babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4473. static readonly GEQUAL: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/webRequest" {
  4967. /**
  4968. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4969. */
  4970. export class WebRequest {
  4971. private _xhr;
  4972. /**
  4973. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4974. * i.e. when loading files, where the server/service expects an Authorization header
  4975. */
  4976. static CustomRequestHeaders: {
  4977. [key: string]: string;
  4978. };
  4979. /**
  4980. * Add callback functions in this array to update all the requests before they get sent to the network
  4981. */
  4982. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4983. private _injectCustomRequestHeaders;
  4984. /**
  4985. * Gets or sets a function to be called when loading progress changes
  4986. */
  4987. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4988. /**
  4989. * Returns client's state
  4990. */
  4991. readonly readyState: number;
  4992. /**
  4993. * Returns client's status
  4994. */
  4995. readonly status: number;
  4996. /**
  4997. * Returns client's status as a text
  4998. */
  4999. readonly statusText: string;
  5000. /**
  5001. * Returns client's response
  5002. */
  5003. readonly response: any;
  5004. /**
  5005. * Returns client's response url
  5006. */
  5007. readonly responseURL: string;
  5008. /**
  5009. * Returns client's response as text
  5010. */
  5011. readonly responseText: string;
  5012. /**
  5013. * Gets or sets the expected response type
  5014. */
  5015. responseType: XMLHttpRequestResponseType;
  5016. /** @hidden */
  5017. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5018. /** @hidden */
  5019. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5020. /**
  5021. * Cancels any network activity
  5022. */
  5023. abort(): void;
  5024. /**
  5025. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5026. * @param body defines an optional request body
  5027. */
  5028. send(body?: Document | BodyInit | null): void;
  5029. /**
  5030. * Sets the request method, request URL
  5031. * @param method defines the method to use (GET, POST, etc..)
  5032. * @param url defines the url to connect with
  5033. */
  5034. open(method: string, url: string): void;
  5035. }
  5036. }
  5037. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5038. /**
  5039. * Class used to evalaute queries containing `and` and `or` operators
  5040. */
  5041. export class AndOrNotEvaluator {
  5042. /**
  5043. * Evaluate a query
  5044. * @param query defines the query to evaluate
  5045. * @param evaluateCallback defines the callback used to filter result
  5046. * @returns true if the query matches
  5047. */
  5048. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5049. private static _HandleParenthesisContent;
  5050. private static _SimplifyNegation;
  5051. }
  5052. }
  5053. declare module "babylonjs/Misc/tags" {
  5054. /**
  5055. * Class used to store custom tags
  5056. */
  5057. export class Tags {
  5058. /**
  5059. * Adds support for tags on the given object
  5060. * @param obj defines the object to use
  5061. */
  5062. static EnableFor(obj: any): void;
  5063. /**
  5064. * Removes tags support
  5065. * @param obj defines the object to use
  5066. */
  5067. static DisableFor(obj: any): void;
  5068. /**
  5069. * Gets a boolean indicating if the given object has tags
  5070. * @param obj defines the object to use
  5071. * @returns a boolean
  5072. */
  5073. static HasTags(obj: any): boolean;
  5074. /**
  5075. * Gets the tags available on a given object
  5076. * @param obj defines the object to use
  5077. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5078. * @returns the tags
  5079. */
  5080. static GetTags(obj: any, asString?: boolean): any;
  5081. /**
  5082. * Adds tags to an object
  5083. * @param obj defines the object to use
  5084. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5085. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5086. */
  5087. static AddTagsTo(obj: any, tagsString: string): void;
  5088. /**
  5089. * @hidden
  5090. */
  5091. static _AddTagTo(obj: any, tag: string): void;
  5092. /**
  5093. * Removes specific tags from a specific object
  5094. * @param obj defines the object to use
  5095. * @param tagsString defines the tags to remove
  5096. */
  5097. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _RemoveTagFrom(obj: any, tag: string): void;
  5102. /**
  5103. * Defines if tags hosted on an object match a given query
  5104. * @param obj defines the object to use
  5105. * @param tagsQuery defines the tag query
  5106. * @returns a boolean
  5107. */
  5108. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5109. }
  5110. }
  5111. declare module "babylonjs/Materials/materialDefines" {
  5112. /**
  5113. * Manages the defines for the Material
  5114. */
  5115. export class MaterialDefines {
  5116. private _keys;
  5117. private _isDirty;
  5118. /** @hidden */
  5119. _renderId: number;
  5120. /** @hidden */
  5121. _areLightsDirty: boolean;
  5122. /** @hidden */
  5123. _areAttributesDirty: boolean;
  5124. /** @hidden */
  5125. _areTexturesDirty: boolean;
  5126. /** @hidden */
  5127. _areFresnelDirty: boolean;
  5128. /** @hidden */
  5129. _areMiscDirty: boolean;
  5130. /** @hidden */
  5131. _areImageProcessingDirty: boolean;
  5132. /** @hidden */
  5133. _normals: boolean;
  5134. /** @hidden */
  5135. _uvs: boolean;
  5136. /** @hidden */
  5137. _needNormals: boolean;
  5138. /** @hidden */
  5139. _needUVs: boolean;
  5140. /**
  5141. * Specifies if the material needs to be re-calculated
  5142. */
  5143. readonly isDirty: boolean;
  5144. /**
  5145. * Marks the material to indicate that it has been re-calculated
  5146. */
  5147. markAsProcessed(): void;
  5148. /**
  5149. * Marks the material to indicate that it needs to be re-calculated
  5150. */
  5151. markAsUnprocessed(): void;
  5152. /**
  5153. * Marks the material to indicate all of its defines need to be re-calculated
  5154. */
  5155. markAllAsDirty(): void;
  5156. /**
  5157. * Marks the material to indicate that image processing needs to be re-calculated
  5158. */
  5159. markAsImageProcessingDirty(): void;
  5160. /**
  5161. * Marks the material to indicate the lights need to be re-calculated
  5162. */
  5163. markAsLightDirty(): void;
  5164. /**
  5165. * Marks the attribute state as changed
  5166. */
  5167. markAsAttributesDirty(): void;
  5168. /**
  5169. * Marks the texture state as changed
  5170. */
  5171. markAsTexturesDirty(): void;
  5172. /**
  5173. * Marks the fresnel state as changed
  5174. */
  5175. markAsFresnelDirty(): void;
  5176. /**
  5177. * Marks the misc state as changed
  5178. */
  5179. markAsMiscDirty(): void;
  5180. /**
  5181. * Rebuilds the material defines
  5182. */
  5183. rebuild(): void;
  5184. /**
  5185. * Specifies if two material defines are equal
  5186. * @param other - A material define instance to compare to
  5187. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5188. */
  5189. isEqual(other: MaterialDefines): boolean;
  5190. /**
  5191. * Clones this instance's defines to another instance
  5192. * @param other - material defines to clone values to
  5193. */
  5194. cloneTo(other: MaterialDefines): void;
  5195. /**
  5196. * Resets the material define values
  5197. */
  5198. reset(): void;
  5199. /**
  5200. * Converts the material define values to a string
  5201. * @returns - String of material define information
  5202. */
  5203. toString(): string;
  5204. }
  5205. }
  5206. declare module "babylonjs/Misc/performanceMonitor" {
  5207. /**
  5208. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5209. */
  5210. export class PerformanceMonitor {
  5211. private _enabled;
  5212. private _rollingFrameTime;
  5213. private _lastFrameTimeMs;
  5214. /**
  5215. * constructor
  5216. * @param frameSampleSize The number of samples required to saturate the sliding window
  5217. */
  5218. constructor(frameSampleSize?: number);
  5219. /**
  5220. * Samples current frame
  5221. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5222. */
  5223. sampleFrame(timeMs?: number): void;
  5224. /**
  5225. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5226. */
  5227. readonly averageFrameTime: number;
  5228. /**
  5229. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5230. */
  5231. readonly averageFrameTimeVariance: number;
  5232. /**
  5233. * Returns the frame time of the most recent frame
  5234. */
  5235. readonly instantaneousFrameTime: number;
  5236. /**
  5237. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFPS: number;
  5240. /**
  5241. * Returns the average framerate in frames per second using the most recent frame time
  5242. */
  5243. readonly instantaneousFPS: number;
  5244. /**
  5245. * Returns true if enough samples have been taken to completely fill the sliding window
  5246. */
  5247. readonly isSaturated: boolean;
  5248. /**
  5249. * Enables contributions to the sliding window sample set
  5250. */
  5251. enable(): void;
  5252. /**
  5253. * Disables contributions to the sliding window sample set
  5254. * Samples will not be interpolated over the disabled period
  5255. */
  5256. disable(): void;
  5257. /**
  5258. * Returns true if sampling is enabled
  5259. */
  5260. readonly isEnabled: boolean;
  5261. /**
  5262. * Resets performance monitor
  5263. */
  5264. reset(): void;
  5265. }
  5266. /**
  5267. * RollingAverage
  5268. *
  5269. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5270. */
  5271. export class RollingAverage {
  5272. /**
  5273. * Current average
  5274. */
  5275. average: number;
  5276. /**
  5277. * Current variance
  5278. */
  5279. variance: number;
  5280. protected _samples: Array<number>;
  5281. protected _sampleCount: number;
  5282. protected _pos: number;
  5283. protected _m2: number;
  5284. /**
  5285. * constructor
  5286. * @param length The number of samples required to saturate the sliding window
  5287. */
  5288. constructor(length: number);
  5289. /**
  5290. * Adds a sample to the sample set
  5291. * @param v The sample value
  5292. */
  5293. add(v: number): void;
  5294. /**
  5295. * Returns previously added values or null if outside of history or outside the sliding window domain
  5296. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5297. * @return Value previously recorded with add() or null if outside of range
  5298. */
  5299. history(i: number): number;
  5300. /**
  5301. * Returns true if enough samples have been taken to completely fill the sliding window
  5302. * @return true if sample-set saturated
  5303. */
  5304. isSaturated(): boolean;
  5305. /**
  5306. * Resets the rolling average (equivalent to 0 samples taken so far)
  5307. */
  5308. reset(): void;
  5309. /**
  5310. * Wraps a value around the sample range boundaries
  5311. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5312. * @return Wrapped position in sample range
  5313. */
  5314. protected _wrapPosition(i: number): number;
  5315. }
  5316. }
  5317. declare module "babylonjs/Misc/stringDictionary" {
  5318. import { Nullable } from "babylonjs/types";
  5319. /**
  5320. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5321. * The underlying implementation relies on an associative array to ensure the best performances.
  5322. * The value can be anything including 'null' but except 'undefined'
  5323. */
  5324. export class StringDictionary<T> {
  5325. /**
  5326. * This will clear this dictionary and copy the content from the 'source' one.
  5327. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5328. * @param source the dictionary to take the content from and copy to this dictionary
  5329. */
  5330. copyFrom(source: StringDictionary<T>): void;
  5331. /**
  5332. * Get a value based from its key
  5333. * @param key the given key to get the matching value from
  5334. * @return the value if found, otherwise undefined is returned
  5335. */
  5336. get(key: string): T | undefined;
  5337. /**
  5338. * Get a value from its key or add it if it doesn't exist.
  5339. * This method will ensure you that a given key/data will be present in the dictionary.
  5340. * @param key the given key to get the matching value from
  5341. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5342. * The factory will only be invoked if there's no data for the given key.
  5343. * @return the value corresponding to the key.
  5344. */
  5345. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5346. /**
  5347. * Get a value from its key if present in the dictionary otherwise add it
  5348. * @param key the key to get the value from
  5349. * @param val if there's no such key/value pair in the dictionary add it with this value
  5350. * @return the value corresponding to the key
  5351. */
  5352. getOrAdd(key: string, val: T): T;
  5353. /**
  5354. * Check if there's a given key in the dictionary
  5355. * @param key the key to check for
  5356. * @return true if the key is present, false otherwise
  5357. */
  5358. contains(key: string): boolean;
  5359. /**
  5360. * Add a new key and its corresponding value
  5361. * @param key the key to add
  5362. * @param value the value corresponding to the key
  5363. * @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
  5364. */
  5365. add(key: string, value: T): boolean;
  5366. /**
  5367. * Update a specific value associated to a key
  5368. * @param key defines the key to use
  5369. * @param value defines the value to store
  5370. * @returns true if the value was updated (or false if the key was not found)
  5371. */
  5372. set(key: string, value: T): boolean;
  5373. /**
  5374. * Get the element of the given key and remove it from the dictionary
  5375. * @param key defines the key to search
  5376. * @returns the value associated with the key or null if not found
  5377. */
  5378. getAndRemove(key: string): Nullable<T>;
  5379. /**
  5380. * Remove a key/value from the dictionary.
  5381. * @param key the key to remove
  5382. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5383. */
  5384. remove(key: string): boolean;
  5385. /**
  5386. * Clear the whole content of the dictionary
  5387. */
  5388. clear(): void;
  5389. /**
  5390. * Gets the current count
  5391. */
  5392. readonly count: number;
  5393. /**
  5394. * Execute a callback on each key/val of the dictionary.
  5395. * Note that you can remove any element in this dictionary in the callback implementation
  5396. * @param callback the callback to execute on a given key/value pair
  5397. */
  5398. forEach(callback: (key: string, val: T) => void): void;
  5399. /**
  5400. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5401. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5404. * @returns the first item
  5405. */
  5406. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5407. private _count;
  5408. private _data;
  5409. }
  5410. }
  5411. declare module "babylonjs/Misc/promise" {
  5412. /**
  5413. * Helper class that provides a small promise polyfill
  5414. */
  5415. export class PromisePolyfill {
  5416. /**
  5417. * Static function used to check if the polyfill is required
  5418. * If this is the case then the function will inject the polyfill to window.Promise
  5419. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5420. */
  5421. static Apply(force?: boolean): void;
  5422. }
  5423. }
  5424. declare module "babylonjs/Meshes/buffer" {
  5425. import { Nullable, DataArray } from "babylonjs/types";
  5426. /**
  5427. * Class used to store data that will be store in GPU memory
  5428. */
  5429. export class Buffer {
  5430. private _engine;
  5431. private _buffer;
  5432. /** @hidden */
  5433. _data: Nullable<DataArray>;
  5434. private _updatable;
  5435. private _instanced;
  5436. /**
  5437. * Gets the byte stride.
  5438. */
  5439. readonly byteStride: number;
  5440. /**
  5441. * Constructor
  5442. * @param engine the engine
  5443. * @param data the data to use for this buffer
  5444. * @param updatable whether the data is updatable
  5445. * @param stride the stride (optional)
  5446. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5447. * @param instanced whether the buffer is instanced (optional)
  5448. * @param useBytes set to true if the stride in in bytes (optional)
  5449. */
  5450. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5451. /**
  5452. * Create a new VertexBuffer based on the current buffer
  5453. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5454. * @param offset defines offset in the buffer (0 by default)
  5455. * @param size defines the size in floats of attributes (position is 3 for instance)
  5456. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5457. * @param instanced defines if the vertex buffer contains indexed data
  5458. * @param useBytes defines if the offset and stride are in bytes
  5459. * @returns the new vertex buffer
  5460. */
  5461. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5462. /**
  5463. * Gets a boolean indicating if the Buffer is updatable?
  5464. * @returns true if the buffer is updatable
  5465. */
  5466. isUpdatable(): boolean;
  5467. /**
  5468. * Gets current buffer's data
  5469. * @returns a DataArray or null
  5470. */
  5471. getData(): Nullable<DataArray>;
  5472. /**
  5473. * Gets underlying native buffer
  5474. * @returns underlying native buffer
  5475. */
  5476. getBuffer(): Nullable<WebGLBuffer>;
  5477. /**
  5478. * Gets the stride in float32 units (i.e. byte stride / 4).
  5479. * May not be an integer if the byte stride is not divisible by 4.
  5480. * DEPRECATED. Use byteStride instead.
  5481. * @returns the stride in float32 units
  5482. */
  5483. getStrideSize(): number;
  5484. /**
  5485. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5486. * @param data defines the data to store
  5487. */
  5488. create(data?: Nullable<DataArray>): void;
  5489. /** @hidden */
  5490. _rebuild(): void;
  5491. /**
  5492. * Update current buffer data
  5493. * @param data defines the data to store
  5494. */
  5495. update(data: DataArray): void;
  5496. /**
  5497. * Updates the data directly.
  5498. * @param data the new data
  5499. * @param offset the new offset
  5500. * @param vertexCount the vertex count (optional)
  5501. * @param useBytes set to true if the offset is in bytes
  5502. */
  5503. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5504. /**
  5505. * Release all resources
  5506. */
  5507. dispose(): void;
  5508. }
  5509. /**
  5510. * Specialized buffer used to store vertex data
  5511. */
  5512. export class VertexBuffer {
  5513. /** @hidden */
  5514. _buffer: Buffer;
  5515. private _kind;
  5516. private _size;
  5517. private _ownsBuffer;
  5518. private _instanced;
  5519. private _instanceDivisor;
  5520. /**
  5521. * The byte type.
  5522. */
  5523. static readonly BYTE: number;
  5524. /**
  5525. * The unsigned byte type.
  5526. */
  5527. static readonly UNSIGNED_BYTE: number;
  5528. /**
  5529. * The short type.
  5530. */
  5531. static readonly SHORT: number;
  5532. /**
  5533. * The unsigned short type.
  5534. */
  5535. static readonly UNSIGNED_SHORT: number;
  5536. /**
  5537. * The integer type.
  5538. */
  5539. static readonly INT: number;
  5540. /**
  5541. * The unsigned integer type.
  5542. */
  5543. static readonly UNSIGNED_INT: number;
  5544. /**
  5545. * The float type.
  5546. */
  5547. static readonly FLOAT: number;
  5548. /**
  5549. * Gets or sets the instance divisor when in instanced mode
  5550. */
  5551. instanceDivisor: number;
  5552. /**
  5553. * Gets the byte stride.
  5554. */
  5555. readonly byteStride: number;
  5556. /**
  5557. * Gets the byte offset.
  5558. */
  5559. readonly byteOffset: number;
  5560. /**
  5561. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5562. */
  5563. readonly normalized: boolean;
  5564. /**
  5565. * Gets the data type of each component in the array.
  5566. */
  5567. readonly type: number;
  5568. /**
  5569. * Constructor
  5570. * @param engine the engine
  5571. * @param data the data to use for this vertex buffer
  5572. * @param kind the vertex buffer kind
  5573. * @param updatable whether the data is updatable
  5574. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5575. * @param stride the stride (optional)
  5576. * @param instanced whether the buffer is instanced (optional)
  5577. * @param offset the offset of the data (optional)
  5578. * @param size the number of components (optional)
  5579. * @param type the type of the component (optional)
  5580. * @param normalized whether the data contains normalized data (optional)
  5581. * @param useBytes set to true if stride and offset are in bytes (optional)
  5582. */
  5583. 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);
  5584. /** @hidden */
  5585. _rebuild(): void;
  5586. /**
  5587. * Returns the kind of the VertexBuffer (string)
  5588. * @returns a string
  5589. */
  5590. getKind(): string;
  5591. /**
  5592. * Gets a boolean indicating if the VertexBuffer is updatable?
  5593. * @returns true if the buffer is updatable
  5594. */
  5595. isUpdatable(): boolean;
  5596. /**
  5597. * Gets current buffer's data
  5598. * @returns a DataArray or null
  5599. */
  5600. getData(): Nullable<DataArray>;
  5601. /**
  5602. * Gets underlying native buffer
  5603. * @returns underlying native buffer
  5604. */
  5605. getBuffer(): Nullable<WebGLBuffer>;
  5606. /**
  5607. * Gets the stride in float32 units (i.e. byte stride / 4).
  5608. * May not be an integer if the byte stride is not divisible by 4.
  5609. * DEPRECATED. Use byteStride instead.
  5610. * @returns the stride in float32 units
  5611. */
  5612. getStrideSize(): number;
  5613. /**
  5614. * Returns the offset as a multiple of the type byte length.
  5615. * DEPRECATED. Use byteOffset instead.
  5616. * @returns the offset in bytes
  5617. */
  5618. getOffset(): number;
  5619. /**
  5620. * Returns the number of components per vertex attribute (integer)
  5621. * @returns the size in float
  5622. */
  5623. getSize(): number;
  5624. /**
  5625. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5626. * @returns true if this buffer is instanced
  5627. */
  5628. getIsInstanced(): boolean;
  5629. /**
  5630. * Returns the instancing divisor, zero for non-instanced (integer).
  5631. * @returns a number
  5632. */
  5633. getInstanceDivisor(): number;
  5634. /**
  5635. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5636. * @param data defines the data to store
  5637. */
  5638. create(data?: DataArray): void;
  5639. /**
  5640. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5641. * This function will create a new buffer if the current one is not updatable
  5642. * @param data defines the data to store
  5643. */
  5644. update(data: DataArray): void;
  5645. /**
  5646. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5647. * Returns the directly updated WebGLBuffer.
  5648. * @param data the new data
  5649. * @param offset the new offset
  5650. * @param useBytes set to true if the offset is in bytes
  5651. */
  5652. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5653. /**
  5654. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5655. */
  5656. dispose(): void;
  5657. /**
  5658. * Enumerates each value of this vertex buffer as numbers.
  5659. * @param count the number of values to enumerate
  5660. * @param callback the callback function called for each value
  5661. */
  5662. forEach(count: number, callback: (value: number, index: number) => void): void;
  5663. /**
  5664. * Positions
  5665. */
  5666. static readonly PositionKind: string;
  5667. /**
  5668. * Normals
  5669. */
  5670. static readonly NormalKind: string;
  5671. /**
  5672. * Tangents
  5673. */
  5674. static readonly TangentKind: string;
  5675. /**
  5676. * Texture coordinates
  5677. */
  5678. static readonly UVKind: string;
  5679. /**
  5680. * Texture coordinates 2
  5681. */
  5682. static readonly UV2Kind: string;
  5683. /**
  5684. * Texture coordinates 3
  5685. */
  5686. static readonly UV3Kind: string;
  5687. /**
  5688. * Texture coordinates 4
  5689. */
  5690. static readonly UV4Kind: string;
  5691. /**
  5692. * Texture coordinates 5
  5693. */
  5694. static readonly UV5Kind: string;
  5695. /**
  5696. * Texture coordinates 6
  5697. */
  5698. static readonly UV6Kind: string;
  5699. /**
  5700. * Colors
  5701. */
  5702. static readonly ColorKind: string;
  5703. /**
  5704. * Matrix indices (for bones)
  5705. */
  5706. static readonly MatricesIndicesKind: string;
  5707. /**
  5708. * Matrix weights (for bones)
  5709. */
  5710. static readonly MatricesWeightsKind: string;
  5711. /**
  5712. * Additional matrix indices (for bones)
  5713. */
  5714. static readonly MatricesIndicesExtraKind: string;
  5715. /**
  5716. * Additional matrix weights (for bones)
  5717. */
  5718. static readonly MatricesWeightsExtraKind: string;
  5719. /**
  5720. * Deduces the stride given a kind.
  5721. * @param kind The kind string to deduce
  5722. * @returns The deduced stride
  5723. */
  5724. static DeduceStride(kind: string): number;
  5725. /**
  5726. * Gets the byte length of the given type.
  5727. * @param type the type
  5728. * @returns the number of bytes
  5729. */
  5730. static GetTypeByteLength(type: number): number;
  5731. /**
  5732. * Enumerates each value of the given parameters as numbers.
  5733. * @param data the data to enumerate
  5734. * @param byteOffset the byte offset of the data
  5735. * @param byteStride the byte stride of the data
  5736. * @param componentCount the number of components per element
  5737. * @param componentType the type of the component
  5738. * @param count the total number of components
  5739. * @param normalized whether the data is normalized
  5740. * @param callback the callback function called for each value
  5741. */
  5742. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5743. private static _GetFloatValue;
  5744. }
  5745. }
  5746. declare module "babylonjs/Maths/sphericalPolynomial" {
  5747. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5748. /**
  5749. * Class representing spherical polynomial coefficients to the 3rd degree
  5750. */
  5751. export class SphericalPolynomial {
  5752. /**
  5753. * The x coefficients of the spherical polynomial
  5754. */
  5755. x: Vector3;
  5756. /**
  5757. * The y coefficients of the spherical polynomial
  5758. */
  5759. y: Vector3;
  5760. /**
  5761. * The z coefficients of the spherical polynomial
  5762. */
  5763. z: Vector3;
  5764. /**
  5765. * The xx coefficients of the spherical polynomial
  5766. */
  5767. xx: Vector3;
  5768. /**
  5769. * The yy coefficients of the spherical polynomial
  5770. */
  5771. yy: Vector3;
  5772. /**
  5773. * The zz coefficients of the spherical polynomial
  5774. */
  5775. zz: Vector3;
  5776. /**
  5777. * The xy coefficients of the spherical polynomial
  5778. */
  5779. xy: Vector3;
  5780. /**
  5781. * The yz coefficients of the spherical polynomial
  5782. */
  5783. yz: Vector3;
  5784. /**
  5785. * The zx coefficients of the spherical polynomial
  5786. */
  5787. zx: Vector3;
  5788. /**
  5789. * Adds an ambient color to the spherical polynomial
  5790. * @param color the color to add
  5791. */
  5792. addAmbient(color: Color3): void;
  5793. /**
  5794. * Scales the spherical polynomial by the given amount
  5795. * @param scale the amount to scale
  5796. */
  5797. scale(scale: number): void;
  5798. /**
  5799. * Gets the spherical polynomial from harmonics
  5800. * @param harmonics the spherical harmonics
  5801. * @returns the spherical polynomial
  5802. */
  5803. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5804. /**
  5805. * Constructs a spherical polynomial from an array.
  5806. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5807. * @returns the spherical polynomial
  5808. */
  5809. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5810. }
  5811. /**
  5812. * Class representing spherical harmonics coefficients to the 3rd degree
  5813. */
  5814. export class SphericalHarmonics {
  5815. /**
  5816. * The l0,0 coefficients of the spherical harmonics
  5817. */
  5818. l00: Vector3;
  5819. /**
  5820. * The l1,-1 coefficients of the spherical harmonics
  5821. */
  5822. l1_1: Vector3;
  5823. /**
  5824. * The l1,0 coefficients of the spherical harmonics
  5825. */
  5826. l10: Vector3;
  5827. /**
  5828. * The l1,1 coefficients of the spherical harmonics
  5829. */
  5830. l11: Vector3;
  5831. /**
  5832. * The l2,-2 coefficients of the spherical harmonics
  5833. */
  5834. l2_2: Vector3;
  5835. /**
  5836. * The l2,-1 coefficients of the spherical harmonics
  5837. */
  5838. l2_1: Vector3;
  5839. /**
  5840. * The l2,0 coefficients of the spherical harmonics
  5841. */
  5842. l20: Vector3;
  5843. /**
  5844. * The l2,1 coefficients of the spherical harmonics
  5845. */
  5846. l21: Vector3;
  5847. /**
  5848. * The l2,2 coefficients of the spherical harmonics
  5849. */
  5850. lL22: Vector3;
  5851. /**
  5852. * Adds a light to the spherical harmonics
  5853. * @param direction the direction of the light
  5854. * @param color the color of the light
  5855. * @param deltaSolidAngle the delta solid angle of the light
  5856. */
  5857. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5858. /**
  5859. * Scales the spherical harmonics by the given amount
  5860. * @param scale the amount to scale
  5861. */
  5862. scale(scale: number): void;
  5863. /**
  5864. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5865. *
  5866. * ```
  5867. * E_lm = A_l * L_lm
  5868. * ```
  5869. *
  5870. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5871. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5872. * the scaling factors are given in equation 9.
  5873. */
  5874. convertIncidentRadianceToIrradiance(): void;
  5875. /**
  5876. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5877. *
  5878. * ```
  5879. * L = (1/pi) * E * rho
  5880. * ```
  5881. *
  5882. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5883. */
  5884. convertIrradianceToLambertianRadiance(): void;
  5885. /**
  5886. * Gets the spherical harmonics from polynomial
  5887. * @param polynomial the spherical polynomial
  5888. * @returns the spherical harmonics
  5889. */
  5890. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5891. /**
  5892. * Constructs a spherical harmonics from an array.
  5893. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5894. * @returns the spherical harmonics
  5895. */
  5896. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5897. }
  5898. }
  5899. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5900. import { Nullable } from "babylonjs/types";
  5901. /**
  5902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5903. */
  5904. export interface CubeMapInfo {
  5905. /**
  5906. * The pixel array for the front face.
  5907. * This is stored in format, left to right, up to down format.
  5908. */
  5909. front: Nullable<ArrayBufferView>;
  5910. /**
  5911. * The pixel array for the back face.
  5912. * This is stored in format, left to right, up to down format.
  5913. */
  5914. back: Nullable<ArrayBufferView>;
  5915. /**
  5916. * The pixel array for the left face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. left: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the right face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. right: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the up face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. up: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the down face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. down: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The size of the cubemap stored.
  5937. *
  5938. * Each faces will be size * size pixels.
  5939. */
  5940. size: number;
  5941. /**
  5942. * The format of the texture.
  5943. *
  5944. * RGBA, RGB.
  5945. */
  5946. format: number;
  5947. /**
  5948. * The type of the texture data.
  5949. *
  5950. * UNSIGNED_INT, FLOAT.
  5951. */
  5952. type: number;
  5953. /**
  5954. * Specifies whether the texture is in gamma space.
  5955. */
  5956. gammaSpace: boolean;
  5957. }
  5958. /**
  5959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5960. */
  5961. export class PanoramaToCubeMapTools {
  5962. private static FACE_FRONT;
  5963. private static FACE_BACK;
  5964. private static FACE_RIGHT;
  5965. private static FACE_LEFT;
  5966. private static FACE_DOWN;
  5967. private static FACE_UP;
  5968. /**
  5969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5970. *
  5971. * @param float32Array The source data.
  5972. * @param inputWidth The width of the input panorama.
  5973. * @param inputHeight The height of the input panorama.
  5974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5975. * @return The cubemap data
  5976. */
  5977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5978. private static CreateCubemapTexture;
  5979. private static CalcProjectionSpherical;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5983. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5985. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5986. /**
  5987. * Helper class dealing with the extraction of spherical polynomial dataArray
  5988. * from a cube map.
  5989. */
  5990. export class CubeMapToSphericalPolynomialTools {
  5991. private static FileFaces;
  5992. /**
  5993. * Converts a texture to the according Spherical Polynomial data.
  5994. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5995. *
  5996. * @param texture The texture to extract the information from.
  5997. * @return The Spherical Polynomial data.
  5998. */
  5999. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6000. /**
  6001. * Converts a cubemap to the according Spherical Polynomial data.
  6002. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6003. *
  6004. * @param cubeInfo The Cube map to extract the information from.
  6005. * @return The Spherical Polynomial data.
  6006. */
  6007. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6008. }
  6009. }
  6010. declare module "babylonjs/Engines/engineStore" {
  6011. import { Nullable } from "babylonjs/types";
  6012. import { Engine } from "babylonjs/Engines/engine";
  6013. import { Scene } from "babylonjs/scene";
  6014. /**
  6015. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6016. * during the life time of the application.
  6017. */
  6018. export class EngineStore {
  6019. /** Gets the list of created engines */
  6020. static Instances: import("babylonjs/Engines/engine").Engine[];
  6021. /**
  6022. * Gets the latest created engine
  6023. */
  6024. static readonly LastCreatedEngine: Nullable<Engine>;
  6025. /**
  6026. * Gets the latest created scene
  6027. */
  6028. static readonly LastCreatedScene: Nullable<Scene>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6032. /**
  6033. * Define options used to create a render target texture
  6034. */
  6035. export class RenderTargetCreationOptions {
  6036. /**
  6037. * Specifies is mipmaps must be generated
  6038. */
  6039. generateMipMaps?: boolean;
  6040. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6041. generateDepthBuffer?: boolean;
  6042. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6043. generateStencilBuffer?: boolean;
  6044. /** Defines texture type (int by default) */
  6045. type?: number;
  6046. /** Defines sampling mode (trilinear by default) */
  6047. samplingMode?: number;
  6048. /** Defines format (RGBA by default) */
  6049. format?: number;
  6050. }
  6051. }
  6052. declare module "babylonjs/States/alphaCullingState" {
  6053. /**
  6054. * @hidden
  6055. **/
  6056. export class _AlphaState {
  6057. private _isAlphaBlendDirty;
  6058. private _isBlendFunctionParametersDirty;
  6059. private _isBlendEquationParametersDirty;
  6060. private _isBlendConstantsDirty;
  6061. private _alphaBlend;
  6062. private _blendFunctionParameters;
  6063. private _blendEquationParameters;
  6064. private _blendConstants;
  6065. /**
  6066. * Initializes the state.
  6067. */
  6068. constructor();
  6069. readonly isDirty: boolean;
  6070. alphaBlend: boolean;
  6071. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6072. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6073. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6074. reset(): void;
  6075. apply(gl: WebGLRenderingContext): void;
  6076. }
  6077. }
  6078. declare module "babylonjs/States/depthCullingState" {
  6079. import { Nullable } from "babylonjs/types";
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _DepthCullingState {
  6084. private _isDepthTestDirty;
  6085. private _isDepthMaskDirty;
  6086. private _isDepthFuncDirty;
  6087. private _isCullFaceDirty;
  6088. private _isCullDirty;
  6089. private _isZOffsetDirty;
  6090. private _isFrontFaceDirty;
  6091. private _depthTest;
  6092. private _depthMask;
  6093. private _depthFunc;
  6094. private _cull;
  6095. private _cullFace;
  6096. private _zOffset;
  6097. private _frontFace;
  6098. /**
  6099. * Initializes the state.
  6100. */
  6101. constructor();
  6102. readonly isDirty: boolean;
  6103. zOffset: number;
  6104. cullFace: Nullable<number>;
  6105. cull: Nullable<boolean>;
  6106. depthFunc: Nullable<number>;
  6107. depthMask: boolean;
  6108. depthTest: boolean;
  6109. frontFace: Nullable<number>;
  6110. reset(): void;
  6111. apply(gl: WebGLRenderingContext): void;
  6112. }
  6113. }
  6114. declare module "babylonjs/States/stencilState" {
  6115. /**
  6116. * @hidden
  6117. **/
  6118. export class _StencilState {
  6119. /** 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 */
  6120. static readonly ALWAYS: number;
  6121. /** Passed to stencilOperation to specify that stencil value must be kept */
  6122. static readonly KEEP: number;
  6123. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6124. static readonly REPLACE: number;
  6125. private _isStencilTestDirty;
  6126. private _isStencilMaskDirty;
  6127. private _isStencilFuncDirty;
  6128. private _isStencilOpDirty;
  6129. private _stencilTest;
  6130. private _stencilMask;
  6131. private _stencilFunc;
  6132. private _stencilFuncRef;
  6133. private _stencilFuncMask;
  6134. private _stencilOpStencilFail;
  6135. private _stencilOpDepthFail;
  6136. private _stencilOpStencilDepthPass;
  6137. readonly isDirty: boolean;
  6138. stencilFunc: number;
  6139. stencilFuncRef: number;
  6140. stencilFuncMask: number;
  6141. stencilOpStencilFail: number;
  6142. stencilOpDepthFail: number;
  6143. stencilOpStencilDepthPass: number;
  6144. stencilMask: number;
  6145. stencilTest: boolean;
  6146. constructor();
  6147. reset(): void;
  6148. apply(gl: WebGLRenderingContext): void;
  6149. }
  6150. }
  6151. declare module "babylonjs/States/index" {
  6152. export * from "babylonjs/States/alphaCullingState";
  6153. export * from "babylonjs/States/depthCullingState";
  6154. export * from "babylonjs/States/stencilState";
  6155. }
  6156. declare module "babylonjs/Instrumentation/timeToken" {
  6157. import { Nullable } from "babylonjs/types";
  6158. /**
  6159. * @hidden
  6160. **/
  6161. export class _TimeToken {
  6162. _startTimeQuery: Nullable<WebGLQuery>;
  6163. _endTimeQuery: Nullable<WebGLQuery>;
  6164. _timeElapsedQuery: Nullable<WebGLQuery>;
  6165. _timeElapsedQueryEnded: boolean;
  6166. }
  6167. }
  6168. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6169. import { Nullable } from "babylonjs/types";
  6170. /**
  6171. * Internal interface used to track InternalTexture already bound to the GL context
  6172. */
  6173. export interface IInternalTextureTracker {
  6174. /**
  6175. * Gets or set the previous tracker in the list
  6176. */
  6177. previous: Nullable<IInternalTextureTracker>;
  6178. /**
  6179. * Gets or set the next tracker in the list
  6180. */
  6181. next: Nullable<IInternalTextureTracker>;
  6182. }
  6183. /**
  6184. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6185. */
  6186. export class DummyInternalTextureTracker {
  6187. /**
  6188. * Gets or set the previous tracker in the list
  6189. */
  6190. previous: Nullable<IInternalTextureTracker>;
  6191. /**
  6192. * Gets or set the next tracker in the list
  6193. */
  6194. next: Nullable<IInternalTextureTracker>;
  6195. }
  6196. }
  6197. declare module "babylonjs/Materials/Textures/internalTexture" {
  6198. import { Observable } from "babylonjs/Misc/observable";
  6199. import { Nullable, int } from "babylonjs/types";
  6200. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6201. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6202. import { Engine } from "babylonjs/Engines/engine";
  6203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6204. /**
  6205. * Class used to store data associated with WebGL texture data for the engine
  6206. * This class should not be used directly
  6207. */
  6208. export class InternalTexture implements IInternalTextureTracker {
  6209. /** hidden */
  6210. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6211. /**
  6212. * The source of the texture data is unknown
  6213. */
  6214. static DATASOURCE_UNKNOWN: number;
  6215. /**
  6216. * Texture data comes from an URL
  6217. */
  6218. static DATASOURCE_URL: number;
  6219. /**
  6220. * Texture data is only used for temporary storage
  6221. */
  6222. static DATASOURCE_TEMP: number;
  6223. /**
  6224. * Texture data comes from raw data (ArrayBuffer)
  6225. */
  6226. static DATASOURCE_RAW: number;
  6227. /**
  6228. * Texture content is dynamic (video or dynamic texture)
  6229. */
  6230. static DATASOURCE_DYNAMIC: number;
  6231. /**
  6232. * Texture content is generated by rendering to it
  6233. */
  6234. static DATASOURCE_RENDERTARGET: number;
  6235. /**
  6236. * Texture content is part of a multi render target process
  6237. */
  6238. static DATASOURCE_MULTIRENDERTARGET: number;
  6239. /**
  6240. * Texture data comes from a cube data file
  6241. */
  6242. static DATASOURCE_CUBE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data
  6245. */
  6246. static DATASOURCE_CUBERAW: number;
  6247. /**
  6248. * Texture data come from a prefiltered cube data file
  6249. */
  6250. static DATASOURCE_CUBEPREFILTERED: number;
  6251. /**
  6252. * Texture content is raw 3D data
  6253. */
  6254. static DATASOURCE_RAW3D: number;
  6255. /**
  6256. * Texture content is a depth texture
  6257. */
  6258. static DATASOURCE_DEPTHTEXTURE: number;
  6259. /**
  6260. * Texture data comes from a raw cube data encoded with RGBD
  6261. */
  6262. static DATASOURCE_CUBERAW_RGBD: number;
  6263. /**
  6264. * Defines if the texture is ready
  6265. */
  6266. isReady: boolean;
  6267. /**
  6268. * Defines if the texture is a cube texture
  6269. */
  6270. isCube: boolean;
  6271. /**
  6272. * Defines if the texture contains 3D data
  6273. */
  6274. is3D: boolean;
  6275. /**
  6276. * Gets the URL used to load this texture
  6277. */
  6278. url: string;
  6279. /**
  6280. * Gets the sampling mode of the texture
  6281. */
  6282. samplingMode: number;
  6283. /**
  6284. * Gets a boolean indicating if the texture needs mipmaps generation
  6285. */
  6286. generateMipMaps: boolean;
  6287. /**
  6288. * Gets the number of samples used by the texture (WebGL2+ only)
  6289. */
  6290. samples: number;
  6291. /**
  6292. * Gets the type of the texture (int, float...)
  6293. */
  6294. type: number;
  6295. /**
  6296. * Gets the format of the texture (RGB, RGBA...)
  6297. */
  6298. format: number;
  6299. /**
  6300. * Observable called when the texture is loaded
  6301. */
  6302. onLoadedObservable: Observable<InternalTexture>;
  6303. /**
  6304. * Gets the width of the texture
  6305. */
  6306. width: number;
  6307. /**
  6308. * Gets the height of the texture
  6309. */
  6310. height: number;
  6311. /**
  6312. * Gets the depth of the texture
  6313. */
  6314. depth: number;
  6315. /**
  6316. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6317. */
  6318. baseWidth: number;
  6319. /**
  6320. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6321. */
  6322. baseHeight: number;
  6323. /**
  6324. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6325. */
  6326. baseDepth: number;
  6327. /**
  6328. * Gets a boolean indicating if the texture is inverted on Y axis
  6329. */
  6330. invertY: boolean;
  6331. /**
  6332. * Gets or set the previous tracker in the list
  6333. */
  6334. previous: Nullable<IInternalTextureTracker>;
  6335. /**
  6336. * Gets or set the next tracker in the list
  6337. */
  6338. next: Nullable<IInternalTextureTracker>;
  6339. /** @hidden */
  6340. _invertVScale: boolean;
  6341. /** @hidden */
  6342. _initialSlot: number;
  6343. /** @hidden */
  6344. _designatedSlot: number;
  6345. /** @hidden */
  6346. _dataSource: number;
  6347. /** @hidden */
  6348. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6349. /** @hidden */
  6350. _bufferView: Nullable<ArrayBufferView>;
  6351. /** @hidden */
  6352. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6353. /** @hidden */
  6354. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6355. /** @hidden */
  6356. _size: number;
  6357. /** @hidden */
  6358. _extension: string;
  6359. /** @hidden */
  6360. _files: Nullable<string[]>;
  6361. /** @hidden */
  6362. _workingCanvas: HTMLCanvasElement;
  6363. /** @hidden */
  6364. _workingContext: CanvasRenderingContext2D;
  6365. /** @hidden */
  6366. _framebuffer: Nullable<WebGLFramebuffer>;
  6367. /** @hidden */
  6368. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6369. /** @hidden */
  6370. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6371. /** @hidden */
  6372. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6373. /** @hidden */
  6374. _attachments: Nullable<number[]>;
  6375. /** @hidden */
  6376. _cachedCoordinatesMode: Nullable<number>;
  6377. /** @hidden */
  6378. _cachedWrapU: Nullable<number>;
  6379. /** @hidden */
  6380. _cachedWrapV: Nullable<number>;
  6381. /** @hidden */
  6382. _cachedWrapR: Nullable<number>;
  6383. /** @hidden */
  6384. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6385. /** @hidden */
  6386. _isDisabled: boolean;
  6387. /** @hidden */
  6388. _compression: Nullable<string>;
  6389. /** @hidden */
  6390. _generateStencilBuffer: boolean;
  6391. /** @hidden */
  6392. _generateDepthBuffer: boolean;
  6393. /** @hidden */
  6394. _comparisonFunction: number;
  6395. /** @hidden */
  6396. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6397. /** @hidden */
  6398. _lodGenerationScale: number;
  6399. /** @hidden */
  6400. _lodGenerationOffset: number;
  6401. /** @hidden */
  6402. _lodTextureHigh: BaseTexture;
  6403. /** @hidden */
  6404. _lodTextureMid: BaseTexture;
  6405. /** @hidden */
  6406. _lodTextureLow: BaseTexture;
  6407. /** @hidden */
  6408. _isRGBD: boolean;
  6409. /** @hidden */
  6410. _webGLTexture: Nullable<WebGLTexture>;
  6411. /** @hidden */
  6412. _references: number;
  6413. private _engine;
  6414. /**
  6415. * Gets the Engine the texture belongs to.
  6416. * @returns The babylon engine
  6417. */
  6418. getEngine(): Engine;
  6419. /**
  6420. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6421. */
  6422. readonly dataSource: number;
  6423. /**
  6424. * Creates a new InternalTexture
  6425. * @param engine defines the engine to use
  6426. * @param dataSource defines the type of data that will be used
  6427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6428. */
  6429. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6430. /**
  6431. * Increments the number of references (ie. the number of Texture that point to it)
  6432. */
  6433. incrementReferences(): void;
  6434. /**
  6435. * Change the size of the texture (not the size of the content)
  6436. * @param width defines the new width
  6437. * @param height defines the new height
  6438. * @param depth defines the new depth (1 by default)
  6439. */
  6440. updateSize(width: int, height: int, depth?: int): void;
  6441. /** @hidden */
  6442. _rebuild(): void;
  6443. /** @hidden */
  6444. _swapAndDie(target: InternalTexture): void;
  6445. /**
  6446. * Dispose the current allocated resources
  6447. */
  6448. dispose(): void;
  6449. }
  6450. }
  6451. declare module "babylonjs/Animations/easing" {
  6452. /**
  6453. * This represents the main contract an easing function should follow.
  6454. * Easing functions are used throughout the animation system.
  6455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6456. */
  6457. export interface IEasingFunction {
  6458. /**
  6459. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6460. * of the easing function.
  6461. * The link below provides some of the most common examples of easing functions.
  6462. * @see https://easings.net/
  6463. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6464. * @returns the corresponding value on the curve defined by the easing function
  6465. */
  6466. ease(gradient: number): number;
  6467. }
  6468. /**
  6469. * Base class used for every default easing function.
  6470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6471. */
  6472. export class EasingFunction implements IEasingFunction {
  6473. /**
  6474. * Interpolation follows the mathematical formula associated with the easing function.
  6475. */
  6476. static readonly EASINGMODE_EASEIN: number;
  6477. /**
  6478. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6479. */
  6480. static readonly EASINGMODE_EASEOUT: number;
  6481. /**
  6482. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6483. */
  6484. static readonly EASINGMODE_EASEINOUT: number;
  6485. private _easingMode;
  6486. /**
  6487. * Sets the easing mode of the current function.
  6488. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6489. */
  6490. setEasingMode(easingMode: number): void;
  6491. /**
  6492. * Gets the current easing mode.
  6493. * @returns the easing mode
  6494. */
  6495. getEasingMode(): number;
  6496. /**
  6497. * @hidden
  6498. */
  6499. easeInCore(gradient: number): number;
  6500. /**
  6501. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6502. * of the easing function.
  6503. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6504. * @returns the corresponding value on the curve defined by the easing function
  6505. */
  6506. ease(gradient: number): number;
  6507. }
  6508. /**
  6509. * Easing function with a circle shape (see link below).
  6510. * @see https://easings.net/#easeInCirc
  6511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6512. */
  6513. export class CircleEase extends EasingFunction implements IEasingFunction {
  6514. /** @hidden */
  6515. easeInCore(gradient: number): number;
  6516. }
  6517. /**
  6518. * Easing function with a ease back shape (see link below).
  6519. * @see https://easings.net/#easeInBack
  6520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6521. */
  6522. export class BackEase extends EasingFunction implements IEasingFunction {
  6523. /** Defines the amplitude of the function */
  6524. amplitude: number;
  6525. /**
  6526. * Instantiates a back ease easing
  6527. * @see https://easings.net/#easeInBack
  6528. * @param amplitude Defines the amplitude of the function
  6529. */
  6530. constructor(
  6531. /** Defines the amplitude of the function */
  6532. amplitude?: number);
  6533. /** @hidden */
  6534. easeInCore(gradient: number): number;
  6535. }
  6536. /**
  6537. * Easing function with a bouncing shape (see link below).
  6538. * @see https://easings.net/#easeInBounce
  6539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6540. */
  6541. export class BounceEase extends EasingFunction implements IEasingFunction {
  6542. /** Defines the number of bounces */
  6543. bounces: number;
  6544. /** Defines the amplitude of the bounce */
  6545. bounciness: number;
  6546. /**
  6547. * Instantiates a bounce easing
  6548. * @see https://easings.net/#easeInBounce
  6549. * @param bounces Defines the number of bounces
  6550. * @param bounciness Defines the amplitude of the bounce
  6551. */
  6552. constructor(
  6553. /** Defines the number of bounces */
  6554. bounces?: number,
  6555. /** Defines the amplitude of the bounce */
  6556. bounciness?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 3 shape (see link below).
  6562. * @see https://easings.net/#easeInCubic
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class CubicEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with an elastic shape (see link below).
  6571. * @see https://easings.net/#easeInElastic
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6575. /** Defines the number of oscillations*/
  6576. oscillations: number;
  6577. /** Defines the amplitude of the oscillations*/
  6578. springiness: number;
  6579. /**
  6580. * Instantiates an elastic easing function
  6581. * @see https://easings.net/#easeInElastic
  6582. * @param oscillations Defines the number of oscillations
  6583. * @param springiness Defines the amplitude of the oscillations
  6584. */
  6585. constructor(
  6586. /** Defines the number of oscillations*/
  6587. oscillations?: number,
  6588. /** Defines the amplitude of the oscillations*/
  6589. springiness?: number);
  6590. /** @hidden */
  6591. easeInCore(gradient: number): number;
  6592. }
  6593. /**
  6594. * Easing function with an exponential shape (see link below).
  6595. * @see https://easings.net/#easeInExpo
  6596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6597. */
  6598. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6599. /** Defines the exponent of the function */
  6600. exponent: number;
  6601. /**
  6602. * Instantiates an exponential easing function
  6603. * @see https://easings.net/#easeInExpo
  6604. * @param exponent Defines the exponent of the function
  6605. */
  6606. constructor(
  6607. /** Defines the exponent of the function */
  6608. exponent?: number);
  6609. /** @hidden */
  6610. easeInCore(gradient: number): number;
  6611. }
  6612. /**
  6613. * Easing function with a power shape (see link below).
  6614. * @see https://easings.net/#easeInQuad
  6615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6616. */
  6617. export class PowerEase extends EasingFunction implements IEasingFunction {
  6618. /** Defines the power of the function */
  6619. power: number;
  6620. /**
  6621. * Instantiates an power base easing function
  6622. * @see https://easings.net/#easeInQuad
  6623. * @param power Defines the power of the function
  6624. */
  6625. constructor(
  6626. /** Defines the power of the function */
  6627. power?: number);
  6628. /** @hidden */
  6629. easeInCore(gradient: number): number;
  6630. }
  6631. /**
  6632. * Easing function with a power of 2 shape (see link below).
  6633. * @see https://easings.net/#easeInQuad
  6634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6635. */
  6636. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6637. /** @hidden */
  6638. easeInCore(gradient: number): number;
  6639. }
  6640. /**
  6641. * Easing function with a power of 4 shape (see link below).
  6642. * @see https://easings.net/#easeInQuart
  6643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6644. */
  6645. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 5 shape (see link below).
  6651. * @see https://easings.net/#easeInQuint
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a sin shape (see link below).
  6660. * @see https://easings.net/#easeInSine
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class SineEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a bezier shape (see link below).
  6669. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6673. /** Defines the x component of the start tangent in the bezier curve */
  6674. x1: number;
  6675. /** Defines the y component of the start tangent in the bezier curve */
  6676. y1: number;
  6677. /** Defines the x component of the end tangent in the bezier curve */
  6678. x2: number;
  6679. /** Defines the y component of the end tangent in the bezier curve */
  6680. y2: number;
  6681. /**
  6682. * Instantiates a bezier function
  6683. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6684. * @param x1 Defines the x component of the start tangent in the bezier curve
  6685. * @param y1 Defines the y component of the start tangent in the bezier curve
  6686. * @param x2 Defines the x component of the end tangent in the bezier curve
  6687. * @param y2 Defines the y component of the end tangent in the bezier curve
  6688. */
  6689. constructor(
  6690. /** Defines the x component of the start tangent in the bezier curve */
  6691. x1?: number,
  6692. /** Defines the y component of the start tangent in the bezier curve */
  6693. y1?: number,
  6694. /** Defines the x component of the end tangent in the bezier curve */
  6695. x2?: number,
  6696. /** Defines the y component of the end tangent in the bezier curve */
  6697. y2?: number);
  6698. /** @hidden */
  6699. easeInCore(gradient: number): number;
  6700. }
  6701. }
  6702. declare module "babylonjs/Animations/animationKey" {
  6703. /**
  6704. * Defines an interface which represents an animation key frame
  6705. */
  6706. export interface IAnimationKey {
  6707. /**
  6708. * Frame of the key frame
  6709. */
  6710. frame: number;
  6711. /**
  6712. * Value at the specifies key frame
  6713. */
  6714. value: any;
  6715. /**
  6716. * The input tangent for the cubic hermite spline
  6717. */
  6718. inTangent?: any;
  6719. /**
  6720. * The output tangent for the cubic hermite spline
  6721. */
  6722. outTangent?: any;
  6723. /**
  6724. * The animation interpolation type
  6725. */
  6726. interpolation?: AnimationKeyInterpolation;
  6727. }
  6728. /**
  6729. * Enum for the animation key frame interpolation type
  6730. */
  6731. export enum AnimationKeyInterpolation {
  6732. /**
  6733. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6734. */
  6735. STEP = 1
  6736. }
  6737. }
  6738. declare module "babylonjs/Animations/animationRange" {
  6739. /**
  6740. * Represents the range of an animation
  6741. */
  6742. export class AnimationRange {
  6743. /**The name of the animation range**/
  6744. name: string;
  6745. /**The starting frame of the animation */
  6746. from: number;
  6747. /**The ending frame of the animation*/
  6748. to: number;
  6749. /**
  6750. * Initializes the range of an animation
  6751. * @param name The name of the animation range
  6752. * @param from The starting frame of the animation
  6753. * @param to The ending frame of the animation
  6754. */
  6755. constructor(
  6756. /**The name of the animation range**/
  6757. name: string,
  6758. /**The starting frame of the animation */
  6759. from: number,
  6760. /**The ending frame of the animation*/
  6761. to: number);
  6762. /**
  6763. * Makes a copy of the animation range
  6764. * @returns A copy of the animation range
  6765. */
  6766. clone(): AnimationRange;
  6767. }
  6768. }
  6769. declare module "babylonjs/Animations/animationEvent" {
  6770. /**
  6771. * Composed of a frame, and an action function
  6772. */
  6773. export class AnimationEvent {
  6774. /** The frame for which the event is triggered **/
  6775. frame: number;
  6776. /** The event to perform when triggered **/
  6777. action: (currentFrame: number) => void;
  6778. /** Specifies if the event should be triggered only once**/
  6779. onlyOnce?: boolean | undefined;
  6780. /**
  6781. * Specifies if the animation event is done
  6782. */
  6783. isDone: boolean;
  6784. /**
  6785. * Initializes the animation event
  6786. * @param frame The frame for which the event is triggered
  6787. * @param action The event to perform when triggered
  6788. * @param onlyOnce Specifies if the event should be triggered only once
  6789. */
  6790. constructor(
  6791. /** The frame for which the event is triggered **/
  6792. frame: number,
  6793. /** The event to perform when triggered **/
  6794. action: (currentFrame: number) => void,
  6795. /** Specifies if the event should be triggered only once**/
  6796. onlyOnce?: boolean | undefined);
  6797. /** @hidden */
  6798. _clone(): AnimationEvent;
  6799. }
  6800. }
  6801. declare module "babylonjs/Behaviors/behavior" {
  6802. import { Nullable } from "babylonjs/types";
  6803. /**
  6804. * Interface used to define a behavior
  6805. */
  6806. export interface Behavior<T> {
  6807. /** gets or sets behavior's name */
  6808. name: string;
  6809. /**
  6810. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6811. */
  6812. init(): void;
  6813. /**
  6814. * Called when the behavior is attached to a target
  6815. * @param target defines the target where the behavior is attached to
  6816. */
  6817. attach(target: T): void;
  6818. /**
  6819. * Called when the behavior is detached from its target
  6820. */
  6821. detach(): void;
  6822. }
  6823. /**
  6824. * Interface implemented by classes supporting behaviors
  6825. */
  6826. export interface IBehaviorAware<T> {
  6827. /**
  6828. * Attach a behavior
  6829. * @param behavior defines the behavior to attach
  6830. * @returns the current host
  6831. */
  6832. addBehavior(behavior: Behavior<T>): T;
  6833. /**
  6834. * Remove a behavior from the current object
  6835. * @param behavior defines the behavior to detach
  6836. * @returns the current host
  6837. */
  6838. removeBehavior(behavior: Behavior<T>): T;
  6839. /**
  6840. * Gets a behavior using its name to search
  6841. * @param name defines the name to search
  6842. * @returns the behavior or null if not found
  6843. */
  6844. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6845. }
  6846. }
  6847. declare module "babylonjs/Collisions/intersectionInfo" {
  6848. import { Nullable } from "babylonjs/types";
  6849. /**
  6850. * @hidden
  6851. */
  6852. export class IntersectionInfo {
  6853. bu: Nullable<number>;
  6854. bv: Nullable<number>;
  6855. distance: number;
  6856. faceId: number;
  6857. subMeshId: number;
  6858. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6859. }
  6860. }
  6861. declare module "babylonjs/Culling/boundingSphere" {
  6862. import { DeepImmutable } from "babylonjs/types";
  6863. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6864. /**
  6865. * Class used to store bounding sphere information
  6866. */
  6867. export class BoundingSphere {
  6868. /**
  6869. * Gets the center of the bounding sphere in local space
  6870. */
  6871. readonly center: Vector3;
  6872. /**
  6873. * Radius of the bounding sphere in local space
  6874. */
  6875. radius: number;
  6876. /**
  6877. * Gets the center of the bounding sphere in world space
  6878. */
  6879. readonly centerWorld: Vector3;
  6880. /**
  6881. * Radius of the bounding sphere in world space
  6882. */
  6883. radiusWorld: number;
  6884. /**
  6885. * Gets the minimum vector in local space
  6886. */
  6887. readonly minimum: Vector3;
  6888. /**
  6889. * Gets the maximum vector in local space
  6890. */
  6891. readonly maximum: Vector3;
  6892. private _worldMatrix;
  6893. private static readonly TmpVector3;
  6894. /**
  6895. * Creates a new bounding sphere
  6896. * @param min defines the minimum vector (in local space)
  6897. * @param max defines the maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6901. /**
  6902. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6903. * @param min defines the new minimum vector (in local space)
  6904. * @param max defines the new maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6908. /**
  6909. * Scale the current bounding sphere by applying a scale factor
  6910. * @param factor defines the scale factor to apply
  6911. * @returns the current bounding box
  6912. */
  6913. scale(factor: number): BoundingSphere;
  6914. /**
  6915. * Gets the world matrix of the bounding box
  6916. * @returns a matrix
  6917. */
  6918. getWorldMatrix(): DeepImmutable<Matrix>;
  6919. /** @hidden */
  6920. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6921. /**
  6922. * Tests if the bounding sphere is intersecting the frustum planes
  6923. * @param frustumPlanes defines the frustum planes to test
  6924. * @returns true if there is an intersection
  6925. */
  6926. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6927. /**
  6928. * Tests if the bounding sphere center is in between the frustum planes.
  6929. * Used for optimistic fast inclusion.
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if the sphere center is in between the frustum planes
  6932. */
  6933. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a point is inside the bounding sphere
  6936. * @param point defines the point to test
  6937. * @returns true if the point is inside the bounding sphere
  6938. */
  6939. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6940. /**
  6941. * Checks if two sphere intersct
  6942. * @param sphere0 sphere 0
  6943. * @param sphere1 sphere 1
  6944. * @returns true if the speres intersect
  6945. */
  6946. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6947. }
  6948. }
  6949. declare module "babylonjs/Culling/boundingBox" {
  6950. import { DeepImmutable } from "babylonjs/types";
  6951. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6952. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6953. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6954. /**
  6955. * Class used to store bounding box information
  6956. */
  6957. export class BoundingBox implements ICullable {
  6958. /**
  6959. * Gets the 8 vectors representing the bounding box in local space
  6960. */
  6961. readonly vectors: Vector3[];
  6962. /**
  6963. * Gets the center of the bounding box in local space
  6964. */
  6965. readonly center: Vector3;
  6966. /**
  6967. * Gets the center of the bounding box in world space
  6968. */
  6969. readonly centerWorld: Vector3;
  6970. /**
  6971. * Gets the extend size in local space
  6972. */
  6973. readonly extendSize: Vector3;
  6974. /**
  6975. * Gets the extend size in world space
  6976. */
  6977. readonly extendSizeWorld: Vector3;
  6978. /**
  6979. * Gets the OBB (object bounding box) directions
  6980. */
  6981. readonly directions: Vector3[];
  6982. /**
  6983. * Gets the 8 vectors representing the bounding box in world space
  6984. */
  6985. readonly vectorsWorld: Vector3[];
  6986. /**
  6987. * Gets the minimum vector in world space
  6988. */
  6989. readonly minimumWorld: Vector3;
  6990. /**
  6991. * Gets the maximum vector in world space
  6992. */
  6993. readonly maximumWorld: Vector3;
  6994. /**
  6995. * Gets the minimum vector in local space
  6996. */
  6997. readonly minimum: Vector3;
  6998. /**
  6999. * Gets the maximum vector in local space
  7000. */
  7001. readonly maximum: Vector3;
  7002. private _worldMatrix;
  7003. private static readonly TmpVector3;
  7004. /**
  7005. * @hidden
  7006. */
  7007. _tag: number;
  7008. /**
  7009. * Creates a new bounding box
  7010. * @param min defines the minimum vector (in local space)
  7011. * @param max defines the maximum vector (in local space)
  7012. * @param worldMatrix defines the new world matrix
  7013. */
  7014. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7015. /**
  7016. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7017. * @param min defines the new minimum vector (in local space)
  7018. * @param max defines the new maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7022. /**
  7023. * Scale the current bounding box by applying a scale factor
  7024. * @param factor defines the scale factor to apply
  7025. * @returns the current bounding box
  7026. */
  7027. scale(factor: number): BoundingBox;
  7028. /**
  7029. * Gets the world matrix of the bounding box
  7030. * @returns a matrix
  7031. */
  7032. getWorldMatrix(): DeepImmutable<Matrix>;
  7033. /** @hidden */
  7034. _update(world: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Tests if the bounding box is intersecting the frustum planes
  7037. * @param frustumPlanes defines the frustum planes to test
  7038. * @returns true if there is an intersection
  7039. */
  7040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7041. /**
  7042. * Tests if the bounding box is entirely inside the frustum planes
  7043. * @param frustumPlanes defines the frustum planes to test
  7044. * @returns true if there is an inclusion
  7045. */
  7046. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7047. /**
  7048. * Tests if a point is inside the bounding box
  7049. * @param point defines the point to test
  7050. * @returns true if the point is inside the bounding box
  7051. */
  7052. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7053. /**
  7054. * Tests if the bounding box intersects with a bounding sphere
  7055. * @param sphere defines the sphere to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7059. /**
  7060. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7061. * @param min defines the min vector to use
  7062. * @param max defines the max vector to use
  7063. * @returns true if there is an intersection
  7064. */
  7065. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Tests if two bounding boxes are intersections
  7068. * @param box0 defines the first box to test
  7069. * @param box1 defines the second box to test
  7070. * @returns true if there is an intersection
  7071. */
  7072. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7073. /**
  7074. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7075. * @param minPoint defines the minimum vector of the bounding box
  7076. * @param maxPoint defines the maximum vector of the bounding box
  7077. * @param sphereCenter defines the sphere center
  7078. * @param sphereRadius defines the sphere radius
  7079. * @returns true if there is an intersection
  7080. */
  7081. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7082. /**
  7083. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7084. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7085. * @param frustumPlanes defines the frustum planes to test
  7086. * @return true if there is an inclusion
  7087. */
  7088. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7089. /**
  7090. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7091. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7092. * @param frustumPlanes defines the frustum planes to test
  7093. * @return true if there is an intersection
  7094. */
  7095. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7096. }
  7097. }
  7098. declare module "babylonjs/Collisions/collider" {
  7099. import { Nullable, IndicesArray } from "babylonjs/types";
  7100. import { Vector3, Plane } from "babylonjs/Maths/math";
  7101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7102. /** @hidden */
  7103. export class Collider {
  7104. /** Define if a collision was found */
  7105. collisionFound: boolean;
  7106. /**
  7107. * Define last intersection point in local space
  7108. */
  7109. intersectionPoint: Vector3;
  7110. /**
  7111. * Define last collided mesh
  7112. */
  7113. collidedMesh: Nullable<AbstractMesh>;
  7114. private _collisionPoint;
  7115. private _planeIntersectionPoint;
  7116. private _tempVector;
  7117. private _tempVector2;
  7118. private _tempVector3;
  7119. private _tempVector4;
  7120. private _edge;
  7121. private _baseToVertex;
  7122. private _destinationPoint;
  7123. private _slidePlaneNormal;
  7124. private _displacementVector;
  7125. /** @hidden */
  7126. _radius: Vector3;
  7127. /** @hidden */
  7128. _retry: number;
  7129. private _velocity;
  7130. private _basePoint;
  7131. private _epsilon;
  7132. /** @hidden */
  7133. _velocityWorldLength: number;
  7134. /** @hidden */
  7135. _basePointWorld: Vector3;
  7136. private _velocityWorld;
  7137. private _normalizedVelocity;
  7138. /** @hidden */
  7139. _initialVelocity: Vector3;
  7140. /** @hidden */
  7141. _initialPosition: Vector3;
  7142. private _nearestDistance;
  7143. private _collisionMask;
  7144. collisionMask: number;
  7145. /**
  7146. * Gets the plane normal used to compute the sliding response (in local space)
  7147. */
  7148. readonly slidePlaneNormal: Vector3;
  7149. /** @hidden */
  7150. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7151. /** @hidden */
  7152. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7153. /** @hidden */
  7154. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7155. /** @hidden */
  7156. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7157. /** @hidden */
  7158. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7159. /** @hidden */
  7160. _getResponse(pos: Vector3, vel: Vector3): void;
  7161. }
  7162. }
  7163. declare module "babylonjs/Culling/boundingInfo" {
  7164. import { DeepImmutable } from "babylonjs/types";
  7165. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7166. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7167. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7168. import { Collider } from "babylonjs/Collisions/collider";
  7169. /**
  7170. * Interface for cullable objects
  7171. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7172. */
  7173. export interface ICullable {
  7174. /**
  7175. * Checks if the object or part of the object is in the frustum
  7176. * @param frustumPlanes Camera near/planes
  7177. * @returns true if the object is in frustum otherwise false
  7178. */
  7179. isInFrustum(frustumPlanes: Plane[]): boolean;
  7180. /**
  7181. * Checks if a cullable object (mesh...) is in the camera frustum
  7182. * Unlike isInFrustum this cheks the full bounding box
  7183. * @param frustumPlanes Camera near/planes
  7184. * @returns true if the object is in frustum otherwise false
  7185. */
  7186. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7187. }
  7188. /**
  7189. * Info for a bounding data of a mesh
  7190. */
  7191. export class BoundingInfo implements ICullable {
  7192. /**
  7193. * Bounding box for the mesh
  7194. */
  7195. readonly boundingBox: BoundingBox;
  7196. /**
  7197. * Bounding sphere for the mesh
  7198. */
  7199. readonly boundingSphere: BoundingSphere;
  7200. private _isLocked;
  7201. private static readonly TmpVector3;
  7202. /**
  7203. * Constructs bounding info
  7204. * @param minimum min vector of the bounding box/sphere
  7205. * @param maximum max vector of the bounding box/sphere
  7206. * @param worldMatrix defines the new world matrix
  7207. */
  7208. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7209. /**
  7210. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7211. * @param min defines the new minimum vector (in local space)
  7212. * @param max defines the new maximum vector (in local space)
  7213. * @param worldMatrix defines the new world matrix
  7214. */
  7215. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7216. /**
  7217. * min vector of the bounding box/sphere
  7218. */
  7219. readonly minimum: Vector3;
  7220. /**
  7221. * max vector of the bounding box/sphere
  7222. */
  7223. readonly maximum: Vector3;
  7224. /**
  7225. * If the info is locked and won't be updated to avoid perf overhead
  7226. */
  7227. isLocked: boolean;
  7228. /**
  7229. * Updates the bounding sphere and box
  7230. * @param world world matrix to be used to update
  7231. */
  7232. update(world: DeepImmutable<Matrix>): void;
  7233. /**
  7234. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7235. * @param center New center of the bounding info
  7236. * @param extend New extend of the bounding info
  7237. * @returns the current bounding info
  7238. */
  7239. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7240. /**
  7241. * Scale the current bounding info by applying a scale factor
  7242. * @param factor defines the scale factor to apply
  7243. * @returns the current bounding info
  7244. */
  7245. scale(factor: number): BoundingInfo;
  7246. /**
  7247. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7248. * @param frustumPlanes defines the frustum to test
  7249. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7250. * @returns true if the bounding info is in the frustum planes
  7251. */
  7252. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7253. /**
  7254. * Gets the world distance between the min and max points of the bounding box
  7255. */
  7256. readonly diagonalLength: number;
  7257. /**
  7258. * Checks if a cullable object (mesh...) is in the camera frustum
  7259. * Unlike isInFrustum this cheks the full bounding box
  7260. * @param frustumPlanes Camera near/planes
  7261. * @returns true if the object is in frustum otherwise false
  7262. */
  7263. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7264. /** @hidden */
  7265. _checkCollision(collider: Collider): boolean;
  7266. /**
  7267. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7268. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7269. * @param point the point to check intersection with
  7270. * @returns if the point intersects
  7271. */
  7272. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7273. /**
  7274. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7275. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7276. * @param boundingInfo the bounding info to check intersection with
  7277. * @param precise if the intersection should be done using OBB
  7278. * @returns if the bounding info intersects
  7279. */
  7280. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7281. }
  7282. }
  7283. declare module "babylonjs/Misc/smartArray" {
  7284. /**
  7285. * Defines an array and its length.
  7286. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7287. */
  7288. export interface ISmartArrayLike<T> {
  7289. /**
  7290. * The data of the array.
  7291. */
  7292. data: Array<T>;
  7293. /**
  7294. * The active length of the array.
  7295. */
  7296. length: number;
  7297. }
  7298. /**
  7299. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7300. */
  7301. export class SmartArray<T> implements ISmartArrayLike<T> {
  7302. /**
  7303. * The full set of data from the array.
  7304. */
  7305. data: Array<T>;
  7306. /**
  7307. * The active length of the array.
  7308. */
  7309. length: number;
  7310. protected _id: number;
  7311. /**
  7312. * Instantiates a Smart Array.
  7313. * @param capacity defines the default capacity of the array.
  7314. */
  7315. constructor(capacity: number);
  7316. /**
  7317. * Pushes a value at the end of the active data.
  7318. * @param value defines the object to push in the array.
  7319. */
  7320. push(value: T): void;
  7321. /**
  7322. * Iterates over the active data and apply the lambda to them.
  7323. * @param func defines the action to apply on each value.
  7324. */
  7325. forEach(func: (content: T) => void): void;
  7326. /**
  7327. * Sorts the full sets of data.
  7328. * @param compareFn defines the comparison function to apply.
  7329. */
  7330. sort(compareFn: (a: T, b: T) => number): void;
  7331. /**
  7332. * Resets the active data to an empty array.
  7333. */
  7334. reset(): void;
  7335. /**
  7336. * Releases all the data from the array as well as the array.
  7337. */
  7338. dispose(): void;
  7339. /**
  7340. * Concats the active data with a given array.
  7341. * @param array defines the data to concatenate with.
  7342. */
  7343. concat(array: any): void;
  7344. /**
  7345. * Returns the position of a value in the active data.
  7346. * @param value defines the value to find the index for
  7347. * @returns the index if found in the active data otherwise -1
  7348. */
  7349. indexOf(value: T): number;
  7350. /**
  7351. * Returns whether an element is part of the active data.
  7352. * @param value defines the value to look for
  7353. * @returns true if found in the active data otherwise false
  7354. */
  7355. contains(value: T): boolean;
  7356. private static _GlobalId;
  7357. }
  7358. /**
  7359. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7360. * The data in this array can only be present once
  7361. */
  7362. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7363. private _duplicateId;
  7364. /**
  7365. * Pushes a value at the end of the active data.
  7366. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7367. * @param value defines the object to push in the array.
  7368. */
  7369. push(value: T): void;
  7370. /**
  7371. * Pushes a value at the end of the active data.
  7372. * If the data is already present, it won t be added again
  7373. * @param value defines the object to push in the array.
  7374. * @returns true if added false if it was already present
  7375. */
  7376. pushNoDuplicate(value: T): boolean;
  7377. /**
  7378. * Resets the active data to an empty array.
  7379. */
  7380. reset(): void;
  7381. /**
  7382. * Concats the active data with a given array.
  7383. * This ensures no dupplicate will be present in the result.
  7384. * @param array defines the data to concatenate with.
  7385. */
  7386. concatWithNoDuplicate(array: any): void;
  7387. }
  7388. }
  7389. declare module "babylonjs/Materials/multiMaterial" {
  7390. import { Nullable } from "babylonjs/types";
  7391. import { Scene } from "babylonjs/scene";
  7392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7393. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7395. import { Material } from "babylonjs/Materials/material";
  7396. /**
  7397. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7398. * separate meshes. This can be use to improve performances.
  7399. * @see http://doc.babylonjs.com/how_to/multi_materials
  7400. */
  7401. export class MultiMaterial extends Material {
  7402. private _subMaterials;
  7403. /**
  7404. * Gets or Sets the list of Materials used within the multi material.
  7405. * They need to be ordered according to the submeshes order in the associated mesh
  7406. */
  7407. subMaterials: Nullable<Material>[];
  7408. /**
  7409. * Function used to align with Node.getChildren()
  7410. * @returns the list of Materials used within the multi material
  7411. */
  7412. getChildren(): Nullable<Material>[];
  7413. /**
  7414. * Instantiates a new Multi Material
  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. * @param name Define the name in the scene
  7419. * @param scene Define the scene the material belongs to
  7420. */
  7421. constructor(name: string, scene: Scene);
  7422. private _hookArray;
  7423. /**
  7424. * Get one of the submaterial by its index in the submaterials array
  7425. * @param index The index to look the sub material at
  7426. * @returns The Material if the index has been defined
  7427. */
  7428. getSubMaterial(index: number): Nullable<Material>;
  7429. /**
  7430. * Get the list of active textures for the whole sub materials list.
  7431. * @returns All the textures that will be used during the rendering
  7432. */
  7433. getActiveTextures(): BaseTexture[];
  7434. /**
  7435. * Gets the current class name of the material e.g. "MultiMaterial"
  7436. * Mainly use in serialization.
  7437. * @returns the class name
  7438. */
  7439. getClassName(): string;
  7440. /**
  7441. * Checks if the material is ready to render the requested sub mesh
  7442. * @param mesh Define the mesh the submesh belongs to
  7443. * @param subMesh Define the sub mesh to look readyness for
  7444. * @param useInstances Define whether or not the material is used with instances
  7445. * @returns true if ready, otherwise false
  7446. */
  7447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7448. /**
  7449. * Clones the current material and its related sub materials
  7450. * @param name Define the name of the newly cloned material
  7451. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7452. * @returns the cloned material
  7453. */
  7454. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7455. /**
  7456. * Serializes the materials into a JSON representation.
  7457. * @returns the JSON representation
  7458. */
  7459. serialize(): any;
  7460. /**
  7461. * Dispose the material and release its associated resources
  7462. * @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)
  7463. * @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)
  7464. * @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)
  7465. */
  7466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7467. /**
  7468. * Creates a MultiMaterial from parsed MultiMaterial data.
  7469. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7470. * @param scene defines the hosting scene
  7471. * @returns a new MultiMaterial
  7472. */
  7473. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7474. }
  7475. }
  7476. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7477. /**
  7478. * Class used to represent data loading progression
  7479. */
  7480. export class SceneLoaderFlags {
  7481. private static _ForceFullSceneLoadingForIncremental;
  7482. private static _ShowLoadingScreen;
  7483. private static _CleanBoneMatrixWeights;
  7484. private static _loggingLevel;
  7485. /**
  7486. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7487. */
  7488. static ForceFullSceneLoadingForIncremental: boolean;
  7489. /**
  7490. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7491. */
  7492. static ShowLoadingScreen: boolean;
  7493. /**
  7494. * Defines the current logging level (while loading the scene)
  7495. * @ignorenaming
  7496. */
  7497. static loggingLevel: number;
  7498. /**
  7499. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7500. */
  7501. static CleanBoneMatrixWeights: boolean;
  7502. }
  7503. }
  7504. declare module "babylonjs/Meshes/transformNode" {
  7505. import { DeepImmutable } from "babylonjs/types";
  7506. import { Observable } from "babylonjs/Misc/observable";
  7507. import { Nullable } from "babylonjs/types";
  7508. import { Camera } from "babylonjs/Cameras/camera";
  7509. import { Scene } from "babylonjs/scene";
  7510. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7511. import { Node } from "babylonjs/node";
  7512. import { Bone } from "babylonjs/Bones/bone";
  7513. /**
  7514. * 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.
  7515. * @see https://doc.babylonjs.com/how_to/transformnode
  7516. */
  7517. export class TransformNode extends Node {
  7518. /**
  7519. * Object will not rotate to face the camera
  7520. */
  7521. static BILLBOARDMODE_NONE: number;
  7522. /**
  7523. * Object will rotate to face the camera but only on the x axis
  7524. */
  7525. static BILLBOARDMODE_X: number;
  7526. /**
  7527. * Object will rotate to face the camera but only on the y axis
  7528. */
  7529. static BILLBOARDMODE_Y: number;
  7530. /**
  7531. * Object will rotate to face the camera but only on the z axis
  7532. */
  7533. static BILLBOARDMODE_Z: number;
  7534. /**
  7535. * Object will rotate to face the camera
  7536. */
  7537. static BILLBOARDMODE_ALL: number;
  7538. private _forward;
  7539. private _forwardInverted;
  7540. private _up;
  7541. private _right;
  7542. private _rightInverted;
  7543. private _position;
  7544. private _rotation;
  7545. private _rotationQuaternion;
  7546. protected _scaling: Vector3;
  7547. protected _isDirty: boolean;
  7548. private _transformToBoneReferal;
  7549. /**
  7550. * Set the billboard mode. Default is 0.
  7551. *
  7552. * | Value | Type | Description |
  7553. * | --- | --- | --- |
  7554. * | 0 | BILLBOARDMODE_NONE | |
  7555. * | 1 | BILLBOARDMODE_X | |
  7556. * | 2 | BILLBOARDMODE_Y | |
  7557. * | 4 | BILLBOARDMODE_Z | |
  7558. * | 7 | BILLBOARDMODE_ALL | |
  7559. *
  7560. */
  7561. billboardMode: number;
  7562. /**
  7563. * 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
  7564. */
  7565. scalingDeterminant: number;
  7566. /**
  7567. * Sets the distance of the object to max, often used by skybox
  7568. */
  7569. infiniteDistance: boolean;
  7570. /**
  7571. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7572. * By default the system will update normals to compensate
  7573. */
  7574. ignoreNonUniformScaling: boolean;
  7575. /** @hidden */
  7576. _poseMatrix: Matrix;
  7577. /** @hidden */
  7578. _localMatrix: Matrix;
  7579. private _absolutePosition;
  7580. private _pivotMatrix;
  7581. private _pivotMatrixInverse;
  7582. protected _postMultiplyPivotMatrix: boolean;
  7583. private _tempMatrix;
  7584. private _tempMatrix2;
  7585. protected _isWorldMatrixFrozen: boolean;
  7586. /** @hidden */
  7587. _indexInSceneTransformNodesArray: number;
  7588. /**
  7589. * An event triggered after the world matrix is updated
  7590. */
  7591. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7592. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7593. /**
  7594. * Gets a string identifying the name of the class
  7595. * @returns "TransformNode" string
  7596. */
  7597. getClassName(): string;
  7598. /**
  7599. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7600. */
  7601. position: Vector3;
  7602. /**
  7603. * 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)).
  7604. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7605. */
  7606. rotation: Vector3;
  7607. /**
  7608. * 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)).
  7609. */
  7610. scaling: Vector3;
  7611. /**
  7612. * 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).
  7613. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7614. */
  7615. rotationQuaternion: Nullable<Quaternion>;
  7616. /**
  7617. * The forward direction of that transform in world space.
  7618. */
  7619. readonly forward: Vector3;
  7620. /**
  7621. * The up direction of that transform in world space.
  7622. */
  7623. readonly up: Vector3;
  7624. /**
  7625. * The right direction of that transform in world space.
  7626. */
  7627. readonly right: Vector3;
  7628. /**
  7629. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7630. * @param matrix the matrix to copy the pose from
  7631. * @returns this TransformNode.
  7632. */
  7633. updatePoseMatrix(matrix: Matrix): TransformNode;
  7634. /**
  7635. * Returns the mesh Pose matrix.
  7636. * @returns the pose matrix
  7637. */
  7638. getPoseMatrix(): Matrix;
  7639. /** @hidden */
  7640. _isSynchronized(): boolean;
  7641. /** @hidden */
  7642. _initCache(): void;
  7643. /**
  7644. * Flag the transform node as dirty (Forcing it to update everything)
  7645. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7646. * @returns this transform node
  7647. */
  7648. markAsDirty(property: string): TransformNode;
  7649. /**
  7650. * Returns the current mesh absolute position.
  7651. * Returns a Vector3.
  7652. */
  7653. readonly absolutePosition: Vector3;
  7654. /**
  7655. * Sets a new matrix to apply before all other transformation
  7656. * @param matrix defines the transform matrix
  7657. * @returns the current TransformNode
  7658. */
  7659. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7660. /**
  7661. * Sets a new pivot matrix to the current node
  7662. * @param matrix defines the new pivot matrix to use
  7663. * @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
  7664. * @returns the current TransformNode
  7665. */
  7666. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7667. /**
  7668. * Returns the mesh pivot matrix.
  7669. * Default : Identity.
  7670. * @returns the matrix
  7671. */
  7672. getPivotMatrix(): Matrix;
  7673. /**
  7674. * Prevents the World matrix to be computed any longer.
  7675. * @returns the TransformNode.
  7676. */
  7677. freezeWorldMatrix(): TransformNode;
  7678. /**
  7679. * Allows back the World matrix computation.
  7680. * @returns the TransformNode.
  7681. */
  7682. unfreezeWorldMatrix(): this;
  7683. /**
  7684. * True if the World matrix has been frozen.
  7685. */
  7686. readonly isWorldMatrixFrozen: boolean;
  7687. /**
  7688. * Retuns the mesh absolute position in the World.
  7689. * @returns a Vector3.
  7690. */
  7691. getAbsolutePosition(): Vector3;
  7692. /**
  7693. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7694. * @param absolutePosition the absolute position to set
  7695. * @returns the TransformNode.
  7696. */
  7697. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7698. /**
  7699. * Sets the mesh position in its local space.
  7700. * @param vector3 the position to set in localspace
  7701. * @returns the TransformNode.
  7702. */
  7703. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7704. /**
  7705. * Returns the mesh position in the local space from the current World matrix values.
  7706. * @returns a new Vector3.
  7707. */
  7708. getPositionExpressedInLocalSpace(): Vector3;
  7709. /**
  7710. * Translates the mesh along the passed Vector3 in its local space.
  7711. * @param vector3 the distance to translate in localspace
  7712. * @returns the TransformNode.
  7713. */
  7714. locallyTranslate(vector3: Vector3): TransformNode;
  7715. private static _lookAtVectorCache;
  7716. /**
  7717. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7718. * @param targetPoint the position (must be in same space as current mesh) to look at
  7719. * @param yawCor optional yaw (y-axis) correction in radians
  7720. * @param pitchCor optional pitch (x-axis) correction in radians
  7721. * @param rollCor optional roll (z-axis) correction in radians
  7722. * @param space the choosen space of the target
  7723. * @returns the TransformNode.
  7724. */
  7725. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7726. /**
  7727. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7728. * This Vector3 is expressed in the World space.
  7729. * @param localAxis axis to rotate
  7730. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7731. */
  7732. getDirection(localAxis: Vector3): Vector3;
  7733. /**
  7734. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7735. * localAxis is expressed in the mesh local space.
  7736. * result is computed in the Wordl space from the mesh World matrix.
  7737. * @param localAxis axis to rotate
  7738. * @param result the resulting transformnode
  7739. * @returns this TransformNode.
  7740. */
  7741. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7742. /**
  7743. * Sets this transform node rotation to the given local axis.
  7744. * @param localAxis the axis in local space
  7745. * @param yawCor optional yaw (y-axis) correction in radians
  7746. * @param pitchCor optional pitch (x-axis) correction in radians
  7747. * @param rollCor optional roll (z-axis) correction in radians
  7748. * @returns this TransformNode
  7749. */
  7750. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7751. /**
  7752. * Sets a new pivot point to the current node
  7753. * @param point defines the new pivot point to use
  7754. * @param space defines if the point is in world or local space (local by default)
  7755. * @returns the current TransformNode
  7756. */
  7757. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7758. /**
  7759. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7760. * @returns the pivot point
  7761. */
  7762. getPivotPoint(): Vector3;
  7763. /**
  7764. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7765. * @param result the vector3 to store the result
  7766. * @returns this TransformNode.
  7767. */
  7768. getPivotPointToRef(result: Vector3): TransformNode;
  7769. /**
  7770. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7771. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7772. */
  7773. getAbsolutePivotPoint(): Vector3;
  7774. /**
  7775. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7776. * @param result vector3 to store the result
  7777. * @returns this TransformNode.
  7778. */
  7779. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7780. /**
  7781. * Defines the passed node as the parent of the current node.
  7782. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7783. * @param node the node ot set as the parent
  7784. * @returns this TransformNode.
  7785. */
  7786. setParent(node: Nullable<Node>): TransformNode;
  7787. private _nonUniformScaling;
  7788. /**
  7789. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7790. */
  7791. readonly nonUniformScaling: boolean;
  7792. /** @hidden */
  7793. _updateNonUniformScalingState(value: boolean): boolean;
  7794. /**
  7795. * Attach the current TransformNode to another TransformNode associated with a bone
  7796. * @param bone Bone affecting the TransformNode
  7797. * @param affectedTransformNode TransformNode associated with the bone
  7798. * @returns this object
  7799. */
  7800. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7801. /**
  7802. * Detach the transform node if its associated with a bone
  7803. * @returns this object
  7804. */
  7805. detachFromBone(): TransformNode;
  7806. private static _rotationAxisCache;
  7807. /**
  7808. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7809. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7810. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7811. * The passed axis is also normalized.
  7812. * @param axis the axis to rotate around
  7813. * @param amount the amount to rotate in radians
  7814. * @param space Space to rotate in (Default: local)
  7815. * @returns the TransformNode.
  7816. */
  7817. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7818. /**
  7819. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7820. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7821. * The passed axis is also normalized. .
  7822. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7823. * @param point the point to rotate around
  7824. * @param axis the axis to rotate around
  7825. * @param amount the amount to rotate in radians
  7826. * @returns the TransformNode
  7827. */
  7828. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7829. /**
  7830. * Translates the mesh along the axis vector for the passed distance in the given space.
  7831. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7832. * @param axis the axis to translate in
  7833. * @param distance the distance to translate
  7834. * @param space Space to rotate in (Default: local)
  7835. * @returns the TransformNode.
  7836. */
  7837. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7838. /**
  7839. * Adds a rotation step to the mesh current rotation.
  7840. * x, y, z are Euler angles expressed in radians.
  7841. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7842. * This means this rotation is made in the mesh local space only.
  7843. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7844. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7845. * ```javascript
  7846. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7847. * ```
  7848. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7849. * 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.
  7850. * @param x Rotation to add
  7851. * @param y Rotation to add
  7852. * @param z Rotation to add
  7853. * @returns the TransformNode.
  7854. */
  7855. addRotation(x: number, y: number, z: number): TransformNode;
  7856. /**
  7857. * Computes the world matrix of the node
  7858. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7859. * @returns the world matrix
  7860. */
  7861. computeWorldMatrix(force?: boolean): Matrix;
  7862. protected _afterComputeWorldMatrix(): void;
  7863. /**
  7864. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7865. * @param func callback function to add
  7866. *
  7867. * @returns the TransformNode.
  7868. */
  7869. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7870. /**
  7871. * Removes a registered callback function.
  7872. * @param func callback function to remove
  7873. * @returns the TransformNode.
  7874. */
  7875. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7876. /**
  7877. * Gets the position of the current mesh in camera space
  7878. * @param camera defines the camera to use
  7879. * @returns a position
  7880. */
  7881. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7882. /**
  7883. * Returns the distance from the mesh to the active camera
  7884. * @param camera defines the camera to use
  7885. * @returns the distance
  7886. */
  7887. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7888. /**
  7889. * Clone the current transform node
  7890. * @param name Name of the new clone
  7891. * @param newParent New parent for the clone
  7892. * @param doNotCloneChildren Do not clone children hierarchy
  7893. * @returns the new transform node
  7894. */
  7895. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7896. /**
  7897. * Serializes the objects information.
  7898. * @param currentSerializationObject defines the object to serialize in
  7899. * @returns the serialized object
  7900. */
  7901. serialize(currentSerializationObject?: any): any;
  7902. /**
  7903. * Returns a new TransformNode object parsed from the source provided.
  7904. * @param parsedTransformNode is the source.
  7905. * @param scene the scne the object belongs to
  7906. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7907. * @returns a new TransformNode object parsed from the source provided.
  7908. */
  7909. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7910. /**
  7911. * Get all child-transformNodes of this node
  7912. * @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
  7913. * @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
  7914. * @returns an array of TransformNode
  7915. */
  7916. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7917. /**
  7918. * Releases resources associated with this transform node.
  7919. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7920. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7921. */
  7922. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7923. }
  7924. }
  7925. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7926. /**
  7927. * Class used to override all child animations of a given target
  7928. */
  7929. export class AnimationPropertiesOverride {
  7930. /**
  7931. * Gets or sets a value indicating if animation blending must be used
  7932. */
  7933. enableBlending: boolean;
  7934. /**
  7935. * Gets or sets the blending speed to use when enableBlending is true
  7936. */
  7937. blendingSpeed: number;
  7938. /**
  7939. * Gets or sets the default loop mode to use
  7940. */
  7941. loopMode: number;
  7942. }
  7943. }
  7944. declare module "babylonjs/Bones/bone" {
  7945. import { Skeleton } from "babylonjs/Bones/skeleton";
  7946. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7947. import { Nullable } from "babylonjs/types";
  7948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7950. import { Node } from "babylonjs/node";
  7951. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7952. /**
  7953. * Class used to store bone information
  7954. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7955. */
  7956. export class Bone extends Node {
  7957. /**
  7958. * defines the bone name
  7959. */
  7960. name: string;
  7961. private static _tmpVecs;
  7962. private static _tmpQuat;
  7963. private static _tmpMats;
  7964. /**
  7965. * Gets the list of child bones
  7966. */
  7967. children: Bone[];
  7968. /** Gets the animations associated with this bone */
  7969. animations: import("babylonjs/Animations/animation").Animation[];
  7970. /**
  7971. * Gets or sets bone length
  7972. */
  7973. length: number;
  7974. /**
  7975. * @hidden Internal only
  7976. * Set this value to map this bone to a different index in the transform matrices
  7977. * Set this value to -1 to exclude the bone from the transform matrices
  7978. */
  7979. _index: Nullable<number>;
  7980. private _skeleton;
  7981. private _localMatrix;
  7982. private _restPose;
  7983. private _baseMatrix;
  7984. private _absoluteTransform;
  7985. private _invertedAbsoluteTransform;
  7986. private _parent;
  7987. private _scalingDeterminant;
  7988. private _worldTransform;
  7989. private _localScaling;
  7990. private _localRotation;
  7991. private _localPosition;
  7992. private _needToDecompose;
  7993. private _needToCompose;
  7994. /** @hidden */
  7995. _linkedTransformNode: Nullable<TransformNode>;
  7996. /** @hidden */
  7997. /** @hidden */
  7998. _matrix: Matrix;
  7999. /**
  8000. * Create a new bone
  8001. * @param name defines the bone name
  8002. * @param skeleton defines the parent skeleton
  8003. * @param parentBone defines the parent (can be null if the bone is the root)
  8004. * @param localMatrix defines the local matrix
  8005. * @param restPose defines the rest pose matrix
  8006. * @param baseMatrix defines the base matrix
  8007. * @param index defines index of the bone in the hiearchy
  8008. */
  8009. constructor(
  8010. /**
  8011. * defines the bone name
  8012. */
  8013. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8014. /**
  8015. * Gets the current object class name.
  8016. * @return the class name
  8017. */
  8018. getClassName(): string;
  8019. /**
  8020. * Gets the parent skeleton
  8021. * @returns a skeleton
  8022. */
  8023. getSkeleton(): Skeleton;
  8024. /**
  8025. * Gets parent bone
  8026. * @returns a bone or null if the bone is the root of the bone hierarchy
  8027. */
  8028. getParent(): Nullable<Bone>;
  8029. /**
  8030. * Returns an array containing the root bones
  8031. * @returns an array containing the root bones
  8032. */
  8033. getChildren(): Array<Bone>;
  8034. /**
  8035. * Sets the parent bone
  8036. * @param parent defines the parent (can be null if the bone is the root)
  8037. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8038. */
  8039. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8040. /**
  8041. * Gets the local matrix
  8042. * @returns a matrix
  8043. */
  8044. getLocalMatrix(): Matrix;
  8045. /**
  8046. * Gets the base matrix (initial matrix which remains unchanged)
  8047. * @returns a matrix
  8048. */
  8049. getBaseMatrix(): Matrix;
  8050. /**
  8051. * Gets the rest pose matrix
  8052. * @returns a matrix
  8053. */
  8054. getRestPose(): Matrix;
  8055. /**
  8056. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8057. */
  8058. getWorldMatrix(): Matrix;
  8059. /**
  8060. * Sets the local matrix to rest pose matrix
  8061. */
  8062. returnToRest(): void;
  8063. /**
  8064. * Gets the inverse of the absolute transform matrix.
  8065. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8066. * @returns a matrix
  8067. */
  8068. getInvertedAbsoluteTransform(): Matrix;
  8069. /**
  8070. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8071. * @returns a matrix
  8072. */
  8073. getAbsoluteTransform(): Matrix;
  8074. /**
  8075. * Links with the given transform node.
  8076. * The local matrix of this bone is copied from the transform node every frame.
  8077. * @param transformNode defines the transform node to link to
  8078. */
  8079. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8080. /** Gets or sets current position (in local space) */
  8081. position: Vector3;
  8082. /** Gets or sets current rotation (in local space) */
  8083. rotation: Vector3;
  8084. /** Gets or sets current rotation quaternion (in local space) */
  8085. rotationQuaternion: Quaternion;
  8086. /** Gets or sets current scaling (in local space) */
  8087. scaling: Vector3;
  8088. /**
  8089. * Gets the animation properties override
  8090. */
  8091. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8092. private _decompose;
  8093. private _compose;
  8094. /**
  8095. * Update the base and local matrices
  8096. * @param matrix defines the new base or local matrix
  8097. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8098. * @param updateLocalMatrix defines if the local matrix should be updated
  8099. */
  8100. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8101. /** @hidden */
  8102. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8103. /**
  8104. * Flag the bone as dirty (Forcing it to update everything)
  8105. */
  8106. markAsDirty(): void;
  8107. private _markAsDirtyAndCompose;
  8108. private _markAsDirtyAndDecompose;
  8109. /**
  8110. * Translate the bone in local or world space
  8111. * @param vec The amount to translate the bone
  8112. * @param space The space that the translation is in
  8113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8114. */
  8115. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8116. /**
  8117. * Set the postion of the bone in local or world space
  8118. * @param position The position to set the bone
  8119. * @param space The space that the position is in
  8120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8121. */
  8122. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8123. /**
  8124. * Set the absolute position of the bone (world space)
  8125. * @param position The position to set the bone
  8126. * @param mesh The mesh that this bone is attached to
  8127. */
  8128. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8129. /**
  8130. * Scale the bone on the x, y and z axes (in local space)
  8131. * @param x The amount to scale the bone on the x axis
  8132. * @param y The amount to scale the bone on the y axis
  8133. * @param z The amount to scale the bone on the z axis
  8134. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8135. */
  8136. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8137. /**
  8138. * Set the bone scaling in local space
  8139. * @param scale defines the scaling vector
  8140. */
  8141. setScale(scale: Vector3): void;
  8142. /**
  8143. * Gets the current scaling in local space
  8144. * @returns the current scaling vector
  8145. */
  8146. getScale(): Vector3;
  8147. /**
  8148. * Gets the current scaling in local space and stores it in a target vector
  8149. * @param result defines the target vector
  8150. */
  8151. getScaleToRef(result: Vector3): void;
  8152. /**
  8153. * Set the yaw, pitch, and roll of the bone in local or world space
  8154. * @param yaw The rotation of the bone on the y axis
  8155. * @param pitch The rotation of the bone on the x axis
  8156. * @param roll The rotation of the bone on the z axis
  8157. * @param space The space that the axes of rotation are in
  8158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8159. */
  8160. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8161. /**
  8162. * Add a rotation to the bone on an axis in local or world space
  8163. * @param axis The axis to rotate the bone on
  8164. * @param amount The amount to rotate the bone
  8165. * @param space The space that the axis is in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. */
  8168. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8169. /**
  8170. * Set the rotation of the bone to a particular axis angle in local or world space
  8171. * @param axis The axis to rotate the bone on
  8172. * @param angle The angle that the bone should be rotated to
  8173. * @param space The space that the axis is in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. */
  8176. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Set the euler rotation of the bone in local of world space
  8179. * @param rotation The euler rotation that the bone should be set to
  8180. * @param space The space that the rotation is in
  8181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8182. */
  8183. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8184. /**
  8185. * Set the quaternion rotation of the bone in local of world space
  8186. * @param quat The quaternion rotation that the bone should be set to
  8187. * @param space The space that the rotation is in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. */
  8190. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8191. /**
  8192. * Set the rotation matrix of the bone in local of world space
  8193. * @param rotMat The rotation matrix that the bone should be set to
  8194. * @param space The space that the rotation is in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. */
  8197. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8198. private _rotateWithMatrix;
  8199. private _getNegativeRotationToRef;
  8200. /**
  8201. * Get the position of the bone in local or world space
  8202. * @param space The space that the returned position is in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The position of the bone
  8205. */
  8206. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8207. /**
  8208. * Copy the position of the bone to a vector3 in local or world space
  8209. * @param space The space that the returned position is in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The vector3 to copy the position to
  8212. */
  8213. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8214. /**
  8215. * Get the absolute position of the bone (world space)
  8216. * @param mesh The mesh that this bone is attached to
  8217. * @returns The absolute position of the bone
  8218. */
  8219. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8220. /**
  8221. * Copy the absolute position of the bone (world space) to the result param
  8222. * @param mesh The mesh that this bone is attached to
  8223. * @param result The vector3 to copy the absolute position to
  8224. */
  8225. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8226. /**
  8227. * Compute the absolute transforms of this bone and its children
  8228. */
  8229. computeAbsoluteTransforms(): void;
  8230. /**
  8231. * Get the world direction from an axis that is in the local space of the bone
  8232. * @param localAxis The local direction that is used to compute the world direction
  8233. * @param mesh The mesh that this bone is attached to
  8234. * @returns The world direction
  8235. */
  8236. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8237. /**
  8238. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8239. * @param localAxis The local direction that is used to compute the world direction
  8240. * @param mesh The mesh that this bone is attached to
  8241. * @param result The vector3 that the world direction will be copied to
  8242. */
  8243. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8244. /**
  8245. * Get the euler rotation of the bone in local or world space
  8246. * @param space The space that the rotation should be in
  8247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8248. * @returns The euler rotation
  8249. */
  8250. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8251. /**
  8252. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8253. * @param space The space that the rotation should be in
  8254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8255. * @param result The vector3 that the rotation should be copied to
  8256. */
  8257. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8258. /**
  8259. * Get the quaternion rotation of the bone in either local or world space
  8260. * @param space The space that the rotation should be in
  8261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8262. * @returns The quaternion rotation
  8263. */
  8264. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8265. /**
  8266. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8267. * @param space The space that the rotation should be in
  8268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8269. * @param result The quaternion that the rotation should be copied to
  8270. */
  8271. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8272. /**
  8273. * Get the rotation matrix of the bone in local or world space
  8274. * @param space The space that the rotation should be in
  8275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8276. * @returns The rotation matrix
  8277. */
  8278. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8279. /**
  8280. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8281. * @param space The space that the rotation should be in
  8282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8283. * @param result The quaternion that the rotation should be copied to
  8284. */
  8285. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8286. /**
  8287. * Get the world position of a point that is in the local space of the bone
  8288. * @param position The local position
  8289. * @param mesh The mesh that this bone is attached to
  8290. * @returns The world position
  8291. */
  8292. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8293. /**
  8294. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8295. * @param position The local position
  8296. * @param mesh The mesh that this bone is attached to
  8297. * @param result The vector3 that the world position should be copied to
  8298. */
  8299. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8300. /**
  8301. * Get the local position of a point that is in world space
  8302. * @param position The world position
  8303. * @param mesh The mesh that this bone is attached to
  8304. * @returns The local position
  8305. */
  8306. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8307. /**
  8308. * Get the local position of a point that is in world space and copy it to the result param
  8309. * @param position The world position
  8310. * @param mesh The mesh that this bone is attached to
  8311. * @param result The vector3 that the local position should be copied to
  8312. */
  8313. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8314. }
  8315. }
  8316. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8317. import { Nullable } from "babylonjs/types";
  8318. import { Scene } from "babylonjs/scene";
  8319. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8321. /**
  8322. * Class for creating a cube texture
  8323. */
  8324. export class CubeTexture extends BaseTexture {
  8325. private _delayedOnLoad;
  8326. /**
  8327. * The url of the texture
  8328. */
  8329. url: string;
  8330. /**
  8331. * Gets or sets the center of the bounding box associated with the cube texture.
  8332. * It must define where the camera used to render the texture was set
  8333. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8334. */
  8335. boundingBoxPosition: Vector3;
  8336. private _boundingBoxSize;
  8337. /**
  8338. * Gets or sets the size of the bounding box associated with the cube texture
  8339. * When defined, the cubemap will switch to local mode
  8340. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8341. * @example https://www.babylonjs-playground.com/#RNASML
  8342. */
  8343. /**
  8344. * Returns the bounding box size
  8345. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8346. */
  8347. boundingBoxSize: Vector3;
  8348. protected _rotationY: number;
  8349. /**
  8350. * Sets texture matrix rotation angle around Y axis in radians.
  8351. */
  8352. /**
  8353. * Gets texture matrix rotation angle around Y axis radians.
  8354. */
  8355. rotationY: number;
  8356. /**
  8357. * Are mip maps generated for this texture or not.
  8358. */
  8359. readonly noMipmap: boolean;
  8360. private _noMipmap;
  8361. private _files;
  8362. private _extensions;
  8363. private _textureMatrix;
  8364. private _format;
  8365. private _createPolynomials;
  8366. /** @hidden */
  8367. _prefiltered: boolean;
  8368. /**
  8369. * Creates a cube texture from an array of image urls
  8370. * @param files defines an array of image urls
  8371. * @param scene defines the hosting scene
  8372. * @param noMipmap specifies if mip maps are not used
  8373. * @returns a cube texture
  8374. */
  8375. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8376. /**
  8377. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8378. * @param url defines the url of the prefiltered texture
  8379. * @param scene defines the scene the texture is attached to
  8380. * @param forcedExtension defines the extension of the file if different from the url
  8381. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8382. * @return the prefiltered texture
  8383. */
  8384. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8385. /**
  8386. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8387. * as prefiltered data.
  8388. * @param rootUrl defines the url of the texture or the root name of the six images
  8389. * @param scene defines the scene the texture is attached to
  8390. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8391. * @param noMipmap defines if mipmaps should be created or not
  8392. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8393. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8394. * @param onError defines a callback triggered in case of error during load
  8395. * @param format defines the internal format to use for the texture once loaded
  8396. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8397. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8398. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8399. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8400. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8401. * @return the cube texture
  8402. */
  8403. 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);
  8404. /**
  8405. * Get the current class name of the texture useful for serialization or dynamic coding.
  8406. * @returns "CubeTexture"
  8407. */
  8408. getClassName(): string;
  8409. /**
  8410. * Update the url (and optional buffer) of this texture if url was null during construction.
  8411. * @param url the url of the texture
  8412. * @param forcedExtension defines the extension to use
  8413. * @param onLoad callback called when the texture is loaded (defaults to null)
  8414. */
  8415. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8416. /**
  8417. * Delays loading of the cube texture
  8418. * @param forcedExtension defines the extension to use
  8419. */
  8420. delayLoad(forcedExtension?: string): void;
  8421. /**
  8422. * Returns the reflection texture matrix
  8423. * @returns the reflection texture matrix
  8424. */
  8425. getReflectionTextureMatrix(): Matrix;
  8426. /**
  8427. * Sets the reflection texture matrix
  8428. * @param value Reflection texture matrix
  8429. */
  8430. setReflectionTextureMatrix(value: Matrix): void;
  8431. /**
  8432. * Parses text to create a cube texture
  8433. * @param parsedTexture define the serialized text to read from
  8434. * @param scene defines the hosting scene
  8435. * @param rootUrl defines the root url of the cube texture
  8436. * @returns a cube texture
  8437. */
  8438. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8439. /**
  8440. * Makes a clone, or deep copy, of the cube texture
  8441. * @returns a new cube texture
  8442. */
  8443. clone(): CubeTexture;
  8444. }
  8445. }
  8446. declare module "babylonjs/Shaders/postprocess.vertex" {
  8447. /** @hidden */
  8448. export var postprocessVertexShader: {
  8449. name: string;
  8450. shader: string;
  8451. };
  8452. }
  8453. declare module "babylonjs/Cameras/targetCamera" {
  8454. import { Nullable } from "babylonjs/types";
  8455. import { Camera } from "babylonjs/Cameras/camera";
  8456. import { Scene } from "babylonjs/scene";
  8457. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8458. /**
  8459. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8460. * This is the base of the follow, arc rotate cameras and Free camera
  8461. * @see http://doc.babylonjs.com/features/cameras
  8462. */
  8463. export class TargetCamera extends Camera {
  8464. private static _RigCamTransformMatrix;
  8465. private static _TargetTransformMatrix;
  8466. private static _TargetFocalPoint;
  8467. /**
  8468. * Define the current direction the camera is moving to
  8469. */
  8470. cameraDirection: Vector3;
  8471. /**
  8472. * Define the current rotation the camera is rotating to
  8473. */
  8474. cameraRotation: Vector2;
  8475. /**
  8476. * When set, the up vector of the camera will be updated by the rotation of the camera
  8477. */
  8478. updateUpVectorFromRotation: boolean;
  8479. private _tmpQuaternion;
  8480. /**
  8481. * Define the current rotation of the camera
  8482. */
  8483. rotation: Vector3;
  8484. /**
  8485. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8486. */
  8487. rotationQuaternion: Quaternion;
  8488. /**
  8489. * Define the current speed of the camera
  8490. */
  8491. speed: number;
  8492. /**
  8493. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8494. * around all axis.
  8495. */
  8496. noRotationConstraint: boolean;
  8497. /**
  8498. * Define the current target of the camera as an object or a position.
  8499. */
  8500. lockedTarget: any;
  8501. /** @hidden */
  8502. _currentTarget: Vector3;
  8503. /** @hidden */
  8504. _initialFocalDistance: number;
  8505. /** @hidden */
  8506. _viewMatrix: Matrix;
  8507. /** @hidden */
  8508. _camMatrix: Matrix;
  8509. /** @hidden */
  8510. _cameraTransformMatrix: Matrix;
  8511. /** @hidden */
  8512. _cameraRotationMatrix: Matrix;
  8513. /** @hidden */
  8514. _referencePoint: Vector3;
  8515. /** @hidden */
  8516. _transformedReferencePoint: Vector3;
  8517. protected _globalCurrentTarget: Vector3;
  8518. protected _globalCurrentUpVector: Vector3;
  8519. /** @hidden */
  8520. _reset: () => void;
  8521. private _defaultUp;
  8522. /**
  8523. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8524. * This is the base of the follow, arc rotate cameras and Free camera
  8525. * @see http://doc.babylonjs.com/features/cameras
  8526. * @param name Defines the name of the camera in the scene
  8527. * @param position Defines the start position of the camera in the scene
  8528. * @param scene Defines the scene the camera belongs to
  8529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8530. */
  8531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8532. /**
  8533. * Gets the position in front of the camera at a given distance.
  8534. * @param distance The distance from the camera we want the position to be
  8535. * @returns the position
  8536. */
  8537. getFrontPosition(distance: number): Vector3;
  8538. /** @hidden */
  8539. _getLockedTargetPosition(): Nullable<Vector3>;
  8540. private _storedPosition;
  8541. private _storedRotation;
  8542. private _storedRotationQuaternion;
  8543. /**
  8544. * Store current camera state of the camera (fov, position, rotation, etc..)
  8545. * @returns the camera
  8546. */
  8547. storeState(): Camera;
  8548. /**
  8549. * Restored camera state. You must call storeState() first
  8550. * @returns whether it was successful or not
  8551. * @hidden
  8552. */
  8553. _restoreStateValues(): boolean;
  8554. /** @hidden */
  8555. _initCache(): void;
  8556. /** @hidden */
  8557. _updateCache(ignoreParentClass?: boolean): void;
  8558. /** @hidden */
  8559. _isSynchronizedViewMatrix(): boolean;
  8560. /** @hidden */
  8561. _computeLocalCameraSpeed(): number;
  8562. /**
  8563. * Defines the target the camera should look at.
  8564. * This will automatically adapt alpha beta and radius to fit within the new target.
  8565. * @param target Defines the new target as a Vector or a mesh
  8566. */
  8567. setTarget(target: Vector3): void;
  8568. /**
  8569. * Return the current target position of the camera. This value is expressed in local space.
  8570. * @returns the target position
  8571. */
  8572. getTarget(): Vector3;
  8573. /** @hidden */
  8574. _decideIfNeedsToMove(): boolean;
  8575. /** @hidden */
  8576. _updatePosition(): void;
  8577. /** @hidden */
  8578. _checkInputs(): void;
  8579. protected _updateCameraRotationMatrix(): void;
  8580. /**
  8581. * 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)
  8582. * @returns the current camera
  8583. */
  8584. private _rotateUpVectorWithCameraRotationMatrix;
  8585. private _cachedRotationZ;
  8586. private _cachedQuaternionRotationZ;
  8587. /** @hidden */
  8588. _getViewMatrix(): Matrix;
  8589. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8590. /**
  8591. * @hidden
  8592. */
  8593. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8594. /**
  8595. * @hidden
  8596. */
  8597. _updateRigCameras(): void;
  8598. private _getRigCamPositionAndTarget;
  8599. /**
  8600. * Gets the current object class name.
  8601. * @return the class name
  8602. */
  8603. getClassName(): string;
  8604. }
  8605. }
  8606. declare module "babylonjs/Cameras/cameraInputsManager" {
  8607. import { Nullable } from "babylonjs/types";
  8608. import { Camera } from "babylonjs/Cameras/camera";
  8609. /**
  8610. * @ignore
  8611. * This is a list of all the different input types that are available in the application.
  8612. * Fo instance: ArcRotateCameraGamepadInput...
  8613. */
  8614. export var CameraInputTypes: {};
  8615. /**
  8616. * This is the contract to implement in order to create a new input class.
  8617. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8618. */
  8619. export interface ICameraInput<TCamera extends Camera> {
  8620. /**
  8621. * Defines the camera the input is attached to.
  8622. */
  8623. camera: Nullable<TCamera>;
  8624. /**
  8625. * Gets the class name of the current intput.
  8626. * @returns the class name
  8627. */
  8628. getClassName(): string;
  8629. /**
  8630. * Get the friendly name associated with the input class.
  8631. * @returns the input friendly name
  8632. */
  8633. getSimpleName(): string;
  8634. /**
  8635. * Attach the input controls to a specific dom element to get the input from.
  8636. * @param element Defines the element the controls should be listened from
  8637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8638. */
  8639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8640. /**
  8641. * Detach the current controls from the specified dom element.
  8642. * @param element Defines the element to stop listening the inputs from
  8643. */
  8644. detachControl(element: Nullable<HTMLElement>): void;
  8645. /**
  8646. * Update the current camera state depending on the inputs that have been used this frame.
  8647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8648. */
  8649. checkInputs?: () => void;
  8650. }
  8651. /**
  8652. * Represents a map of input types to input instance or input index to input instance.
  8653. */
  8654. export interface CameraInputsMap<TCamera extends Camera> {
  8655. /**
  8656. * Accessor to the input by input type.
  8657. */
  8658. [name: string]: ICameraInput<TCamera>;
  8659. /**
  8660. * Accessor to the input by input index.
  8661. */
  8662. [idx: number]: ICameraInput<TCamera>;
  8663. }
  8664. /**
  8665. * This represents the input manager used within a camera.
  8666. * It helps dealing with all the different kind of input attached to a camera.
  8667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8668. */
  8669. export class CameraInputsManager<TCamera extends Camera> {
  8670. /**
  8671. * Defines the list of inputs attahed to the camera.
  8672. */
  8673. attached: CameraInputsMap<TCamera>;
  8674. /**
  8675. * Defines the dom element the camera is collecting inputs from.
  8676. * This is null if the controls have not been attached.
  8677. */
  8678. attachedElement: Nullable<HTMLElement>;
  8679. /**
  8680. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8681. */
  8682. noPreventDefault: boolean;
  8683. /**
  8684. * Defined the camera the input manager belongs to.
  8685. */
  8686. camera: TCamera;
  8687. /**
  8688. * Update the current camera state depending on the inputs that have been used this frame.
  8689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8690. */
  8691. checkInputs: () => void;
  8692. /**
  8693. * Instantiate a new Camera Input Manager.
  8694. * @param camera Defines the camera the input manager blongs to
  8695. */
  8696. constructor(camera: TCamera);
  8697. /**
  8698. * Add an input method to a camera
  8699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8700. * @param input camera input method
  8701. */
  8702. add(input: ICameraInput<TCamera>): void;
  8703. /**
  8704. * Remove a specific input method from a camera
  8705. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8706. * @param inputToRemove camera input method
  8707. */
  8708. remove(inputToRemove: ICameraInput<TCamera>): void;
  8709. /**
  8710. * Remove a specific input type from a camera
  8711. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8712. * @param inputType the type of the input to remove
  8713. */
  8714. removeByType(inputType: string): void;
  8715. private _addCheckInputs;
  8716. /**
  8717. * Attach the input controls to the currently attached dom element to listen the events from.
  8718. * @param input Defines the input to attach
  8719. */
  8720. attachInput(input: ICameraInput<TCamera>): void;
  8721. /**
  8722. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8723. * @param element Defines the dom element to collect the events from
  8724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8725. */
  8726. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8727. /**
  8728. * Detach the current manager inputs controls from a specific dom element.
  8729. * @param element Defines the dom element to collect the events from
  8730. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8731. */
  8732. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8733. /**
  8734. * Rebuild the dynamic inputCheck function from the current list of
  8735. * defined inputs in the manager.
  8736. */
  8737. rebuildInputCheck(): void;
  8738. /**
  8739. * Remove all attached input methods from a camera
  8740. */
  8741. clear(): void;
  8742. /**
  8743. * Serialize the current input manager attached to a camera.
  8744. * This ensures than once parsed,
  8745. * the input associated to the camera will be identical to the current ones
  8746. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8747. */
  8748. serialize(serializedCamera: any): void;
  8749. /**
  8750. * Parses an input manager serialized JSON to restore the previous list of inputs
  8751. * and states associated to a camera.
  8752. * @param parsedCamera Defines the JSON to parse
  8753. */
  8754. parse(parsedCamera: any): void;
  8755. }
  8756. }
  8757. declare module "babylonjs/Events/keyboardEvents" {
  8758. /**
  8759. * Gather the list of keyboard event types as constants.
  8760. */
  8761. export class KeyboardEventTypes {
  8762. /**
  8763. * The keydown event is fired when a key becomes active (pressed).
  8764. */
  8765. static readonly KEYDOWN: number;
  8766. /**
  8767. * The keyup event is fired when a key has been released.
  8768. */
  8769. static readonly KEYUP: number;
  8770. }
  8771. /**
  8772. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8773. */
  8774. export class KeyboardInfo {
  8775. /**
  8776. * Defines the type of event (KeyboardEventTypes)
  8777. */
  8778. type: number;
  8779. /**
  8780. * Defines the related dom event
  8781. */
  8782. event: KeyboardEvent;
  8783. /**
  8784. * Instantiates a new keyboard info.
  8785. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8786. * @param type Defines the type of event (KeyboardEventTypes)
  8787. * @param event Defines the related dom event
  8788. */
  8789. constructor(
  8790. /**
  8791. * Defines the type of event (KeyboardEventTypes)
  8792. */
  8793. type: number,
  8794. /**
  8795. * Defines the related dom event
  8796. */
  8797. event: KeyboardEvent);
  8798. }
  8799. /**
  8800. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8801. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8802. */
  8803. export class KeyboardInfoPre extends KeyboardInfo {
  8804. /**
  8805. * Defines the type of event (KeyboardEventTypes)
  8806. */
  8807. type: number;
  8808. /**
  8809. * Defines the related dom event
  8810. */
  8811. event: KeyboardEvent;
  8812. /**
  8813. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8814. */
  8815. skipOnPointerObservable: boolean;
  8816. /**
  8817. * Instantiates a new keyboard pre info.
  8818. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8819. * @param type Defines the type of event (KeyboardEventTypes)
  8820. * @param event Defines the related dom event
  8821. */
  8822. constructor(
  8823. /**
  8824. * Defines the type of event (KeyboardEventTypes)
  8825. */
  8826. type: number,
  8827. /**
  8828. * Defines the related dom event
  8829. */
  8830. event: KeyboardEvent);
  8831. }
  8832. }
  8833. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8834. import { Nullable } from "babylonjs/types";
  8835. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8836. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8837. /**
  8838. * Manage the keyboard inputs to control the movement of a free camera.
  8839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8840. */
  8841. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8842. /**
  8843. * Defines the camera the input is attached to.
  8844. */
  8845. camera: FreeCamera;
  8846. /**
  8847. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8848. */
  8849. keysUp: number[];
  8850. /**
  8851. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8852. */
  8853. keysDown: number[];
  8854. /**
  8855. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8856. */
  8857. keysLeft: number[];
  8858. /**
  8859. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8860. */
  8861. keysRight: number[];
  8862. private _keys;
  8863. private _onCanvasBlurObserver;
  8864. private _onKeyboardObserver;
  8865. private _engine;
  8866. private _scene;
  8867. /**
  8868. * Attach the input controls to a specific dom element to get the input from.
  8869. * @param element Defines the element the controls should be listened from
  8870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8871. */
  8872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8873. /**
  8874. * Detach the current controls from the specified dom element.
  8875. * @param element Defines the element to stop listening the inputs from
  8876. */
  8877. detachControl(element: Nullable<HTMLElement>): void;
  8878. /**
  8879. * Update the current camera state depending on the inputs that have been used this frame.
  8880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8881. */
  8882. checkInputs(): void;
  8883. /**
  8884. * Gets the class name of the current intput.
  8885. * @returns the class name
  8886. */
  8887. getClassName(): string;
  8888. /** @hidden */
  8889. _onLostFocus(): void;
  8890. /**
  8891. * Get the friendly name associated with the input class.
  8892. * @returns the input friendly name
  8893. */
  8894. getSimpleName(): string;
  8895. }
  8896. }
  8897. declare module "babylonjs/Lights/shadowLight" {
  8898. import { Camera } from "babylonjs/Cameras/camera";
  8899. import { Scene } from "babylonjs/scene";
  8900. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8902. import { Light } from "babylonjs/Lights/light";
  8903. /**
  8904. * Interface describing all the common properties and methods a shadow light needs to implement.
  8905. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8906. * as well as binding the different shadow properties to the effects.
  8907. */
  8908. export interface IShadowLight extends Light {
  8909. /**
  8910. * The light id in the scene (used in scene.findLighById for instance)
  8911. */
  8912. id: string;
  8913. /**
  8914. * The position the shdow will be casted from.
  8915. */
  8916. position: Vector3;
  8917. /**
  8918. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8919. */
  8920. direction: Vector3;
  8921. /**
  8922. * The transformed position. Position of the light in world space taking parenting in account.
  8923. */
  8924. transformedPosition: Vector3;
  8925. /**
  8926. * The transformed direction. Direction of the light in world space taking parenting in account.
  8927. */
  8928. transformedDirection: Vector3;
  8929. /**
  8930. * The friendly name of the light in the scene.
  8931. */
  8932. name: string;
  8933. /**
  8934. * Defines the shadow projection clipping minimum z value.
  8935. */
  8936. shadowMinZ: number;
  8937. /**
  8938. * Defines the shadow projection clipping maximum z value.
  8939. */
  8940. shadowMaxZ: number;
  8941. /**
  8942. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8943. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8944. */
  8945. computeTransformedInformation(): boolean;
  8946. /**
  8947. * Gets the scene the light belongs to.
  8948. * @returns The scene
  8949. */
  8950. getScene(): Scene;
  8951. /**
  8952. * Callback defining a custom Projection Matrix Builder.
  8953. * This can be used to override the default projection matrix computation.
  8954. */
  8955. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8956. /**
  8957. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8958. * @param matrix The materix to updated with the projection information
  8959. * @param viewMatrix The transform matrix of the light
  8960. * @param renderList The list of mesh to render in the map
  8961. * @returns The current light
  8962. */
  8963. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8964. /**
  8965. * Gets the current depth scale used in ESM.
  8966. * @returns The scale
  8967. */
  8968. getDepthScale(): number;
  8969. /**
  8970. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8971. * @returns true if a cube texture needs to be use
  8972. */
  8973. needCube(): boolean;
  8974. /**
  8975. * Detects if the projection matrix requires to be recomputed this frame.
  8976. * @returns true if it requires to be recomputed otherwise, false.
  8977. */
  8978. needProjectionMatrixCompute(): boolean;
  8979. /**
  8980. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8981. */
  8982. forceProjectionMatrixCompute(): void;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Gets the minZ used for shadow according to both the scene and the light.
  8991. * @param activeCamera The camera we are returning the min for
  8992. * @returns the depth min z
  8993. */
  8994. getDepthMinZ(activeCamera: Camera): number;
  8995. /**
  8996. * Gets the maxZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the max for
  8998. * @returns the depth max z
  8999. */
  9000. getDepthMaxZ(activeCamera: Camera): number;
  9001. }
  9002. /**
  9003. * Base implementation IShadowLight
  9004. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9005. */
  9006. export abstract class ShadowLight extends Light implements IShadowLight {
  9007. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9008. protected _position: Vector3;
  9009. protected _setPosition(value: Vector3): void;
  9010. /**
  9011. * Sets the position the shadow will be casted from. Also use as the light position for both
  9012. * point and spot lights.
  9013. */
  9014. /**
  9015. * Sets the position the shadow will be casted from. Also use as the light position for both
  9016. * point and spot lights.
  9017. */
  9018. position: Vector3;
  9019. protected _direction: Vector3;
  9020. protected _setDirection(value: Vector3): void;
  9021. /**
  9022. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9023. * Also use as the light direction on spot and directional lights.
  9024. */
  9025. /**
  9026. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9027. * Also use as the light direction on spot and directional lights.
  9028. */
  9029. direction: Vector3;
  9030. private _shadowMinZ;
  9031. /**
  9032. * Gets the shadow projection clipping minimum z value.
  9033. */
  9034. /**
  9035. * Sets the shadow projection clipping minimum z value.
  9036. */
  9037. shadowMinZ: number;
  9038. private _shadowMaxZ;
  9039. /**
  9040. * Sets the shadow projection clipping maximum z value.
  9041. */
  9042. /**
  9043. * Gets the shadow projection clipping maximum z value.
  9044. */
  9045. shadowMaxZ: number;
  9046. /**
  9047. * Callback defining a custom Projection Matrix Builder.
  9048. * This can be used to override the default projection matrix computation.
  9049. */
  9050. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9051. /**
  9052. * The transformed position. Position of the light in world space taking parenting in account.
  9053. */
  9054. transformedPosition: Vector3;
  9055. /**
  9056. * The transformed direction. Direction of the light in world space taking parenting in account.
  9057. */
  9058. transformedDirection: Vector3;
  9059. private _needProjectionMatrixCompute;
  9060. /**
  9061. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9062. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9063. */
  9064. computeTransformedInformation(): boolean;
  9065. /**
  9066. * Return the depth scale used for the shadow map.
  9067. * @returns the depth scale.
  9068. */
  9069. getDepthScale(): number;
  9070. /**
  9071. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9072. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9073. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9074. */
  9075. getShadowDirection(faceIndex?: number): Vector3;
  9076. /**
  9077. * Returns the ShadowLight absolute position in the World.
  9078. * @returns the position vector in world space
  9079. */
  9080. getAbsolutePosition(): Vector3;
  9081. /**
  9082. * Sets the ShadowLight direction toward the passed target.
  9083. * @param target The point to target in local space
  9084. * @returns the updated ShadowLight direction
  9085. */
  9086. setDirectionToTarget(target: Vector3): Vector3;
  9087. /**
  9088. * Returns the light rotation in euler definition.
  9089. * @returns the x y z rotation in local space.
  9090. */
  9091. getRotation(): Vector3;
  9092. /**
  9093. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9094. * @returns true if a cube texture needs to be use
  9095. */
  9096. needCube(): boolean;
  9097. /**
  9098. * Detects if the projection matrix requires to be recomputed this frame.
  9099. * @returns true if it requires to be recomputed otherwise, false.
  9100. */
  9101. needProjectionMatrixCompute(): boolean;
  9102. /**
  9103. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9104. */
  9105. forceProjectionMatrixCompute(): void;
  9106. /** @hidden */
  9107. _initCache(): void;
  9108. /** @hidden */
  9109. _isSynchronized(): boolean;
  9110. /**
  9111. * Computes the world matrix of the node
  9112. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9113. * @returns the world matrix
  9114. */
  9115. computeWorldMatrix(force?: boolean): Matrix;
  9116. /**
  9117. * Gets the minZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the min for
  9119. * @returns the depth min z
  9120. */
  9121. getDepthMinZ(activeCamera: Camera): number;
  9122. /**
  9123. * Gets the maxZ used for shadow according to both the scene and the light.
  9124. * @param activeCamera The camera we are returning the max for
  9125. * @returns the depth max z
  9126. */
  9127. getDepthMaxZ(activeCamera: Camera): number;
  9128. /**
  9129. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9130. * @param matrix The materix to updated with the projection information
  9131. * @param viewMatrix The transform matrix of the light
  9132. * @param renderList The list of mesh to render in the map
  9133. * @returns The current light
  9134. */
  9135. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9136. }
  9137. }
  9138. declare module "babylonjs/Materials/materialHelper" {
  9139. import { Nullable } from "babylonjs/types";
  9140. import { Scene } from "babylonjs/scene";
  9141. import { Engine } from "babylonjs/Engines/engine";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. import { Light } from "babylonjs/Lights/light";
  9144. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9145. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9147. /**
  9148. * "Static Class" containing the most commonly used helper while dealing with material for
  9149. * rendering purpose.
  9150. *
  9151. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9152. *
  9153. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9154. */
  9155. export class MaterialHelper {
  9156. /**
  9157. * Bind the current view position to an effect.
  9158. * @param effect The effect to be bound
  9159. * @param scene The scene the eyes position is used from
  9160. */
  9161. static BindEyePosition(effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Helps preparing the defines values about the UVs in used in the effect.
  9164. * UVs are shared as much as we can accross channels in the shaders.
  9165. * @param texture The texture we are preparing the UVs for
  9166. * @param defines The defines to update
  9167. * @param key The channel key "diffuse", "specular"... used in the shader
  9168. */
  9169. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9170. /**
  9171. * Binds a texture matrix value to its corrsponding uniform
  9172. * @param texture The texture to bind the matrix for
  9173. * @param uniformBuffer The uniform buffer receivin the data
  9174. * @param key The channel key "diffuse", "specular"... used in the shader
  9175. */
  9176. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9177. /**
  9178. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9179. * @param mesh defines the current mesh
  9180. * @param scene defines the current scene
  9181. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9182. * @param pointsCloud defines if point cloud rendering has to be turned on
  9183. * @param fogEnabled defines if fog has to be turned on
  9184. * @param alphaTest defines if alpha testing has to be turned on
  9185. * @param defines defines the current list of defines
  9186. */
  9187. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9188. /**
  9189. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9190. * @param scene defines the current scene
  9191. * @param engine defines the current engine
  9192. * @param defines specifies the list of active defines
  9193. * @param useInstances defines if instances have to be turned on
  9194. * @param useClipPlane defines if clip plane have to be turned on
  9195. */
  9196. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9197. /**
  9198. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9199. * @param mesh The mesh containing the geometry data we will draw
  9200. * @param defines The defines to update
  9201. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9202. * @param useBones Precise whether bones should be used or not (override mesh info)
  9203. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9204. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9205. * @returns false if defines are considered not dirty and have not been checked
  9206. */
  9207. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9208. /**
  9209. * Prepares the defines related to the light information passed in parameter
  9210. * @param scene The scene we are intending to draw
  9211. * @param mesh The mesh the effect is compiling for
  9212. * @param defines The defines to update
  9213. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9214. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9215. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9216. * @returns true if normals will be required for the rest of the effect
  9217. */
  9218. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9219. /**
  9220. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9221. * that won t be acctive due to defines being turned off.
  9222. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9223. * @param samplersList The samplers list
  9224. * @param defines The defines helping in the list generation
  9225. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9226. */
  9227. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9228. /**
  9229. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9230. * @param defines The defines to update while falling back
  9231. * @param fallbacks The authorized effect fallbacks
  9232. * @param maxSimultaneousLights The maximum number of lights allowed
  9233. * @param rank the current rank of the Effect
  9234. * @returns The newly affected rank
  9235. */
  9236. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9237. /**
  9238. * Prepares the list of attributes required for morph targets according to the effect defines.
  9239. * @param attribs The current list of supported attribs
  9240. * @param mesh The mesh to prepare the morph targets attributes for
  9241. * @param defines The current Defines of the effect
  9242. */
  9243. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9244. /**
  9245. * Prepares the list of attributes required for bones according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the bones attributes for
  9248. * @param defines The current Defines of the effect
  9249. * @param fallbacks The current efffect fallback strategy
  9250. */
  9251. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9252. /**
  9253. * Prepares the list of attributes required for instances according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param defines The current Defines of the effect
  9256. */
  9257. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9258. /**
  9259. * Binds the light shadow information to the effect for the given mesh.
  9260. * @param light The light containing the generator
  9261. * @param scene The scene the lights belongs to
  9262. * @param mesh The mesh we are binding the information to render
  9263. * @param lightIndex The light index in the effect used to render the mesh
  9264. * @param effect The effect we are binding the data to
  9265. */
  9266. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9267. /**
  9268. * Binds the light information to the effect.
  9269. * @param light The light containing the generator
  9270. * @param effect The effect we are binding the data to
  9271. * @param lightIndex The light index in the effect used to render
  9272. */
  9273. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9274. /**
  9275. * Binds the lights information from the scene to the effect for the given mesh.
  9276. * @param scene The scene the lights belongs to
  9277. * @param mesh The mesh we are binding the information to render
  9278. * @param effect The effect we are binding the data to
  9279. * @param defines The generated defines for the effect
  9280. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9281. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9282. */
  9283. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9284. private static _tempFogColor;
  9285. /**
  9286. * Binds the fog information from the scene to the effect for the given mesh.
  9287. * @param scene The scene the lights belongs to
  9288. * @param mesh The mesh we are binding the information to render
  9289. * @param effect The effect we are binding the data to
  9290. * @param linearSpace Defines if the fog effect is applied in linear space
  9291. */
  9292. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9293. /**
  9294. * Binds the bones information from the mesh to the effect.
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. */
  9298. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9299. /**
  9300. * Binds the morph targets information from the mesh to the effect.
  9301. * @param abstractMesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. */
  9304. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9305. /**
  9306. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9307. * @param defines The generated defines used in the effect
  9308. * @param effect The effect we are binding the data to
  9309. * @param scene The scene we are willing to render with logarithmic scale for
  9310. */
  9311. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9312. /**
  9313. * Binds the clip plane information from the scene to the effect.
  9314. * @param scene The scene the clip plane information are extracted from
  9315. * @param effect The effect we are binding the data to
  9316. */
  9317. static BindClipPlane(effect: Effect, scene: Scene): void;
  9318. }
  9319. }
  9320. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9321. /** @hidden */
  9322. export var kernelBlurVaryingDeclaration: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9328. /** @hidden */
  9329. export var kernelBlurFragment: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9335. /** @hidden */
  9336. export var kernelBlurFragment2: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9342. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9343. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9344. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9345. /** @hidden */
  9346. export var kernelBlurPixelShader: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9352. /** @hidden */
  9353. export var kernelBlurVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9359. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9360. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9361. /** @hidden */
  9362. export var kernelBlurVertexShader: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9368. import { Vector2 } from "babylonjs/Maths/math";
  9369. import { Nullable } from "babylonjs/types";
  9370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9371. import { Camera } from "babylonjs/Cameras/camera";
  9372. import { Effect } from "babylonjs/Materials/effect";
  9373. import { Engine } from "babylonjs/Engines/engine";
  9374. import "babylonjs/Shaders/kernelBlur.fragment";
  9375. import "babylonjs/Shaders/kernelBlur.vertex";
  9376. /**
  9377. * The Blur Post Process which blurs an image based on a kernel and direction.
  9378. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9379. */
  9380. export class BlurPostProcess extends PostProcess {
  9381. /** The direction in which to blur the image. */
  9382. direction: Vector2;
  9383. private blockCompilation;
  9384. protected _kernel: number;
  9385. protected _idealKernel: number;
  9386. protected _packedFloat: boolean;
  9387. private _staticDefines;
  9388. /**
  9389. * Sets the length in pixels of the blur sample region
  9390. */
  9391. /**
  9392. * Gets the length in pixels of the blur sample region
  9393. */
  9394. kernel: number;
  9395. /**
  9396. * Sets wether or not the blur needs to unpack/repack floats
  9397. */
  9398. /**
  9399. * Gets wether or not the blur is unpacking/repacking floats
  9400. */
  9401. packedFloat: boolean;
  9402. /**
  9403. * Creates a new instance BlurPostProcess
  9404. * @param name The name of the effect.
  9405. * @param direction The direction in which to blur the image.
  9406. * @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.
  9407. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9408. * @param camera The camera to apply the render pass to.
  9409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9410. * @param engine The engine which the post process will be applied. (default: current engine)
  9411. * @param reusable If the post process can be reused on the same frame. (default: false)
  9412. * @param textureType Type of textures used when performing the post process. (default: 0)
  9413. * @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)
  9414. */
  9415. constructor(name: string,
  9416. /** The direction in which to blur the image. */
  9417. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9418. /**
  9419. * Updates the effect with the current post process compile time values and recompiles the shader.
  9420. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9421. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9422. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9423. * @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
  9424. * @param onCompiled Called when the shader has been compiled.
  9425. * @param onError Called if there is an error when compiling a shader.
  9426. */
  9427. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9428. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9429. /**
  9430. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9431. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9432. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9433. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9434. * The gaps between physical kernels are compensated for in the weighting of the samples
  9435. * @param idealKernel Ideal blur kernel.
  9436. * @return Nearest best kernel.
  9437. */
  9438. protected _nearestBestKernel(idealKernel: number): number;
  9439. /**
  9440. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9441. * @param x The point on the Gaussian distribution to sample.
  9442. * @return the value of the Gaussian function at x.
  9443. */
  9444. protected _gaussianWeight(x: number): number;
  9445. /**
  9446. * Generates a string that can be used as a floating point number in GLSL.
  9447. * @param x Value to print.
  9448. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9449. * @return GLSL float string.
  9450. */
  9451. protected _glslFloat(x: number, decimalFigures?: number): string;
  9452. }
  9453. }
  9454. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9455. /** @hidden */
  9456. export var shadowMapPixelShader: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9462. /** @hidden */
  9463. export var bonesDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexGlobalDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9476. /** @hidden */
  9477. export var morphTargetsVertexDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9483. /** @hidden */
  9484. export var instancesDeclaration: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9490. /** @hidden */
  9491. export var helperFunctions: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9518. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9523. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9525. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9526. /** @hidden */
  9527. export var shadowMapVertexShader: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9533. /** @hidden */
  9534. export var depthBoxBlurPixelShader: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9540. import { Nullable } from "babylonjs/types";
  9541. import { Scene } from "babylonjs/scene";
  9542. import { Matrix } from "babylonjs/Maths/math";
  9543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9545. import { Mesh } from "babylonjs/Meshes/mesh";
  9546. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9547. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9548. import { Effect } from "babylonjs/Materials/effect";
  9549. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9550. import "babylonjs/Shaders/shadowMap.fragment";
  9551. import "babylonjs/Shaders/shadowMap.vertex";
  9552. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9553. import { Observable } from "babylonjs/Misc/observable";
  9554. /**
  9555. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9556. */
  9557. export interface ICustomShaderOptions {
  9558. /**
  9559. * Gets or sets the custom shader name to use
  9560. */
  9561. shaderName: string;
  9562. /**
  9563. * The list of attribute names used in the shader
  9564. */
  9565. attributes?: string[];
  9566. /**
  9567. * The list of unifrom names used in the shader
  9568. */
  9569. uniforms?: string[];
  9570. /**
  9571. * The list of sampler names used in the shader
  9572. */
  9573. samplers?: string[];
  9574. /**
  9575. * The list of defines used in the shader
  9576. */
  9577. defines?: string[];
  9578. }
  9579. /**
  9580. * Interface to implement to create a shadow generator compatible with BJS.
  9581. */
  9582. export interface IShadowGenerator {
  9583. /**
  9584. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9585. * @returns The render target texture if present otherwise, null
  9586. */
  9587. getShadowMap(): Nullable<RenderTargetTexture>;
  9588. /**
  9589. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9590. * @returns The render target texture if the shadow map is present otherwise, null
  9591. */
  9592. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9593. /**
  9594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9595. * @param subMesh The submesh we want to render in the shadow map
  9596. * @param useInstances Defines wether will draw in the map using instances
  9597. * @returns true if ready otherwise, false
  9598. */
  9599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9600. /**
  9601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9602. * @param defines Defines of the material we want to update
  9603. * @param lightIndex Index of the light in the enabled light list of the material
  9604. */
  9605. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9606. /**
  9607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9608. * defined in the generator but impacting the effect).
  9609. * It implies the unifroms available on the materials are the standard BJS ones.
  9610. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9611. * @param effect The effect we are binfing the information for
  9612. */
  9613. bindShadowLight(lightIndex: string, effect: Effect): void;
  9614. /**
  9615. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9616. * (eq to shadow prjection matrix * light transform matrix)
  9617. * @returns The transform matrix used to create the shadow map
  9618. */
  9619. getTransformMatrix(): Matrix;
  9620. /**
  9621. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9622. * Cube and 2D textures for instance.
  9623. */
  9624. recreateShadowMap(): void;
  9625. /**
  9626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9627. * @param onCompiled Callback triggered at the and of the effects compilation
  9628. * @param options Sets of optional options forcing the compilation with different modes
  9629. */
  9630. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9631. useInstances: boolean;
  9632. }>): void;
  9633. /**
  9634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9635. * @param options Sets of optional options forcing the compilation with different modes
  9636. * @returns A promise that resolves when the compilation completes
  9637. */
  9638. forceCompilationAsync(options?: Partial<{
  9639. useInstances: boolean;
  9640. }>): Promise<void>;
  9641. /**
  9642. * Serializes the shadow generator setup to a json object.
  9643. * @returns The serialized JSON object
  9644. */
  9645. serialize(): any;
  9646. /**
  9647. * Disposes the Shadow map and related Textures and effects.
  9648. */
  9649. dispose(): void;
  9650. }
  9651. /**
  9652. * Default implementation IShadowGenerator.
  9653. * This is the main object responsible of generating shadows in the framework.
  9654. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9655. */
  9656. export class ShadowGenerator implements IShadowGenerator {
  9657. /**
  9658. * Shadow generator mode None: no filtering applied.
  9659. */
  9660. static readonly FILTER_NONE: number;
  9661. /**
  9662. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9664. */
  9665. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9666. /**
  9667. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9668. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9669. */
  9670. static readonly FILTER_POISSONSAMPLING: number;
  9671. /**
  9672. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9673. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9674. */
  9675. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9676. /**
  9677. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9678. * edge artifacts on steep falloff.
  9679. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9680. */
  9681. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9682. /**
  9683. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9684. * edge artifacts on steep falloff.
  9685. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9686. */
  9687. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9688. /**
  9689. * Shadow generator mode PCF: Percentage Closer Filtering
  9690. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9691. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9692. */
  9693. static readonly FILTER_PCF: number;
  9694. /**
  9695. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9696. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9697. * Contact Hardening
  9698. */
  9699. static readonly FILTER_PCSS: number;
  9700. /**
  9701. * Reserved for PCF and PCSS
  9702. * Highest Quality.
  9703. *
  9704. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9705. *
  9706. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9707. */
  9708. static readonly QUALITY_HIGH: number;
  9709. /**
  9710. * Reserved for PCF and PCSS
  9711. * Good tradeoff for quality/perf cross devices
  9712. *
  9713. * Execute PCF on a 3*3 kernel.
  9714. *
  9715. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9716. */
  9717. static readonly QUALITY_MEDIUM: number;
  9718. /**
  9719. * Reserved for PCF and PCSS
  9720. * The lowest quality but the fastest.
  9721. *
  9722. * Execute PCF on a 1*1 kernel.
  9723. *
  9724. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9725. */
  9726. static readonly QUALITY_LOW: number;
  9727. /** Gets or sets the custom shader name to use */
  9728. customShaderOptions: ICustomShaderOptions;
  9729. /**
  9730. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9731. */
  9732. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9733. /**
  9734. * Observable triggered before a mesh is rendered in the shadow map.
  9735. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9736. */
  9737. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9738. private _bias;
  9739. /**
  9740. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9741. */
  9742. /**
  9743. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9744. */
  9745. bias: number;
  9746. private _normalBias;
  9747. /**
  9748. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9749. */
  9750. /**
  9751. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9752. */
  9753. normalBias: number;
  9754. private _blurBoxOffset;
  9755. /**
  9756. * Gets the blur box offset: offset applied during the blur pass.
  9757. * Only useful if useKernelBlur = false
  9758. */
  9759. /**
  9760. * Sets the blur box offset: offset applied during the blur pass.
  9761. * Only useful if useKernelBlur = false
  9762. */
  9763. blurBoxOffset: number;
  9764. private _blurScale;
  9765. /**
  9766. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9767. * 2 means half of the size.
  9768. */
  9769. /**
  9770. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9771. * 2 means half of the size.
  9772. */
  9773. blurScale: number;
  9774. private _blurKernel;
  9775. /**
  9776. * Gets the blur kernel: kernel size of the blur pass.
  9777. * Only useful if useKernelBlur = true
  9778. */
  9779. /**
  9780. * Sets the blur kernel: kernel size of the blur pass.
  9781. * Only useful if useKernelBlur = true
  9782. */
  9783. blurKernel: number;
  9784. private _useKernelBlur;
  9785. /**
  9786. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9788. */
  9789. /**
  9790. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9791. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9792. */
  9793. useKernelBlur: boolean;
  9794. private _depthScale;
  9795. /**
  9796. * Gets the depth scale used in ESM mode.
  9797. */
  9798. /**
  9799. * Sets the depth scale used in ESM mode.
  9800. * This can override the scale stored on the light.
  9801. */
  9802. depthScale: number;
  9803. private _filter;
  9804. /**
  9805. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9806. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9807. */
  9808. /**
  9809. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9810. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9811. */
  9812. filter: number;
  9813. /**
  9814. * Gets if the current filter is set to Poisson Sampling.
  9815. */
  9816. /**
  9817. * Sets the current filter to Poisson Sampling.
  9818. */
  9819. usePoissonSampling: boolean;
  9820. /**
  9821. * Gets if the current filter is set to ESM.
  9822. */
  9823. /**
  9824. * Sets the current filter is to ESM.
  9825. */
  9826. useExponentialShadowMap: boolean;
  9827. /**
  9828. * Gets if the current filter is set to filtered ESM.
  9829. */
  9830. /**
  9831. * Gets if the current filter is set to filtered ESM.
  9832. */
  9833. useBlurExponentialShadowMap: boolean;
  9834. /**
  9835. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9836. * exponential to prevent steep falloff artifacts).
  9837. */
  9838. /**
  9839. * Sets the current filter to "close ESM" (using the inverse of the
  9840. * exponential to prevent steep falloff artifacts).
  9841. */
  9842. useCloseExponentialShadowMap: boolean;
  9843. /**
  9844. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9845. * exponential to prevent steep falloff artifacts).
  9846. */
  9847. /**
  9848. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9849. * exponential to prevent steep falloff artifacts).
  9850. */
  9851. useBlurCloseExponentialShadowMap: boolean;
  9852. /**
  9853. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9854. */
  9855. /**
  9856. * Sets the current filter to "PCF" (percentage closer filtering).
  9857. */
  9858. usePercentageCloserFiltering: boolean;
  9859. private _filteringQuality;
  9860. /**
  9861. * Gets the PCF or PCSS Quality.
  9862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9863. */
  9864. /**
  9865. * Sets the PCF or PCSS Quality.
  9866. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9867. */
  9868. filteringQuality: number;
  9869. /**
  9870. * Gets if the current filter is set to "PCSS" (contact hardening).
  9871. */
  9872. /**
  9873. * Sets the current filter to "PCSS" (contact hardening).
  9874. */
  9875. useContactHardeningShadow: boolean;
  9876. private _contactHardeningLightSizeUVRatio;
  9877. /**
  9878. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9879. * Using a ratio helps keeping shape stability independently of the map size.
  9880. *
  9881. * It does not account for the light projection as it was having too much
  9882. * instability during the light setup or during light position changes.
  9883. *
  9884. * Only valid if useContactHardeningShadow is true.
  9885. */
  9886. /**
  9887. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9888. * Using a ratio helps keeping shape stability independently of the map size.
  9889. *
  9890. * It does not account for the light projection as it was having too much
  9891. * instability during the light setup or during light position changes.
  9892. *
  9893. * Only valid if useContactHardeningShadow is true.
  9894. */
  9895. contactHardeningLightSizeUVRatio: number;
  9896. private _darkness;
  9897. /**
  9898. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9899. * 0 means strongest and 1 would means no shadow.
  9900. * @returns the darkness.
  9901. */
  9902. getDarkness(): number;
  9903. /**
  9904. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9905. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9906. * @returns the shadow generator allowing fluent coding.
  9907. */
  9908. setDarkness(darkness: number): ShadowGenerator;
  9909. private _transparencyShadow;
  9910. /**
  9911. * Sets the ability to have transparent shadow (boolean).
  9912. * @param transparent True if transparent else False
  9913. * @returns the shadow generator allowing fluent coding
  9914. */
  9915. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9916. private _shadowMap;
  9917. private _shadowMap2;
  9918. /**
  9919. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9920. * @returns The render target texture if present otherwise, null
  9921. */
  9922. getShadowMap(): Nullable<RenderTargetTexture>;
  9923. /**
  9924. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9925. * @returns The render target texture if the shadow map is present otherwise, null
  9926. */
  9927. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9928. /**
  9929. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9930. * @param mesh Mesh to add
  9931. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9932. * @returns the Shadow Generator itself
  9933. */
  9934. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9935. /**
  9936. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9937. * @param mesh Mesh to remove
  9938. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9939. * @returns the Shadow Generator itself
  9940. */
  9941. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9942. /**
  9943. * Controls the extent to which the shadows fade out at the edge of the frustum
  9944. * Used only by directionals and spots
  9945. */
  9946. frustumEdgeFalloff: number;
  9947. private _light;
  9948. /**
  9949. * Returns the associated light object.
  9950. * @returns the light generating the shadow
  9951. */
  9952. getLight(): IShadowLight;
  9953. /**
  9954. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9955. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9956. * It might on the other hand introduce peter panning.
  9957. */
  9958. forceBackFacesOnly: boolean;
  9959. private _scene;
  9960. private _lightDirection;
  9961. private _effect;
  9962. private _viewMatrix;
  9963. private _projectionMatrix;
  9964. private _transformMatrix;
  9965. private _cachedPosition;
  9966. private _cachedDirection;
  9967. private _cachedDefines;
  9968. private _currentRenderID;
  9969. private _boxBlurPostprocess;
  9970. private _kernelBlurXPostprocess;
  9971. private _kernelBlurYPostprocess;
  9972. private _blurPostProcesses;
  9973. private _mapSize;
  9974. private _currentFaceIndex;
  9975. private _currentFaceIndexCache;
  9976. private _textureType;
  9977. private _defaultTextureMatrix;
  9978. /** @hidden */
  9979. static _SceneComponentInitialization: (scene: Scene) => void;
  9980. /**
  9981. * Creates a ShadowGenerator object.
  9982. * A ShadowGenerator is the required tool to use the shadows.
  9983. * Each light casting shadows needs to use its own ShadowGenerator.
  9984. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9985. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9986. * @param light The light object generating the shadows.
  9987. * @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.
  9988. */
  9989. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9990. private _initializeGenerator;
  9991. private _initializeShadowMap;
  9992. private _initializeBlurRTTAndPostProcesses;
  9993. private _renderForShadowMap;
  9994. private _renderSubMeshForShadowMap;
  9995. private _applyFilterValues;
  9996. /**
  9997. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9998. * @param onCompiled Callback triggered at the and of the effects compilation
  9999. * @param options Sets of optional options forcing the compilation with different modes
  10000. */
  10001. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10002. useInstances: boolean;
  10003. }>): void;
  10004. /**
  10005. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10006. * @param options Sets of optional options forcing the compilation with different modes
  10007. * @returns A promise that resolves when the compilation completes
  10008. */
  10009. forceCompilationAsync(options?: Partial<{
  10010. useInstances: boolean;
  10011. }>): Promise<void>;
  10012. /**
  10013. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10014. * @param subMesh The submesh we want to render in the shadow map
  10015. * @param useInstances Defines wether will draw in the map using instances
  10016. * @returns true if ready otherwise, false
  10017. */
  10018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10019. /**
  10020. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10021. * @param defines Defines of the material we want to update
  10022. * @param lightIndex Index of the light in the enabled light list of the material
  10023. */
  10024. prepareDefines(defines: any, lightIndex: number): void;
  10025. /**
  10026. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10027. * defined in the generator but impacting the effect).
  10028. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10029. * @param effect The effect we are binfing the information for
  10030. */
  10031. bindShadowLight(lightIndex: string, effect: Effect): void;
  10032. /**
  10033. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10034. * (eq to shadow prjection matrix * light transform matrix)
  10035. * @returns The transform matrix used to create the shadow map
  10036. */
  10037. getTransformMatrix(): Matrix;
  10038. /**
  10039. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10040. * Cube and 2D textures for instance.
  10041. */
  10042. recreateShadowMap(): void;
  10043. private _disposeBlurPostProcesses;
  10044. private _disposeRTTandPostProcesses;
  10045. /**
  10046. * Disposes the ShadowGenerator.
  10047. * Returns nothing.
  10048. */
  10049. dispose(): void;
  10050. /**
  10051. * Serializes the shadow generator setup to a json object.
  10052. * @returns The serialized JSON object
  10053. */
  10054. serialize(): any;
  10055. /**
  10056. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10057. * @param parsedShadowGenerator The JSON object to parse
  10058. * @param scene The scene to create the shadow map for
  10059. * @returns The parsed shadow generator
  10060. */
  10061. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10062. }
  10063. }
  10064. declare module "babylonjs/Lights/light" {
  10065. import { Nullable } from "babylonjs/types";
  10066. import { Scene } from "babylonjs/scene";
  10067. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10068. import { Node } from "babylonjs/node";
  10069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10070. import { Effect } from "babylonjs/Materials/effect";
  10071. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10072. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10073. /**
  10074. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10075. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10076. * 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.
  10077. */
  10078. export abstract class Light extends Node {
  10079. /**
  10080. * Falloff Default: light is falling off following the material specification:
  10081. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10082. */
  10083. static readonly FALLOFF_DEFAULT: number;
  10084. /**
  10085. * Falloff Physical: light is falling off following the inverse squared distance law.
  10086. */
  10087. static readonly FALLOFF_PHYSICAL: number;
  10088. /**
  10089. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10090. * to enhance interoperability with other engines.
  10091. */
  10092. static readonly FALLOFF_GLTF: number;
  10093. /**
  10094. * Falloff Standard: light is falling off like in the standard material
  10095. * to enhance interoperability with other materials.
  10096. */
  10097. static readonly FALLOFF_STANDARD: number;
  10098. /**
  10099. * If every light affecting the material is in this lightmapMode,
  10100. * material.lightmapTexture adds or multiplies
  10101. * (depends on material.useLightmapAsShadowmap)
  10102. * after every other light calculations.
  10103. */
  10104. static readonly LIGHTMAP_DEFAULT: number;
  10105. /**
  10106. * material.lightmapTexture as only diffuse lighting from this light
  10107. * adds only specular lighting from this light
  10108. * adds dynamic shadows
  10109. */
  10110. static readonly LIGHTMAP_SPECULAR: number;
  10111. /**
  10112. * material.lightmapTexture as only lighting
  10113. * no light calculation from this light
  10114. * only adds dynamic shadows from this light
  10115. */
  10116. static readonly LIGHTMAP_SHADOWSONLY: number;
  10117. /**
  10118. * Each light type uses the default quantity according to its type:
  10119. * point/spot lights use luminous intensity
  10120. * directional lights use illuminance
  10121. */
  10122. static readonly INTENSITYMODE_AUTOMATIC: number;
  10123. /**
  10124. * lumen (lm)
  10125. */
  10126. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10127. /**
  10128. * candela (lm/sr)
  10129. */
  10130. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10131. /**
  10132. * lux (lm/m^2)
  10133. */
  10134. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10135. /**
  10136. * nit (cd/m^2)
  10137. */
  10138. static readonly INTENSITYMODE_LUMINANCE: number;
  10139. /**
  10140. * Light type const id of the point light.
  10141. */
  10142. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10143. /**
  10144. * Light type const id of the directional light.
  10145. */
  10146. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10147. /**
  10148. * Light type const id of the spot light.
  10149. */
  10150. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10151. /**
  10152. * Light type const id of the hemispheric light.
  10153. */
  10154. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10155. /**
  10156. * Diffuse gives the basic color to an object.
  10157. */
  10158. diffuse: Color3;
  10159. /**
  10160. * Specular produces a highlight color on an object.
  10161. * Note: This is note affecting PBR materials.
  10162. */
  10163. specular: Color3;
  10164. /**
  10165. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10166. * falling off base on range or angle.
  10167. * This can be set to any values in Light.FALLOFF_x.
  10168. *
  10169. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10170. * other types of materials.
  10171. */
  10172. falloffType: number;
  10173. /**
  10174. * Strength of the light.
  10175. * Note: By default it is define in the framework own unit.
  10176. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10177. */
  10178. intensity: number;
  10179. private _range;
  10180. protected _inverseSquaredRange: number;
  10181. /**
  10182. * Defines how far from the source the light is impacting in scene units.
  10183. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10184. */
  10185. /**
  10186. * Defines how far from the source the light is impacting in scene units.
  10187. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10188. */
  10189. range: number;
  10190. /**
  10191. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10192. * of light.
  10193. */
  10194. private _photometricScale;
  10195. private _intensityMode;
  10196. /**
  10197. * Gets the photometric scale used to interpret the intensity.
  10198. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10199. */
  10200. /**
  10201. * Sets the photometric scale used to interpret the intensity.
  10202. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10203. */
  10204. intensityMode: number;
  10205. private _radius;
  10206. /**
  10207. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10208. */
  10209. /**
  10210. * sets the light radius used by PBR Materials to simulate soft area lights.
  10211. */
  10212. radius: number;
  10213. private _renderPriority;
  10214. /**
  10215. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10216. * exceeding the number allowed of the materials.
  10217. */
  10218. renderPriority: number;
  10219. private _shadowEnabled;
  10220. /**
  10221. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10222. * the current shadow generator.
  10223. */
  10224. /**
  10225. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10226. * the current shadow generator.
  10227. */
  10228. shadowEnabled: boolean;
  10229. private _includedOnlyMeshes;
  10230. /**
  10231. * Gets the only meshes impacted by this light.
  10232. */
  10233. /**
  10234. * Sets the only meshes impacted by this light.
  10235. */
  10236. includedOnlyMeshes: AbstractMesh[];
  10237. private _excludedMeshes;
  10238. /**
  10239. * Gets the meshes not impacted by this light.
  10240. */
  10241. /**
  10242. * Sets the meshes not impacted by this light.
  10243. */
  10244. excludedMeshes: AbstractMesh[];
  10245. private _excludeWithLayerMask;
  10246. /**
  10247. * Gets the layer id use to find what meshes are not impacted by the light.
  10248. * Inactive if 0
  10249. */
  10250. /**
  10251. * Sets the layer id use to find what meshes are not impacted by the light.
  10252. * Inactive if 0
  10253. */
  10254. excludeWithLayerMask: number;
  10255. private _includeOnlyWithLayerMask;
  10256. /**
  10257. * Gets the layer id use to find what meshes are impacted by the light.
  10258. * Inactive if 0
  10259. */
  10260. /**
  10261. * Sets the layer id use to find what meshes are impacted by the light.
  10262. * Inactive if 0
  10263. */
  10264. includeOnlyWithLayerMask: number;
  10265. private _lightmapMode;
  10266. /**
  10267. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10268. */
  10269. /**
  10270. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10271. */
  10272. lightmapMode: number;
  10273. /**
  10274. * Shadow generator associted to the light.
  10275. * @hidden Internal use only.
  10276. */
  10277. _shadowGenerator: Nullable<IShadowGenerator>;
  10278. /**
  10279. * @hidden Internal use only.
  10280. */
  10281. _excludedMeshesIds: string[];
  10282. /**
  10283. * @hidden Internal use only.
  10284. */
  10285. _includedOnlyMeshesIds: string[];
  10286. /**
  10287. * The current light unifom buffer.
  10288. * @hidden Internal use only.
  10289. */
  10290. _uniformBuffer: UniformBuffer;
  10291. /**
  10292. * Creates a Light object in the scene.
  10293. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10294. * @param name The firendly name of the light
  10295. * @param scene The scene the light belongs too
  10296. */
  10297. constructor(name: string, scene: Scene);
  10298. protected abstract _buildUniformLayout(): void;
  10299. /**
  10300. * Sets the passed Effect "effect" with the Light information.
  10301. * @param effect The effect to update
  10302. * @param lightIndex The index of the light in the effect to update
  10303. * @returns The light
  10304. */
  10305. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10306. /**
  10307. * Returns the string "Light".
  10308. * @returns the class name
  10309. */
  10310. getClassName(): string;
  10311. /** @hidden */
  10312. readonly _isLight: boolean;
  10313. /**
  10314. * Converts the light information to a readable string for debug purpose.
  10315. * @param fullDetails Supports for multiple levels of logging within scene loading
  10316. * @returns the human readable light info
  10317. */
  10318. toString(fullDetails?: boolean): string;
  10319. /** @hidden */
  10320. protected _syncParentEnabledState(): void;
  10321. /**
  10322. * Set the enabled state of this node.
  10323. * @param value - the new enabled state
  10324. */
  10325. setEnabled(value: boolean): void;
  10326. /**
  10327. * Returns the Light associated shadow generator if any.
  10328. * @return the associated shadow generator.
  10329. */
  10330. getShadowGenerator(): Nullable<IShadowGenerator>;
  10331. /**
  10332. * Returns a Vector3, the absolute light position in the World.
  10333. * @returns the world space position of the light
  10334. */
  10335. getAbsolutePosition(): Vector3;
  10336. /**
  10337. * Specifies if the light will affect the passed mesh.
  10338. * @param mesh The mesh to test against the light
  10339. * @return true the mesh is affected otherwise, false.
  10340. */
  10341. canAffectMesh(mesh: AbstractMesh): boolean;
  10342. /**
  10343. * Sort function to order lights for rendering.
  10344. * @param a First Light object to compare to second.
  10345. * @param b Second Light object to compare first.
  10346. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10347. */
  10348. static CompareLightsPriority(a: Light, b: Light): number;
  10349. /**
  10350. * Releases resources associated with this node.
  10351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10353. */
  10354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10355. /**
  10356. * Returns the light type ID (integer).
  10357. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10358. */
  10359. getTypeID(): number;
  10360. /**
  10361. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10362. * @returns the scaled intensity in intensity mode unit
  10363. */
  10364. getScaledIntensity(): number;
  10365. /**
  10366. * Returns a new Light object, named "name", from the current one.
  10367. * @param name The name of the cloned light
  10368. * @returns the new created light
  10369. */
  10370. clone(name: string): Nullable<Light>;
  10371. /**
  10372. * Serializes the current light into a Serialization object.
  10373. * @returns the serialized object.
  10374. */
  10375. serialize(): any;
  10376. /**
  10377. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10378. * This new light is named "name" and added to the passed scene.
  10379. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10380. * @param name The friendly name of the light
  10381. * @param scene The scene the new light will belong to
  10382. * @returns the constructor function
  10383. */
  10384. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10385. /**
  10386. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10387. * @param parsedLight The JSON representation of the light
  10388. * @param scene The scene to create the parsed light in
  10389. * @returns the created light after parsing
  10390. */
  10391. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10392. private _hookArrayForExcluded;
  10393. private _hookArrayForIncludedOnly;
  10394. private _resyncMeshes;
  10395. /**
  10396. * Forces the meshes to update their light related information in their rendering used effects
  10397. * @hidden Internal Use Only
  10398. */
  10399. _markMeshesAsLightDirty(): void;
  10400. /**
  10401. * Recomputes the cached photometric scale if needed.
  10402. */
  10403. private _computePhotometricScale;
  10404. /**
  10405. * Returns the Photometric Scale according to the light type and intensity mode.
  10406. */
  10407. private _getPhotometricScale;
  10408. /**
  10409. * Reorder the light in the scene according to their defined priority.
  10410. * @hidden Internal Use Only
  10411. */
  10412. _reorderLightsInScene(): void;
  10413. /**
  10414. * Prepares the list of defines specific to the light type.
  10415. * @param defines the list of defines
  10416. * @param lightIndex defines the index of the light for the effect
  10417. */
  10418. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10419. }
  10420. }
  10421. declare module "babylonjs/Actions/action" {
  10422. import { Observable } from "babylonjs/Misc/observable";
  10423. import { Condition } from "babylonjs/Actions/condition";
  10424. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10425. import { ActionManager } from "babylonjs/Actions/actionManager";
  10426. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10427. /**
  10428. * Interface used to define Action
  10429. */
  10430. export interface IAction {
  10431. /**
  10432. * Trigger for the action
  10433. */
  10434. trigger: number;
  10435. /** Options of the trigger */
  10436. triggerOptions: any;
  10437. /**
  10438. * Gets the trigger parameters
  10439. * @returns the trigger parameters
  10440. */
  10441. getTriggerParameter(): any;
  10442. /**
  10443. * Internal only - executes current action event
  10444. * @hidden
  10445. */
  10446. _executeCurrent(evt?: ActionEvent): void;
  10447. /**
  10448. * Serialize placeholder for child classes
  10449. * @param parent of child
  10450. * @returns the serialized object
  10451. */
  10452. serialize(parent: any): any;
  10453. /**
  10454. * Internal only
  10455. * @hidden
  10456. */
  10457. _prepare(): void;
  10458. /**
  10459. * Internal only - manager for action
  10460. * @hidden
  10461. */
  10462. _actionManager: AbstractActionManager;
  10463. }
  10464. /**
  10465. * The action to be carried out following a trigger
  10466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10467. */
  10468. export class Action implements IAction {
  10469. /** the trigger, with or without parameters, for the action */
  10470. triggerOptions: any;
  10471. /**
  10472. * Trigger for the action
  10473. */
  10474. trigger: number;
  10475. /**
  10476. * Internal only - manager for action
  10477. * @hidden
  10478. */
  10479. _actionManager: ActionManager;
  10480. private _nextActiveAction;
  10481. private _child;
  10482. private _condition?;
  10483. private _triggerParameter;
  10484. /**
  10485. * An event triggered prior to action being executed.
  10486. */
  10487. onBeforeExecuteObservable: Observable<Action>;
  10488. /**
  10489. * Creates a new Action
  10490. * @param triggerOptions the trigger, with or without parameters, for the action
  10491. * @param condition an optional determinant of action
  10492. */
  10493. constructor(
  10494. /** the trigger, with or without parameters, for the action */
  10495. triggerOptions: any, condition?: Condition);
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _prepare(): void;
  10501. /**
  10502. * Gets the trigger parameters
  10503. * @returns the trigger parameters
  10504. */
  10505. getTriggerParameter(): any;
  10506. /**
  10507. * Internal only - executes current action event
  10508. * @hidden
  10509. */
  10510. _executeCurrent(evt?: ActionEvent): void;
  10511. /**
  10512. * Execute placeholder for child classes
  10513. * @param evt optional action event
  10514. */
  10515. execute(evt?: ActionEvent): void;
  10516. /**
  10517. * Skips to next active action
  10518. */
  10519. skipToNextActiveAction(): void;
  10520. /**
  10521. * Adds action to chain of actions, may be a DoNothingAction
  10522. * @param action defines the next action to execute
  10523. * @returns The action passed in
  10524. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10525. */
  10526. then(action: Action): Action;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. _getProperty(propertyPath: string): string;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. _getEffectiveTarget(target: any, propertyPath: string): any;
  10537. /**
  10538. * Serialize placeholder for child classes
  10539. * @param parent of child
  10540. * @returns the serialized object
  10541. */
  10542. serialize(parent: any): any;
  10543. /**
  10544. * Internal only called by serialize
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedAction: any, parent?: any): any;
  10548. /**
  10549. * Internal only
  10550. * @hidden
  10551. */
  10552. static _SerializeValueAsString: (value: any) => string;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */
  10557. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10558. name: string;
  10559. targetType: string;
  10560. value: string;
  10561. };
  10562. }
  10563. }
  10564. declare module "babylonjs/Actions/condition" {
  10565. import { ActionManager } from "babylonjs/Actions/actionManager";
  10566. /**
  10567. * A Condition applied to an Action
  10568. */
  10569. export class Condition {
  10570. /**
  10571. * Internal only - manager for action
  10572. * @hidden
  10573. */
  10574. _actionManager: ActionManager;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. _evaluationId: number;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. _currentResult: boolean;
  10585. /**
  10586. * Creates a new Condition
  10587. * @param actionManager the manager of the action the condition is applied to
  10588. */
  10589. constructor(actionManager: ActionManager);
  10590. /**
  10591. * Check if the current condition is valid
  10592. * @returns a boolean
  10593. */
  10594. isValid(): boolean;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. _getProperty(propertyPath: string): string;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. _getEffectiveTarget(target: any, propertyPath: string): any;
  10605. /**
  10606. * Serialize placeholder for child classes
  10607. * @returns the serialized object
  10608. */
  10609. serialize(): any;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. protected _serialize(serializedCondition: any): any;
  10615. }
  10616. /**
  10617. * Defines specific conditional operators as extensions of Condition
  10618. */
  10619. export class ValueCondition extends Condition {
  10620. /** path to specify the property of the target the conditional operator uses */
  10621. propertyPath: string;
  10622. /** the value compared by the conditional operator against the current value of the property */
  10623. value: any;
  10624. /** the conditional operator, default ValueCondition.IsEqual */
  10625. operator: number;
  10626. /**
  10627. * Internal only
  10628. * @hidden
  10629. */
  10630. private static _IsEqual;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. private static _IsDifferent;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. private static _IsGreater;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. private static _IsLesser;
  10646. /**
  10647. * returns the number for IsEqual
  10648. */
  10649. static readonly IsEqual: number;
  10650. /**
  10651. * Returns the number for IsDifferent
  10652. */
  10653. static readonly IsDifferent: number;
  10654. /**
  10655. * Returns the number for IsGreater
  10656. */
  10657. static readonly IsGreater: number;
  10658. /**
  10659. * Returns the number for IsLesser
  10660. */
  10661. static readonly IsLesser: number;
  10662. /**
  10663. * Internal only The action manager for the condition
  10664. * @hidden
  10665. */
  10666. _actionManager: ActionManager;
  10667. /**
  10668. * Internal only
  10669. * @hidden
  10670. */
  10671. private _target;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. private _effectiveTarget;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private _property;
  10682. /**
  10683. * Creates a new ValueCondition
  10684. * @param actionManager manager for the action the condition applies to
  10685. * @param target for the action
  10686. * @param propertyPath path to specify the property of the target the conditional operator uses
  10687. * @param value the value compared by the conditional operator against the current value of the property
  10688. * @param operator the conditional operator, default ValueCondition.IsEqual
  10689. */
  10690. constructor(actionManager: ActionManager, target: any,
  10691. /** path to specify the property of the target the conditional operator uses */
  10692. propertyPath: string,
  10693. /** the value compared by the conditional operator against the current value of the property */
  10694. value: any,
  10695. /** the conditional operator, default ValueCondition.IsEqual */
  10696. operator?: number);
  10697. /**
  10698. * Compares the given value with the property value for the specified conditional operator
  10699. * @returns the result of the comparison
  10700. */
  10701. isValid(): boolean;
  10702. /**
  10703. * Serialize the ValueCondition into a JSON compatible object
  10704. * @returns serialization object
  10705. */
  10706. serialize(): any;
  10707. /**
  10708. * Gets the name of the conditional operator for the ValueCondition
  10709. * @param operator the conditional operator
  10710. * @returns the name
  10711. */
  10712. static GetOperatorName(operator: number): string;
  10713. }
  10714. /**
  10715. * Defines a predicate condition as an extension of Condition
  10716. */
  10717. export class PredicateCondition extends Condition {
  10718. /** defines the predicate function used to validate the condition */
  10719. predicate: () => boolean;
  10720. /**
  10721. * Internal only - manager for action
  10722. * @hidden
  10723. */
  10724. _actionManager: ActionManager;
  10725. /**
  10726. * Creates a new PredicateCondition
  10727. * @param actionManager manager for the action the condition applies to
  10728. * @param predicate defines the predicate function used to validate the condition
  10729. */
  10730. constructor(actionManager: ActionManager,
  10731. /** defines the predicate function used to validate the condition */
  10732. predicate: () => boolean);
  10733. /**
  10734. * @returns the validity of the predicate condition
  10735. */
  10736. isValid(): boolean;
  10737. }
  10738. /**
  10739. * Defines a state condition as an extension of Condition
  10740. */
  10741. export class StateCondition extends Condition {
  10742. /** Value to compare with target state */
  10743. value: string;
  10744. /**
  10745. * Internal only - manager for action
  10746. * @hidden
  10747. */
  10748. _actionManager: ActionManager;
  10749. /**
  10750. * Internal only
  10751. * @hidden
  10752. */
  10753. private _target;
  10754. /**
  10755. * Creates a new StateCondition
  10756. * @param actionManager manager for the action the condition applies to
  10757. * @param target of the condition
  10758. * @param value to compare with target state
  10759. */
  10760. constructor(actionManager: ActionManager, target: any,
  10761. /** Value to compare with target state */
  10762. value: string);
  10763. /**
  10764. * Gets a boolean indicating if the current condition is met
  10765. * @returns the validity of the state
  10766. */
  10767. isValid(): boolean;
  10768. /**
  10769. * Serialize the StateCondition into a JSON compatible object
  10770. * @returns serialization object
  10771. */
  10772. serialize(): any;
  10773. }
  10774. }
  10775. declare module "babylonjs/Actions/directActions" {
  10776. import { Action } from "babylonjs/Actions/action";
  10777. import { Condition } from "babylonjs/Actions/condition";
  10778. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10779. /**
  10780. * This defines an action responsible to toggle a boolean once triggered.
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10782. */
  10783. export class SwitchBooleanAction extends Action {
  10784. /**
  10785. * The path to the boolean property in the target object
  10786. */
  10787. propertyPath: string;
  10788. private _target;
  10789. private _effectiveTarget;
  10790. private _property;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the object containing the boolean
  10795. * @param propertyPath defines the path to the boolean property in the target object
  10796. * @param condition defines the trigger related conditions
  10797. */
  10798. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10799. /** @hidden */
  10800. _prepare(): void;
  10801. /**
  10802. * Execute the action toggle the boolean value.
  10803. */
  10804. execute(): void;
  10805. /**
  10806. * Serializes the actions and its related information.
  10807. * @param parent defines the object to serialize in
  10808. * @returns the serialized object
  10809. */
  10810. serialize(parent: any): any;
  10811. }
  10812. /**
  10813. * This defines an action responsible to set a the state field of the target
  10814. * to a desired value once triggered.
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10816. */
  10817. export class SetStateAction extends Action {
  10818. /**
  10819. * The value to store in the state field.
  10820. */
  10821. value: string;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the object containing the state property
  10827. * @param value defines the value to store in the state field
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10831. /**
  10832. * Execute the action and store the value on the target state property.
  10833. */
  10834. execute(): void;
  10835. /**
  10836. * Serializes the actions and its related information.
  10837. * @param parent defines the object to serialize in
  10838. * @returns the serialized object
  10839. */
  10840. serialize(parent: any): any;
  10841. }
  10842. /**
  10843. * This defines an action responsible to set a property of the target
  10844. * to a desired value once triggered.
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10846. */
  10847. export class SetValueAction extends Action {
  10848. /**
  10849. * The path of the property to set in the target.
  10850. */
  10851. propertyPath: string;
  10852. /**
  10853. * The value to set in the property
  10854. */
  10855. value: any;
  10856. private _target;
  10857. private _effectiveTarget;
  10858. private _property;
  10859. /**
  10860. * Instantiate the action
  10861. * @param triggerOptions defines the trigger options
  10862. * @param target defines the object containing the property
  10863. * @param propertyPath defines the path of the property to set in the target
  10864. * @param value defines the value to set in the property
  10865. * @param condition defines the trigger related conditions
  10866. */
  10867. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10868. /** @hidden */
  10869. _prepare(): void;
  10870. /**
  10871. * Execute the action and set the targetted property to the desired value.
  10872. */
  10873. execute(): void;
  10874. /**
  10875. * Serializes the actions and its related information.
  10876. * @param parent defines the object to serialize in
  10877. * @returns the serialized object
  10878. */
  10879. serialize(parent: any): any;
  10880. }
  10881. /**
  10882. * This defines an action responsible to increment the target value
  10883. * to a desired value once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class IncrementValueAction extends Action {
  10887. /**
  10888. * The path of the property to increment in the target.
  10889. */
  10890. propertyPath: string;
  10891. /**
  10892. * The value we should increment the property by.
  10893. */
  10894. value: any;
  10895. private _target;
  10896. private _effectiveTarget;
  10897. private _property;
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param target defines the object containing the property
  10902. * @param propertyPath defines the path of the property to increment in the target
  10903. * @param value defines the value value we should increment the property by
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and increment the target of the value amount.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible to start an animation once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class PlayAnimationAction extends Action {
  10925. /**
  10926. * Where the animation should start (animation frame)
  10927. */
  10928. from: number;
  10929. /**
  10930. * Where the animation should stop (animation frame)
  10931. */
  10932. to: number;
  10933. /**
  10934. * Define if the animation should loop or stop after the first play.
  10935. */
  10936. loop?: boolean;
  10937. private _target;
  10938. /**
  10939. * Instantiate the action
  10940. * @param triggerOptions defines the trigger options
  10941. * @param target defines the target animation or animation name
  10942. * @param from defines from where the animation should start (animation frame)
  10943. * @param end defines where the animation should stop (animation frame)
  10944. * @param loop defines if the animation should loop or stop after the first play
  10945. * @param condition defines the trigger related conditions
  10946. */
  10947. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10948. /** @hidden */
  10949. _prepare(): void;
  10950. /**
  10951. * Execute the action and play the animation.
  10952. */
  10953. execute(): void;
  10954. /**
  10955. * Serializes the actions and its related information.
  10956. * @param parent defines the object to serialize in
  10957. * @returns the serialized object
  10958. */
  10959. serialize(parent: any): any;
  10960. }
  10961. /**
  10962. * This defines an action responsible to stop an animation once triggered.
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10964. */
  10965. export class StopAnimationAction extends Action {
  10966. private _target;
  10967. /**
  10968. * Instantiate the action
  10969. * @param triggerOptions defines the trigger options
  10970. * @param target defines the target animation or animation name
  10971. * @param condition defines the trigger related conditions
  10972. */
  10973. constructor(triggerOptions: any, target: any, condition?: Condition);
  10974. /** @hidden */
  10975. _prepare(): void;
  10976. /**
  10977. * Execute the action and stop the animation.
  10978. */
  10979. execute(): void;
  10980. /**
  10981. * Serializes the actions and its related information.
  10982. * @param parent defines the object to serialize in
  10983. * @returns the serialized object
  10984. */
  10985. serialize(parent: any): any;
  10986. }
  10987. /**
  10988. * This defines an action responsible that does nothing once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class DoNothingAction extends Action {
  10992. /**
  10993. * Instantiate the action
  10994. * @param triggerOptions defines the trigger options
  10995. * @param condition defines the trigger related conditions
  10996. */
  10997. constructor(triggerOptions?: any, condition?: Condition);
  10998. /**
  10999. * Execute the action and do nothing.
  11000. */
  11001. execute(): void;
  11002. /**
  11003. * Serializes the actions and its related information.
  11004. * @param parent defines the object to serialize in
  11005. * @returns the serialized object
  11006. */
  11007. serialize(parent: any): any;
  11008. }
  11009. /**
  11010. * This defines an action responsible to trigger several actions once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class CombineAction extends Action {
  11014. /**
  11015. * The list of aggregated animations to run.
  11016. */
  11017. children: Action[];
  11018. /**
  11019. * Instantiate the action
  11020. * @param triggerOptions defines the trigger options
  11021. * @param children defines the list of aggregated animations to run
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11025. /** @hidden */
  11026. _prepare(): void;
  11027. /**
  11028. * Execute the action and executes all the aggregated actions.
  11029. */
  11030. execute(evt: ActionEvent): 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 run code (external event) once triggered.
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11041. */
  11042. export class ExecuteCodeAction extends Action {
  11043. /**
  11044. * The callback function to run.
  11045. */
  11046. func: (evt: ActionEvent) => void;
  11047. /**
  11048. * Instantiate the action
  11049. * @param triggerOptions defines the trigger options
  11050. * @param func defines the callback function to run
  11051. * @param condition defines the trigger related conditions
  11052. */
  11053. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11054. /**
  11055. * Execute the action and run the attached code.
  11056. */
  11057. execute(evt: ActionEvent): void;
  11058. }
  11059. /**
  11060. * This defines an action responsible to set the parent property of the target once triggered.
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11062. */
  11063. export class SetParentAction extends Action {
  11064. private _parent;
  11065. private _target;
  11066. /**
  11067. * Instantiate the action
  11068. * @param triggerOptions defines the trigger options
  11069. * @param target defines the target containing the parent property
  11070. * @param parent defines from where the animation should start (animation frame)
  11071. * @param condition defines the trigger related conditions
  11072. */
  11073. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11074. /** @hidden */
  11075. _prepare(): void;
  11076. /**
  11077. * Execute the action and set the parent property.
  11078. */
  11079. execute(): void;
  11080. /**
  11081. * Serializes the actions and its related information.
  11082. * @param parent defines the object to serialize in
  11083. * @returns the serialized object
  11084. */
  11085. serialize(parent: any): any;
  11086. }
  11087. }
  11088. declare module "babylonjs/Actions/actionManager" {
  11089. import { Nullable } from "babylonjs/types";
  11090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11091. import { Scene } from "babylonjs/scene";
  11092. import { IAction } from "babylonjs/Actions/action";
  11093. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11094. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11095. /**
  11096. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11097. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11099. */
  11100. export class ActionManager extends AbstractActionManager {
  11101. /**
  11102. * Nothing
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly NothingTrigger: number;
  11106. /**
  11107. * On pick
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnPickTrigger: number;
  11111. /**
  11112. * On left pick
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnLeftPickTrigger: number;
  11116. /**
  11117. * On right pick
  11118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11119. */
  11120. static readonly OnRightPickTrigger: number;
  11121. /**
  11122. * On center pick
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11124. */
  11125. static readonly OnCenterPickTrigger: number;
  11126. /**
  11127. * On pick down
  11128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11129. */
  11130. static readonly OnPickDownTrigger: number;
  11131. /**
  11132. * On double pick
  11133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11134. */
  11135. static readonly OnDoublePickTrigger: number;
  11136. /**
  11137. * On pick up
  11138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11139. */
  11140. static readonly OnPickUpTrigger: number;
  11141. /**
  11142. * On pick out.
  11143. * This trigger will only be raised if you also declared a OnPickDown
  11144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11145. */
  11146. static readonly OnPickOutTrigger: number;
  11147. /**
  11148. * On long press
  11149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11150. */
  11151. static readonly OnLongPressTrigger: number;
  11152. /**
  11153. * On pointer over
  11154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11155. */
  11156. static readonly OnPointerOverTrigger: number;
  11157. /**
  11158. * On pointer out
  11159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11160. */
  11161. static readonly OnPointerOutTrigger: number;
  11162. /**
  11163. * On every frame
  11164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11165. */
  11166. static readonly OnEveryFrameTrigger: number;
  11167. /**
  11168. * On intersection enter
  11169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11170. */
  11171. static readonly OnIntersectionEnterTrigger: number;
  11172. /**
  11173. * On intersection exit
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11175. */
  11176. static readonly OnIntersectionExitTrigger: number;
  11177. /**
  11178. * On key down
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11180. */
  11181. static readonly OnKeyDownTrigger: number;
  11182. /**
  11183. * On key up
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11185. */
  11186. static readonly OnKeyUpTrigger: number;
  11187. private _scene;
  11188. /**
  11189. * Creates a new action manager
  11190. * @param scene defines the hosting scene
  11191. */
  11192. constructor(scene: Scene);
  11193. /**
  11194. * Releases all associated resources
  11195. */
  11196. dispose(): void;
  11197. /**
  11198. * Gets hosting scene
  11199. * @returns the hosting scene
  11200. */
  11201. getScene(): Scene;
  11202. /**
  11203. * Does this action manager handles actions of any of the given triggers
  11204. * @param triggers defines the triggers to be tested
  11205. * @return a boolean indicating whether one (or more) of the triggers is handled
  11206. */
  11207. hasSpecificTriggers(triggers: number[]): boolean;
  11208. /**
  11209. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11210. * speed.
  11211. * @param triggerA defines the trigger to be tested
  11212. * @param triggerB defines the trigger to be tested
  11213. * @return a boolean indicating whether one (or more) of the triggers is handled
  11214. */
  11215. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11216. /**
  11217. * Does this action manager handles actions of a given trigger
  11218. * @param trigger defines the trigger to be tested
  11219. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11220. * @return whether the trigger is handled
  11221. */
  11222. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11223. /**
  11224. * Does this action manager has pointer triggers
  11225. */
  11226. readonly hasPointerTriggers: boolean;
  11227. /**
  11228. * Does this action manager has pick triggers
  11229. */
  11230. readonly hasPickTriggers: boolean;
  11231. /**
  11232. * Registers an action to this action manager
  11233. * @param action defines the action to be registered
  11234. * @return the action amended (prepared) after registration
  11235. */
  11236. registerAction(action: IAction): Nullable<IAction>;
  11237. /**
  11238. * Unregisters an action to this action manager
  11239. * @param action defines the action to be unregistered
  11240. * @return a boolean indicating whether the action has been unregistered
  11241. */
  11242. unregisterAction(action: IAction): Boolean;
  11243. /**
  11244. * Process a specific trigger
  11245. * @param trigger defines the trigger to process
  11246. * @param evt defines the event details to be processed
  11247. */
  11248. processTrigger(trigger: number, evt?: IActionEvent): void;
  11249. /** @hidden */
  11250. _getEffectiveTarget(target: any, propertyPath: string): any;
  11251. /** @hidden */
  11252. _getProperty(propertyPath: string): string;
  11253. /**
  11254. * Serialize this manager to a JSON object
  11255. * @param name defines the property name to store this manager
  11256. * @returns a JSON representation of this manager
  11257. */
  11258. serialize(name: string): any;
  11259. /**
  11260. * Creates a new ActionManager from a JSON data
  11261. * @param parsedActions defines the JSON data to read from
  11262. * @param object defines the hosting mesh
  11263. * @param scene defines the hosting scene
  11264. */
  11265. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11266. /**
  11267. * Get a trigger name by index
  11268. * @param trigger defines the trigger index
  11269. * @returns a trigger name
  11270. */
  11271. static GetTriggerName(trigger: number): string;
  11272. }
  11273. }
  11274. declare module "babylonjs/Culling/ray" {
  11275. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11276. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11278. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11279. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11280. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11281. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11282. /**
  11283. * Class representing a ray with position and direction
  11284. */
  11285. export class Ray {
  11286. /** origin point */
  11287. origin: Vector3;
  11288. /** direction */
  11289. direction: Vector3;
  11290. /** length of the ray */
  11291. length: number;
  11292. private static readonly TmpVector3;
  11293. private _tmpRay;
  11294. /**
  11295. * Creates a new ray
  11296. * @param origin origin point
  11297. * @param direction direction
  11298. * @param length length of the ray
  11299. */
  11300. constructor(
  11301. /** origin point */
  11302. origin: Vector3,
  11303. /** direction */
  11304. direction: Vector3,
  11305. /** length of the ray */
  11306. length?: number);
  11307. /**
  11308. * Checks if the ray intersects a box
  11309. * @param minimum bound of the box
  11310. * @param maximum bound of the box
  11311. * @param intersectionTreshold extra extend to be added to the box in all direction
  11312. * @returns if the box was hit
  11313. */
  11314. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11315. /**
  11316. * Checks if the ray intersects a box
  11317. * @param box the bounding box to check
  11318. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11319. * @returns if the box was hit
  11320. */
  11321. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11322. /**
  11323. * If the ray hits a sphere
  11324. * @param sphere the bounding sphere to check
  11325. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11326. * @returns true if it hits the sphere
  11327. */
  11328. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11329. /**
  11330. * If the ray hits a triange
  11331. * @param vertex0 triangle vertex
  11332. * @param vertex1 triangle vertex
  11333. * @param vertex2 triangle vertex
  11334. * @returns intersection information if hit
  11335. */
  11336. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11337. /**
  11338. * Checks if ray intersects a plane
  11339. * @param plane the plane to check
  11340. * @returns the distance away it was hit
  11341. */
  11342. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11343. /**
  11344. * Checks if ray intersects a mesh
  11345. * @param mesh the mesh to check
  11346. * @param fastCheck if only the bounding box should checked
  11347. * @returns picking info of the intersecton
  11348. */
  11349. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11350. /**
  11351. * Checks if ray intersects a mesh
  11352. * @param meshes the meshes to check
  11353. * @param fastCheck if only the bounding box should checked
  11354. * @param results array to store result in
  11355. * @returns Array of picking infos
  11356. */
  11357. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11358. private _comparePickingInfo;
  11359. private static smallnum;
  11360. private static rayl;
  11361. /**
  11362. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11363. * @param sega the first point of the segment to test the intersection against
  11364. * @param segb the second point of the segment to test the intersection against
  11365. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11366. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11367. */
  11368. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11369. /**
  11370. * Update the ray from viewport position
  11371. * @param x position
  11372. * @param y y position
  11373. * @param viewportWidth viewport width
  11374. * @param viewportHeight viewport height
  11375. * @param world world matrix
  11376. * @param view view matrix
  11377. * @param projection projection matrix
  11378. * @returns this ray updated
  11379. */
  11380. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11381. /**
  11382. * Creates a ray with origin and direction of 0,0,0
  11383. * @returns the new ray
  11384. */
  11385. static Zero(): Ray;
  11386. /**
  11387. * Creates a new ray from screen space and viewport
  11388. * @param x position
  11389. * @param y y position
  11390. * @param viewportWidth viewport width
  11391. * @param viewportHeight viewport height
  11392. * @param world world matrix
  11393. * @param view view matrix
  11394. * @param projection projection matrix
  11395. * @returns new ray
  11396. */
  11397. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11398. /**
  11399. * 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
  11400. * transformed to the given world matrix.
  11401. * @param origin The origin point
  11402. * @param end The end point
  11403. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11404. * @returns the new ray
  11405. */
  11406. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11407. /**
  11408. * Transforms a ray by a matrix
  11409. * @param ray ray to transform
  11410. * @param matrix matrix to apply
  11411. * @returns the resulting new ray
  11412. */
  11413. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11414. /**
  11415. * Transforms a ray by a matrix
  11416. * @param ray ray to transform
  11417. * @param matrix matrix to apply
  11418. * @param result ray to store result in
  11419. */
  11420. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11421. /**
  11422. * Unproject a ray from screen space to object space
  11423. * @param sourceX defines the screen space x coordinate to use
  11424. * @param sourceY defines the screen space y coordinate to use
  11425. * @param viewportWidth defines the current width of the viewport
  11426. * @param viewportHeight defines the current height of the viewport
  11427. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11428. * @param view defines the view matrix to use
  11429. * @param projection defines the projection matrix to use
  11430. */
  11431. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11432. }
  11433. /**
  11434. * Type used to define predicate used to select faces when a mesh intersection is detected
  11435. */
  11436. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11437. module "babylonjs/scene" {
  11438. interface Scene {
  11439. /** @hidden */
  11440. _tempPickingRay: Nullable<Ray>;
  11441. /** @hidden */
  11442. _cachedRayForTransform: Ray;
  11443. /** @hidden */
  11444. _pickWithRayInverseMatrix: Matrix;
  11445. /** @hidden */
  11446. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11447. /** @hidden */
  11448. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11449. }
  11450. }
  11451. }
  11452. declare module "babylonjs/sceneComponent" {
  11453. import { Scene } from "babylonjs/scene";
  11454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11456. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11457. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11458. import { Nullable } from "babylonjs/types";
  11459. import { Camera } from "babylonjs/Cameras/camera";
  11460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11461. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11462. import { AbstractScene } from "babylonjs/abstractScene";
  11463. /**
  11464. * Groups all the scene component constants in one place to ease maintenance.
  11465. * @hidden
  11466. */
  11467. export class SceneComponentConstants {
  11468. static readonly NAME_EFFECTLAYER: string;
  11469. static readonly NAME_LAYER: string;
  11470. static readonly NAME_LENSFLARESYSTEM: string;
  11471. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11472. static readonly NAME_PARTICLESYSTEM: string;
  11473. static readonly NAME_GAMEPAD: string;
  11474. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11475. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11476. static readonly NAME_DEPTHRENDERER: string;
  11477. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11478. static readonly NAME_SPRITE: string;
  11479. static readonly NAME_OUTLINERENDERER: string;
  11480. static readonly NAME_PROCEDURALTEXTURE: string;
  11481. static readonly NAME_SHADOWGENERATOR: string;
  11482. static readonly NAME_OCTREE: string;
  11483. static readonly NAME_PHYSICSENGINE: string;
  11484. static readonly NAME_AUDIO: string;
  11485. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11486. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11487. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11488. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11489. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11490. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11491. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11492. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11493. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11494. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11495. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11496. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11497. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11498. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11499. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11500. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11501. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11502. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11503. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11504. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11505. static readonly STEP_AFTERRENDER_AUDIO: number;
  11506. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11507. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11508. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11509. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11510. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11511. static readonly STEP_POINTERMOVE_SPRITE: number;
  11512. static readonly STEP_POINTERDOWN_SPRITE: number;
  11513. static readonly STEP_POINTERUP_SPRITE: number;
  11514. }
  11515. /**
  11516. * This represents a scene component.
  11517. *
  11518. * This is used to decouple the dependency the scene is having on the different workloads like
  11519. * layers, post processes...
  11520. */
  11521. export interface ISceneComponent {
  11522. /**
  11523. * The name of the component. Each component must have a unique name.
  11524. */
  11525. name: string;
  11526. /**
  11527. * The scene the component belongs to.
  11528. */
  11529. scene: Scene;
  11530. /**
  11531. * Register the component to one instance of a scene.
  11532. */
  11533. register(): void;
  11534. /**
  11535. * Rebuilds the elements related to this component in case of
  11536. * context lost for instance.
  11537. */
  11538. rebuild(): void;
  11539. /**
  11540. * Disposes the component and the associated ressources.
  11541. */
  11542. dispose(): void;
  11543. }
  11544. /**
  11545. * This represents a SERIALIZABLE scene component.
  11546. *
  11547. * This extends Scene Component to add Serialization methods on top.
  11548. */
  11549. export interface ISceneSerializableComponent extends ISceneComponent {
  11550. /**
  11551. * Adds all the element from the container to the scene
  11552. * @param container the container holding the elements
  11553. */
  11554. addFromContainer(container: AbstractScene): void;
  11555. /**
  11556. * Removes all the elements in the container from the scene
  11557. * @param container contains the elements to remove
  11558. */
  11559. removeFromContainer(container: AbstractScene): void;
  11560. /**
  11561. * Serializes the component data to the specified json object
  11562. * @param serializationObject The object to serialize to
  11563. */
  11564. serialize(serializationObject: any): void;
  11565. }
  11566. /**
  11567. * Strong typing of a Mesh related stage step action
  11568. */
  11569. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11570. /**
  11571. * Strong typing of a Evaluate Sub Mesh related stage step action
  11572. */
  11573. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11574. /**
  11575. * Strong typing of a Active Mesh related stage step action
  11576. */
  11577. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11578. /**
  11579. * Strong typing of a Camera related stage step action
  11580. */
  11581. export type CameraStageAction = (camera: Camera) => void;
  11582. /**
  11583. * Strong typing of a Render Target related stage step action
  11584. */
  11585. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11586. /**
  11587. * Strong typing of a RenderingGroup related stage step action
  11588. */
  11589. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11590. /**
  11591. * Strong typing of a Mesh Render related stage step action
  11592. */
  11593. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11594. /**
  11595. * Strong typing of a simple stage step action
  11596. */
  11597. export type SimpleStageAction = () => void;
  11598. /**
  11599. * Strong typing of a render target action.
  11600. */
  11601. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11602. /**
  11603. * Strong typing of a pointer move action.
  11604. */
  11605. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11606. /**
  11607. * Strong typing of a pointer up/down action.
  11608. */
  11609. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11610. /**
  11611. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11612. * @hidden
  11613. */
  11614. export class Stage<T extends Function> extends Array<{
  11615. index: number;
  11616. component: ISceneComponent;
  11617. action: T;
  11618. }> {
  11619. /**
  11620. * Hide ctor from the rest of the world.
  11621. * @param items The items to add.
  11622. */
  11623. private constructor();
  11624. /**
  11625. * Creates a new Stage.
  11626. * @returns A new instance of a Stage
  11627. */
  11628. static Create<T extends Function>(): Stage<T>;
  11629. /**
  11630. * Registers a step in an ordered way in the targeted stage.
  11631. * @param index Defines the position to register the step in
  11632. * @param component Defines the component attached to the step
  11633. * @param action Defines the action to launch during the step
  11634. */
  11635. registerStep(index: number, component: ISceneComponent, action: T): void;
  11636. /**
  11637. * Clears all the steps from the stage.
  11638. */
  11639. clear(): void;
  11640. }
  11641. }
  11642. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11643. import { Nullable } from "babylonjs/types";
  11644. import { Observable } from "babylonjs/Misc/observable";
  11645. import { Scene } from "babylonjs/scene";
  11646. import { Sprite } from "babylonjs/Sprites/sprite";
  11647. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. import { Camera } from "babylonjs/Cameras/camera";
  11650. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11651. import { ISceneComponent } from "babylonjs/sceneComponent";
  11652. module "babylonjs/scene" {
  11653. interface Scene {
  11654. /** @hidden */
  11655. _pointerOverSprite: Nullable<Sprite>;
  11656. /** @hidden */
  11657. _pickedDownSprite: Nullable<Sprite>;
  11658. /** @hidden */
  11659. _tempSpritePickingRay: Nullable<Ray>;
  11660. /**
  11661. * All of the sprite managers added to this scene
  11662. * @see http://doc.babylonjs.com/babylon101/sprites
  11663. */
  11664. spriteManagers: Array<ISpriteManager>;
  11665. /**
  11666. * An event triggered when sprites rendering is about to start
  11667. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11668. */
  11669. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11670. /**
  11671. * An event triggered when sprites rendering is done
  11672. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11673. */
  11674. onAfterSpritesRenderingObservable: Observable<Scene>;
  11675. /** @hidden */
  11676. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11677. /** Launch a ray to try to pick a sprite in the scene
  11678. * @param x position on screen
  11679. * @param y position on screen
  11680. * @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
  11681. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11682. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11683. * @returns a PickingInfo
  11684. */
  11685. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11686. /** Use the given ray to pick a sprite in the scene
  11687. * @param ray The ray (in world space) to use to pick meshes
  11688. * @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
  11689. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11690. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11691. * @returns a PickingInfo
  11692. */
  11693. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11694. /**
  11695. * Force the sprite under the pointer
  11696. * @param sprite defines the sprite to use
  11697. */
  11698. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11699. /**
  11700. * Gets the sprite under the pointer
  11701. * @returns a Sprite or null if no sprite is under the pointer
  11702. */
  11703. getPointerOverSprite(): Nullable<Sprite>;
  11704. }
  11705. }
  11706. /**
  11707. * Defines the sprite scene component responsible to manage sprites
  11708. * in a given scene.
  11709. */
  11710. export class SpriteSceneComponent implements ISceneComponent {
  11711. /**
  11712. * The component name helpfull to identify the component in the list of scene components.
  11713. */
  11714. readonly name: string;
  11715. /**
  11716. * The scene the component belongs to.
  11717. */
  11718. scene: Scene;
  11719. /** @hidden */
  11720. private _spritePredicate;
  11721. /**
  11722. * Creates a new instance of the component for the given scene
  11723. * @param scene Defines the scene to register the component in
  11724. */
  11725. constructor(scene: Scene);
  11726. /**
  11727. * Registers the component in a given scene
  11728. */
  11729. register(): void;
  11730. /**
  11731. * Rebuilds the elements related to this component in case of
  11732. * context lost for instance.
  11733. */
  11734. rebuild(): void;
  11735. /**
  11736. * Disposes the component and the associated ressources.
  11737. */
  11738. dispose(): void;
  11739. private _pickSpriteButKeepRay;
  11740. private _pointerMove;
  11741. private _pointerDown;
  11742. private _pointerUp;
  11743. }
  11744. }
  11745. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11746. /** @hidden */
  11747. export var fogFragmentDeclaration: {
  11748. name: string;
  11749. shader: string;
  11750. };
  11751. }
  11752. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11753. /** @hidden */
  11754. export var fogFragment: {
  11755. name: string;
  11756. shader: string;
  11757. };
  11758. }
  11759. declare module "babylonjs/Shaders/sprites.fragment" {
  11760. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11761. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11762. /** @hidden */
  11763. export var spritesPixelShader: {
  11764. name: string;
  11765. shader: string;
  11766. };
  11767. }
  11768. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11769. /** @hidden */
  11770. export var fogVertexDeclaration: {
  11771. name: string;
  11772. shader: string;
  11773. };
  11774. }
  11775. declare module "babylonjs/Shaders/sprites.vertex" {
  11776. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11777. /** @hidden */
  11778. export var spritesVertexShader: {
  11779. name: string;
  11780. shader: string;
  11781. };
  11782. }
  11783. declare module "babylonjs/Sprites/spriteManager" {
  11784. import { IDisposable, Scene } from "babylonjs/scene";
  11785. import { Nullable } from "babylonjs/types";
  11786. import { Observable } from "babylonjs/Misc/observable";
  11787. import { Sprite } from "babylonjs/Sprites/sprite";
  11788. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11789. import { Camera } from "babylonjs/Cameras/camera";
  11790. import { Texture } from "babylonjs/Materials/Textures/texture";
  11791. import "babylonjs/Shaders/sprites.fragment";
  11792. import "babylonjs/Shaders/sprites.vertex";
  11793. import { Ray } from "babylonjs/Culling/ray";
  11794. /**
  11795. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11796. */
  11797. export interface ISpriteManager extends IDisposable {
  11798. /**
  11799. * Restricts the camera to viewing objects with the same layerMask.
  11800. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11801. */
  11802. layerMask: number;
  11803. /**
  11804. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11805. */
  11806. isPickable: boolean;
  11807. /**
  11808. * Specifies the rendering group id for this mesh (0 by default)
  11809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11810. */
  11811. renderingGroupId: number;
  11812. /**
  11813. * Defines the list of sprites managed by the manager.
  11814. */
  11815. sprites: Array<Sprite>;
  11816. /**
  11817. * Tests the intersection of a sprite with a specific ray.
  11818. * @param ray The ray we are sending to test the collision
  11819. * @param camera The camera space we are sending rays in
  11820. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11821. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11822. * @returns picking info or null.
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Renders the list of sprites on screen.
  11827. */
  11828. render(): void;
  11829. }
  11830. /**
  11831. * Class used to manage multiple sprites on the same spritesheet
  11832. * @see http://doc.babylonjs.com/babylon101/sprites
  11833. */
  11834. export class SpriteManager implements ISpriteManager {
  11835. /** defines the manager's name */
  11836. name: string;
  11837. /** Gets the list of sprites */
  11838. sprites: Sprite[];
  11839. /** Gets or sets the rendering group id (0 by default) */
  11840. renderingGroupId: number;
  11841. /** Gets or sets camera layer mask */
  11842. layerMask: number;
  11843. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11844. fogEnabled: boolean;
  11845. /** Gets or sets a boolean indicating if the sprites are pickable */
  11846. isPickable: boolean;
  11847. /** Defines the default width of a cell in the spritesheet */
  11848. cellWidth: number;
  11849. /** Defines the default height of a cell in the spritesheet */
  11850. cellHeight: number;
  11851. /**
  11852. * An event triggered when the manager is disposed.
  11853. */
  11854. onDisposeObservable: Observable<SpriteManager>;
  11855. private _onDisposeObserver;
  11856. /**
  11857. * Callback called when the manager is disposed
  11858. */
  11859. onDispose: () => void;
  11860. private _capacity;
  11861. private _spriteTexture;
  11862. private _epsilon;
  11863. private _scene;
  11864. private _vertexData;
  11865. private _buffer;
  11866. private _vertexBuffers;
  11867. private _indexBuffer;
  11868. private _effectBase;
  11869. private _effectFog;
  11870. /**
  11871. * Gets or sets the spritesheet texture
  11872. */
  11873. texture: Texture;
  11874. /**
  11875. * Creates a new sprite manager
  11876. * @param name defines the manager's name
  11877. * @param imgUrl defines the sprite sheet url
  11878. * @param capacity defines the maximum allowed number of sprites
  11879. * @param cellSize defines the size of a sprite cell
  11880. * @param scene defines the hosting scene
  11881. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11882. * @param samplingMode defines the smapling mode to use with spritesheet
  11883. */
  11884. constructor(
  11885. /** defines the manager's name */
  11886. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11887. private _appendSpriteVertex;
  11888. /**
  11889. * Intersects the sprites with a ray
  11890. * @param ray defines the ray to intersect with
  11891. * @param camera defines the current active camera
  11892. * @param predicate defines a predicate used to select candidate sprites
  11893. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11894. * @returns null if no hit or a PickingInfo
  11895. */
  11896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11897. /**
  11898. * Render all child sprites
  11899. */
  11900. render(): void;
  11901. /**
  11902. * Release associated resources
  11903. */
  11904. dispose(): void;
  11905. }
  11906. }
  11907. declare module "babylonjs/Sprites/sprite" {
  11908. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11909. import { Nullable } from "babylonjs/types";
  11910. import { ActionManager } from "babylonjs/Actions/actionManager";
  11911. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11912. /**
  11913. * Class used to represent a sprite
  11914. * @see http://doc.babylonjs.com/babylon101/sprites
  11915. */
  11916. export class Sprite {
  11917. /** defines the name */
  11918. name: string;
  11919. /** Gets or sets the current world position */
  11920. position: Vector3;
  11921. /** Gets or sets the main color */
  11922. color: Color4;
  11923. /** Gets or sets the width */
  11924. width: number;
  11925. /** Gets or sets the height */
  11926. height: number;
  11927. /** Gets or sets rotation angle */
  11928. angle: number;
  11929. /** Gets or sets the cell index in the sprite sheet */
  11930. cellIndex: number;
  11931. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11932. invertU: number;
  11933. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11934. invertV: number;
  11935. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11936. disposeWhenFinishedAnimating: boolean;
  11937. /** Gets the list of attached animations */
  11938. animations: Animation[];
  11939. /** Gets or sets a boolean indicating if the sprite can be picked */
  11940. isPickable: boolean;
  11941. /**
  11942. * Gets or sets the associated action manager
  11943. */
  11944. actionManager: Nullable<ActionManager>;
  11945. private _animationStarted;
  11946. private _loopAnimation;
  11947. private _fromIndex;
  11948. private _toIndex;
  11949. private _delay;
  11950. private _direction;
  11951. private _manager;
  11952. private _time;
  11953. private _onAnimationEnd;
  11954. /**
  11955. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11956. */
  11957. isVisible: boolean;
  11958. /**
  11959. * Gets or sets the sprite size
  11960. */
  11961. size: number;
  11962. /**
  11963. * Creates a new Sprite
  11964. * @param name defines the name
  11965. * @param manager defines the manager
  11966. */
  11967. constructor(
  11968. /** defines the name */
  11969. name: string, manager: ISpriteManager);
  11970. /**
  11971. * Starts an animation
  11972. * @param from defines the initial key
  11973. * @param to defines the end key
  11974. * @param loop defines if the animation must loop
  11975. * @param delay defines the start delay (in ms)
  11976. * @param onAnimationEnd defines a callback to call when animation ends
  11977. */
  11978. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11979. /** Stops current animation (if any) */
  11980. stopAnimation(): void;
  11981. /** @hidden */
  11982. _animate(deltaTime: number): void;
  11983. /** Release associated resources */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module "babylonjs/Collisions/pickingInfo" {
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11991. import { Sprite } from "babylonjs/Sprites/sprite";
  11992. import { Ray } from "babylonjs/Culling/ray";
  11993. /**
  11994. * Information about the result of picking within a scene
  11995. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11996. */
  11997. export class PickingInfo {
  11998. /** @hidden */
  11999. _pickingUnavailable: boolean;
  12000. /**
  12001. * If the pick collided with an object
  12002. */
  12003. hit: boolean;
  12004. /**
  12005. * Distance away where the pick collided
  12006. */
  12007. distance: number;
  12008. /**
  12009. * The location of pick collision
  12010. */
  12011. pickedPoint: Nullable<Vector3>;
  12012. /**
  12013. * The mesh corresponding the the pick collision
  12014. */
  12015. pickedMesh: Nullable<AbstractMesh>;
  12016. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12017. bu: number;
  12018. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12019. bv: number;
  12020. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12021. faceId: number;
  12022. /** Id of the the submesh that was picked */
  12023. subMeshId: number;
  12024. /** If a sprite was picked, this will be the sprite the pick collided with */
  12025. pickedSprite: Nullable<Sprite>;
  12026. /**
  12027. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12028. */
  12029. originMesh: Nullable<AbstractMesh>;
  12030. /**
  12031. * The ray that was used to perform the picking.
  12032. */
  12033. ray: Nullable<Ray>;
  12034. /**
  12035. * Gets the normal correspodning to the face the pick collided with
  12036. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12037. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12038. * @returns The normal correspodning to the face the pick collided with
  12039. */
  12040. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12041. /**
  12042. * Gets the texture coordinates of where the pick occured
  12043. * @returns the vector containing the coordnates of the texture
  12044. */
  12045. getTextureCoordinates(): Nullable<Vector2>;
  12046. }
  12047. }
  12048. declare module "babylonjs/Events/pointerEvents" {
  12049. import { Nullable } from "babylonjs/types";
  12050. import { Vector2 } from "babylonjs/Maths/math";
  12051. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12052. import { Ray } from "babylonjs/Culling/ray";
  12053. /**
  12054. * Gather the list of pointer event types as constants.
  12055. */
  12056. export class PointerEventTypes {
  12057. /**
  12058. * 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.
  12059. */
  12060. static readonly POINTERDOWN: number;
  12061. /**
  12062. * The pointerup event is fired when a pointer is no longer active.
  12063. */
  12064. static readonly POINTERUP: number;
  12065. /**
  12066. * The pointermove event is fired when a pointer changes coordinates.
  12067. */
  12068. static readonly POINTERMOVE: number;
  12069. /**
  12070. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12071. */
  12072. static readonly POINTERWHEEL: number;
  12073. /**
  12074. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12075. */
  12076. static readonly POINTERPICK: number;
  12077. /**
  12078. * The pointertap event is fired when a the object has been touched and released without drag.
  12079. */
  12080. static readonly POINTERTAP: number;
  12081. /**
  12082. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12083. */
  12084. static readonly POINTERDOUBLETAP: number;
  12085. }
  12086. /**
  12087. * Base class of pointer info types.
  12088. */
  12089. export class PointerInfoBase {
  12090. /**
  12091. * Defines the type of event (PointerEventTypes)
  12092. */
  12093. type: number;
  12094. /**
  12095. * Defines the related dom event
  12096. */
  12097. event: PointerEvent | MouseWheelEvent;
  12098. /**
  12099. * Instantiates the base class of pointers info.
  12100. * @param type Defines the type of event (PointerEventTypes)
  12101. * @param event Defines the related dom event
  12102. */
  12103. constructor(
  12104. /**
  12105. * Defines the type of event (PointerEventTypes)
  12106. */
  12107. type: number,
  12108. /**
  12109. * Defines the related dom event
  12110. */
  12111. event: PointerEvent | MouseWheelEvent);
  12112. }
  12113. /**
  12114. * This class is used to store pointer related info for the onPrePointerObservable event.
  12115. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12116. */
  12117. export class PointerInfoPre extends PointerInfoBase {
  12118. /**
  12119. * Ray from a pointer if availible (eg. 6dof controller)
  12120. */
  12121. ray: Nullable<Ray>;
  12122. /**
  12123. * Defines the local position of the pointer on the canvas.
  12124. */
  12125. localPosition: Vector2;
  12126. /**
  12127. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12128. */
  12129. skipOnPointerObservable: boolean;
  12130. /**
  12131. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12132. * @param type Defines the type of event (PointerEventTypes)
  12133. * @param event Defines the related dom event
  12134. * @param localX Defines the local x coordinates of the pointer when the event occured
  12135. * @param localY Defines the local y coordinates of the pointer when the event occured
  12136. */
  12137. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12138. }
  12139. /**
  12140. * This type contains all the data related to a pointer event in Babylon.js.
  12141. * 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.
  12142. */
  12143. export class PointerInfo extends PointerInfoBase {
  12144. /**
  12145. * Defines the picking info associated to the info (if any)\
  12146. */
  12147. pickInfo: Nullable<PickingInfo>;
  12148. /**
  12149. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12150. * @param type Defines the type of event (PointerEventTypes)
  12151. * @param event Defines the related dom event
  12152. * @param pickInfo Defines the picking info associated to the info (if any)\
  12153. */
  12154. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12155. /**
  12156. * Defines the picking info associated to the info (if any)\
  12157. */
  12158. pickInfo: Nullable<PickingInfo>);
  12159. }
  12160. /**
  12161. * Data relating to a touch event on the screen.
  12162. */
  12163. export interface PointerTouch {
  12164. /**
  12165. * X coordinate of touch.
  12166. */
  12167. x: number;
  12168. /**
  12169. * Y coordinate of touch.
  12170. */
  12171. y: number;
  12172. /**
  12173. * Id of touch. Unique for each finger.
  12174. */
  12175. pointerId: number;
  12176. /**
  12177. * Event type passed from DOM.
  12178. */
  12179. type: any;
  12180. }
  12181. }
  12182. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12183. import { Nullable } from "babylonjs/types";
  12184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12186. /**
  12187. * Manage the mouse inputs to control the movement of a free camera.
  12188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12189. */
  12190. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12191. /**
  12192. * Define if touch is enabled in the mouse input
  12193. */
  12194. touchEnabled: boolean;
  12195. /**
  12196. * Defines the camera the input is attached to.
  12197. */
  12198. camera: FreeCamera;
  12199. /**
  12200. * Defines the buttons associated with the input to handle camera move.
  12201. */
  12202. buttons: number[];
  12203. /**
  12204. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12205. */
  12206. angularSensibility: number;
  12207. private _pointerInput;
  12208. private _onMouseMove;
  12209. private _observer;
  12210. private previousPosition;
  12211. /**
  12212. * Manage the mouse inputs to control the movement of a free camera.
  12213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12214. * @param touchEnabled Defines if touch is enabled or not
  12215. */
  12216. constructor(
  12217. /**
  12218. * Define if touch is enabled in the mouse input
  12219. */
  12220. touchEnabled?: boolean);
  12221. /**
  12222. * Attach the input controls to a specific dom element to get the input from.
  12223. * @param element Defines the element the controls should be listened from
  12224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12225. */
  12226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12227. /**
  12228. * Called on JS contextmenu event.
  12229. * Override this method to provide functionality.
  12230. */
  12231. protected onContextMenu(evt: PointerEvent): void;
  12232. /**
  12233. * Detach the current controls from the specified dom element.
  12234. * @param element Defines the element to stop listening the inputs from
  12235. */
  12236. detachControl(element: Nullable<HTMLElement>): void;
  12237. /**
  12238. * Gets the class name of the current intput.
  12239. * @returns the class name
  12240. */
  12241. getClassName(): string;
  12242. /**
  12243. * Get the friendly name associated with the input class.
  12244. * @returns the input friendly name
  12245. */
  12246. getSimpleName(): string;
  12247. }
  12248. }
  12249. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12250. import { Nullable } from "babylonjs/types";
  12251. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12253. /**
  12254. * Manage the touch inputs to control the movement of a free camera.
  12255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12256. */
  12257. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12258. /**
  12259. * Defines the camera the input is attached to.
  12260. */
  12261. camera: FreeCamera;
  12262. /**
  12263. * Defines the touch sensibility for rotation.
  12264. * The higher the faster.
  12265. */
  12266. touchAngularSensibility: number;
  12267. /**
  12268. * Defines the touch sensibility for move.
  12269. * The higher the faster.
  12270. */
  12271. touchMoveSensibility: number;
  12272. private _offsetX;
  12273. private _offsetY;
  12274. private _pointerPressed;
  12275. private _pointerInput;
  12276. private _observer;
  12277. private _onLostFocus;
  12278. /**
  12279. * Attach the input controls to a specific dom element to get the input from.
  12280. * @param element Defines the element the controls should be listened from
  12281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12282. */
  12283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12284. /**
  12285. * Detach the current controls from the specified dom element.
  12286. * @param element Defines the element to stop listening the inputs from
  12287. */
  12288. detachControl(element: Nullable<HTMLElement>): void;
  12289. /**
  12290. * Update the current camera state depending on the inputs that have been used this frame.
  12291. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12292. */
  12293. checkInputs(): void;
  12294. /**
  12295. * Gets the class name of the current intput.
  12296. * @returns the class name
  12297. */
  12298. getClassName(): string;
  12299. /**
  12300. * Get the friendly name associated with the input class.
  12301. * @returns the input friendly name
  12302. */
  12303. getSimpleName(): string;
  12304. }
  12305. }
  12306. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12307. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12308. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12309. /**
  12310. * Default Inputs manager for the FreeCamera.
  12311. * It groups all the default supported inputs for ease of use.
  12312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12313. */
  12314. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12315. /**
  12316. * Instantiates a new FreeCameraInputsManager.
  12317. * @param camera Defines the camera the inputs belong to
  12318. */
  12319. constructor(camera: FreeCamera);
  12320. /**
  12321. * Add keyboard input support to the input manager.
  12322. * @returns the current input manager
  12323. */
  12324. addKeyboard(): FreeCameraInputsManager;
  12325. /**
  12326. * Add mouse input support to the input manager.
  12327. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12328. * @returns the current input manager
  12329. */
  12330. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12331. /**
  12332. * Add touch input support to the input manager.
  12333. * @returns the current input manager
  12334. */
  12335. addTouch(): FreeCameraInputsManager;
  12336. }
  12337. }
  12338. declare module "babylonjs/Cameras/freeCamera" {
  12339. import { Vector3 } from "babylonjs/Maths/math";
  12340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12341. import { Scene } from "babylonjs/scene";
  12342. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12343. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12344. /**
  12345. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12346. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12347. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12348. */
  12349. export class FreeCamera extends TargetCamera {
  12350. /**
  12351. * Define the collision ellipsoid of the camera.
  12352. * This is helpful to simulate a camera body like the player body around the camera
  12353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12354. */
  12355. ellipsoid: Vector3;
  12356. /**
  12357. * Define an offset for the position of the ellipsoid around the camera.
  12358. * This can be helpful to determine the center of the body near the gravity center of the body
  12359. * instead of its head.
  12360. */
  12361. ellipsoidOffset: Vector3;
  12362. /**
  12363. * Enable or disable collisions of the camera with the rest of the scene objects.
  12364. */
  12365. checkCollisions: boolean;
  12366. /**
  12367. * Enable or disable gravity on the camera.
  12368. */
  12369. applyGravity: boolean;
  12370. /**
  12371. * Define the input manager associated to the camera.
  12372. */
  12373. inputs: FreeCameraInputsManager;
  12374. /**
  12375. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12376. * Higher values reduce sensitivity.
  12377. */
  12378. /**
  12379. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12380. * Higher values reduce sensitivity.
  12381. */
  12382. angularSensibility: number;
  12383. /**
  12384. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12385. */
  12386. keysUp: number[];
  12387. /**
  12388. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12389. */
  12390. keysDown: number[];
  12391. /**
  12392. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12393. */
  12394. keysLeft: number[];
  12395. /**
  12396. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12397. */
  12398. keysRight: number[];
  12399. /**
  12400. * Event raised when the camera collide with a mesh in the scene.
  12401. */
  12402. onCollide: (collidedMesh: AbstractMesh) => void;
  12403. private _collider;
  12404. private _needMoveForGravity;
  12405. private _oldPosition;
  12406. private _diffPosition;
  12407. private _newPosition;
  12408. /** @hidden */
  12409. _localDirection: Vector3;
  12410. /** @hidden */
  12411. _transformedDirection: Vector3;
  12412. /**
  12413. * Instantiates a Free Camera.
  12414. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12415. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12417. * @param name Define the name of the camera in the scene
  12418. * @param position Define the start position of the camera in the scene
  12419. * @param scene Define the scene the camera belongs to
  12420. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12421. */
  12422. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12423. /**
  12424. * Attached controls to the current camera.
  12425. * @param element Defines the element the controls should be listened from
  12426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12427. */
  12428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12429. /**
  12430. * Detach the current controls from the camera.
  12431. * The camera will stop reacting to inputs.
  12432. * @param element Defines the element to stop listening the inputs from
  12433. */
  12434. detachControl(element: HTMLElement): void;
  12435. private _collisionMask;
  12436. /**
  12437. * Define a collision mask to limit the list of object the camera can collide with
  12438. */
  12439. collisionMask: number;
  12440. /** @hidden */
  12441. _collideWithWorld(displacement: Vector3): void;
  12442. private _onCollisionPositionChange;
  12443. /** @hidden */
  12444. _checkInputs(): void;
  12445. /** @hidden */
  12446. _decideIfNeedsToMove(): boolean;
  12447. /** @hidden */
  12448. _updatePosition(): void;
  12449. /**
  12450. * Destroy the camera and release the current resources hold by it.
  12451. */
  12452. dispose(): void;
  12453. /**
  12454. * Gets the current object class name.
  12455. * @return the class name
  12456. */
  12457. getClassName(): string;
  12458. }
  12459. }
  12460. declare module "babylonjs/Gamepads/gamepad" {
  12461. import { Observable } from "babylonjs/Misc/observable";
  12462. /**
  12463. * Represents a gamepad control stick position
  12464. */
  12465. export class StickValues {
  12466. /**
  12467. * The x component of the control stick
  12468. */
  12469. x: number;
  12470. /**
  12471. * The y component of the control stick
  12472. */
  12473. y: number;
  12474. /**
  12475. * Initializes the gamepad x and y control stick values
  12476. * @param x The x component of the gamepad control stick value
  12477. * @param y The y component of the gamepad control stick value
  12478. */
  12479. constructor(
  12480. /**
  12481. * The x component of the control stick
  12482. */
  12483. x: number,
  12484. /**
  12485. * The y component of the control stick
  12486. */
  12487. y: number);
  12488. }
  12489. /**
  12490. * An interface which manages callbacks for gamepad button changes
  12491. */
  12492. export interface GamepadButtonChanges {
  12493. /**
  12494. * Called when a gamepad has been changed
  12495. */
  12496. changed: boolean;
  12497. /**
  12498. * Called when a gamepad press event has been triggered
  12499. */
  12500. pressChanged: boolean;
  12501. /**
  12502. * Called when a touch event has been triggered
  12503. */
  12504. touchChanged: boolean;
  12505. /**
  12506. * Called when a value has changed
  12507. */
  12508. valueChanged: boolean;
  12509. }
  12510. /**
  12511. * Represents a gamepad
  12512. */
  12513. export class Gamepad {
  12514. /**
  12515. * The id of the gamepad
  12516. */
  12517. id: string;
  12518. /**
  12519. * The index of the gamepad
  12520. */
  12521. index: number;
  12522. /**
  12523. * The browser gamepad
  12524. */
  12525. browserGamepad: any;
  12526. /**
  12527. * Specifies what type of gamepad this represents
  12528. */
  12529. type: number;
  12530. private _leftStick;
  12531. private _rightStick;
  12532. /** @hidden */
  12533. _isConnected: boolean;
  12534. private _leftStickAxisX;
  12535. private _leftStickAxisY;
  12536. private _rightStickAxisX;
  12537. private _rightStickAxisY;
  12538. /**
  12539. * Triggered when the left control stick has been changed
  12540. */
  12541. private _onleftstickchanged;
  12542. /**
  12543. * Triggered when the right control stick has been changed
  12544. */
  12545. private _onrightstickchanged;
  12546. /**
  12547. * Represents a gamepad controller
  12548. */
  12549. static GAMEPAD: number;
  12550. /**
  12551. * Represents a generic controller
  12552. */
  12553. static GENERIC: number;
  12554. /**
  12555. * Represents an XBox controller
  12556. */
  12557. static XBOX: number;
  12558. /**
  12559. * Represents a pose-enabled controller
  12560. */
  12561. static POSE_ENABLED: number;
  12562. /**
  12563. * Specifies whether the left control stick should be Y-inverted
  12564. */
  12565. protected _invertLeftStickY: boolean;
  12566. /**
  12567. * Specifies if the gamepad has been connected
  12568. */
  12569. readonly isConnected: boolean;
  12570. /**
  12571. * Initializes the gamepad
  12572. * @param id The id of the gamepad
  12573. * @param index The index of the gamepad
  12574. * @param browserGamepad The browser gamepad
  12575. * @param leftStickX The x component of the left joystick
  12576. * @param leftStickY The y component of the left joystick
  12577. * @param rightStickX The x component of the right joystick
  12578. * @param rightStickY The y component of the right joystick
  12579. */
  12580. constructor(
  12581. /**
  12582. * The id of the gamepad
  12583. */
  12584. id: string,
  12585. /**
  12586. * The index of the gamepad
  12587. */
  12588. index: number,
  12589. /**
  12590. * The browser gamepad
  12591. */
  12592. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12593. /**
  12594. * Callback triggered when the left joystick has changed
  12595. * @param callback
  12596. */
  12597. onleftstickchanged(callback: (values: StickValues) => void): void;
  12598. /**
  12599. * Callback triggered when the right joystick has changed
  12600. * @param callback
  12601. */
  12602. onrightstickchanged(callback: (values: StickValues) => void): void;
  12603. /**
  12604. * Gets the left joystick
  12605. */
  12606. /**
  12607. * Sets the left joystick values
  12608. */
  12609. leftStick: StickValues;
  12610. /**
  12611. * Gets the right joystick
  12612. */
  12613. /**
  12614. * Sets the right joystick value
  12615. */
  12616. rightStick: StickValues;
  12617. /**
  12618. * Updates the gamepad joystick positions
  12619. */
  12620. update(): void;
  12621. /**
  12622. * Disposes the gamepad
  12623. */
  12624. dispose(): void;
  12625. }
  12626. /**
  12627. * Represents a generic gamepad
  12628. */
  12629. export class GenericPad extends Gamepad {
  12630. private _buttons;
  12631. private _onbuttondown;
  12632. private _onbuttonup;
  12633. /**
  12634. * Observable triggered when a button has been pressed
  12635. */
  12636. onButtonDownObservable: Observable<number>;
  12637. /**
  12638. * Observable triggered when a button has been released
  12639. */
  12640. onButtonUpObservable: Observable<number>;
  12641. /**
  12642. * Callback triggered when a button has been pressed
  12643. * @param callback Called when a button has been pressed
  12644. */
  12645. onbuttondown(callback: (buttonPressed: number) => void): void;
  12646. /**
  12647. * Callback triggered when a button has been released
  12648. * @param callback Called when a button has been released
  12649. */
  12650. onbuttonup(callback: (buttonReleased: number) => void): void;
  12651. /**
  12652. * Initializes the generic gamepad
  12653. * @param id The id of the generic gamepad
  12654. * @param index The index of the generic gamepad
  12655. * @param browserGamepad The browser gamepad
  12656. */
  12657. constructor(id: string, index: number, browserGamepad: any);
  12658. private _setButtonValue;
  12659. /**
  12660. * Updates the generic gamepad
  12661. */
  12662. update(): void;
  12663. /**
  12664. * Disposes the generic gamepad
  12665. */
  12666. dispose(): void;
  12667. }
  12668. }
  12669. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12670. import { Observable } from "babylonjs/Misc/observable";
  12671. import { Nullable } from "babylonjs/types";
  12672. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12673. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12675. import { Ray } from "babylonjs/Culling/ray";
  12676. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12677. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12678. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12679. /**
  12680. * Defines the types of pose enabled controllers that are supported
  12681. */
  12682. export enum PoseEnabledControllerType {
  12683. /**
  12684. * HTC Vive
  12685. */
  12686. VIVE = 0,
  12687. /**
  12688. * Oculus Rift
  12689. */
  12690. OCULUS = 1,
  12691. /**
  12692. * Windows mixed reality
  12693. */
  12694. WINDOWS = 2,
  12695. /**
  12696. * Samsung gear VR
  12697. */
  12698. GEAR_VR = 3,
  12699. /**
  12700. * Google Daydream
  12701. */
  12702. DAYDREAM = 4,
  12703. /**
  12704. * Generic
  12705. */
  12706. GENERIC = 5
  12707. }
  12708. /**
  12709. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12710. */
  12711. export interface MutableGamepadButton {
  12712. /**
  12713. * Value of the button/trigger
  12714. */
  12715. value: number;
  12716. /**
  12717. * If the button/trigger is currently touched
  12718. */
  12719. touched: boolean;
  12720. /**
  12721. * If the button/trigger is currently pressed
  12722. */
  12723. pressed: boolean;
  12724. }
  12725. /**
  12726. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12727. * @hidden
  12728. */
  12729. export interface ExtendedGamepadButton extends GamepadButton {
  12730. /**
  12731. * If the button/trigger is currently pressed
  12732. */
  12733. readonly pressed: boolean;
  12734. /**
  12735. * If the button/trigger is currently touched
  12736. */
  12737. readonly touched: boolean;
  12738. /**
  12739. * Value of the button/trigger
  12740. */
  12741. readonly value: number;
  12742. }
  12743. /** @hidden */
  12744. export interface _GamePadFactory {
  12745. /**
  12746. * Returns wether or not the current gamepad can be created for this type of controller.
  12747. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12748. * @returns true if it can be created, otherwise false
  12749. */
  12750. canCreate(gamepadInfo: any): boolean;
  12751. /**
  12752. * Creates a new instance of the Gamepad.
  12753. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12754. * @returns the new gamepad instance
  12755. */
  12756. create(gamepadInfo: any): Gamepad;
  12757. }
  12758. /**
  12759. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12760. */
  12761. export class PoseEnabledControllerHelper {
  12762. /** @hidden */
  12763. static _ControllerFactories: _GamePadFactory[];
  12764. /** @hidden */
  12765. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12766. /**
  12767. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12768. * @param vrGamepad the gamepad to initialized
  12769. * @returns a vr controller of the type the gamepad identified as
  12770. */
  12771. static InitiateController(vrGamepad: any): Gamepad;
  12772. }
  12773. /**
  12774. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12775. */
  12776. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12777. private _deviceRoomPosition;
  12778. private _deviceRoomRotationQuaternion;
  12779. /**
  12780. * The device position in babylon space
  12781. */
  12782. devicePosition: Vector3;
  12783. /**
  12784. * The device rotation in babylon space
  12785. */
  12786. deviceRotationQuaternion: Quaternion;
  12787. /**
  12788. * The scale factor of the device in babylon space
  12789. */
  12790. deviceScaleFactor: number;
  12791. /**
  12792. * (Likely devicePosition should be used instead) The device position in its room space
  12793. */
  12794. position: Vector3;
  12795. /**
  12796. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12797. */
  12798. rotationQuaternion: Quaternion;
  12799. /**
  12800. * The type of controller (Eg. Windows mixed reality)
  12801. */
  12802. controllerType: PoseEnabledControllerType;
  12803. protected _calculatedPosition: Vector3;
  12804. private _calculatedRotation;
  12805. /**
  12806. * The raw pose from the device
  12807. */
  12808. rawPose: DevicePose;
  12809. private _trackPosition;
  12810. private _maxRotationDistFromHeadset;
  12811. private _draggedRoomRotation;
  12812. /**
  12813. * @hidden
  12814. */
  12815. _disableTrackPosition(fixedPosition: Vector3): void;
  12816. /**
  12817. * Internal, the mesh attached to the controller
  12818. * @hidden
  12819. */
  12820. _mesh: Nullable<AbstractMesh>;
  12821. private _poseControlledCamera;
  12822. private _leftHandSystemQuaternion;
  12823. /**
  12824. * Internal, matrix used to convert room space to babylon space
  12825. * @hidden
  12826. */
  12827. _deviceToWorld: Matrix;
  12828. /**
  12829. * Node to be used when casting a ray from the controller
  12830. * @hidden
  12831. */
  12832. _pointingPoseNode: Nullable<TransformNode>;
  12833. /**
  12834. * Name of the child mesh that can be used to cast a ray from the controller
  12835. */
  12836. static readonly POINTING_POSE: string;
  12837. /**
  12838. * Creates a new PoseEnabledController from a gamepad
  12839. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12840. */
  12841. constructor(browserGamepad: any);
  12842. private _workingMatrix;
  12843. /**
  12844. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12845. */
  12846. update(): void;
  12847. /**
  12848. * Updates only the pose device and mesh without doing any button event checking
  12849. */
  12850. protected _updatePoseAndMesh(): void;
  12851. /**
  12852. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12853. * @param poseData raw pose fromthe device
  12854. */
  12855. updateFromDevice(poseData: DevicePose): void;
  12856. /**
  12857. * @hidden
  12858. */
  12859. _meshAttachedObservable: Observable<AbstractMesh>;
  12860. /**
  12861. * Attaches a mesh to the controller
  12862. * @param mesh the mesh to be attached
  12863. */
  12864. attachToMesh(mesh: AbstractMesh): void;
  12865. /**
  12866. * Attaches the controllers mesh to a camera
  12867. * @param camera the camera the mesh should be attached to
  12868. */
  12869. attachToPoseControlledCamera(camera: TargetCamera): void;
  12870. /**
  12871. * Disposes of the controller
  12872. */
  12873. dispose(): void;
  12874. /**
  12875. * The mesh that is attached to the controller
  12876. */
  12877. readonly mesh: Nullable<AbstractMesh>;
  12878. /**
  12879. * Gets the ray of the controller in the direction the controller is pointing
  12880. * @param length the length the resulting ray should be
  12881. * @returns a ray in the direction the controller is pointing
  12882. */
  12883. getForwardRay(length?: number): Ray;
  12884. }
  12885. }
  12886. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12887. import { Observable } from "babylonjs/Misc/observable";
  12888. import { Scene } from "babylonjs/scene";
  12889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12890. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12891. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12892. /**
  12893. * Defines the WebVRController object that represents controllers tracked in 3D space
  12894. */
  12895. export abstract class WebVRController extends PoseEnabledController {
  12896. /**
  12897. * Internal, the default controller model for the controller
  12898. */
  12899. protected _defaultModel: AbstractMesh;
  12900. /**
  12901. * Fired when the trigger state has changed
  12902. */
  12903. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12904. /**
  12905. * Fired when the main button state has changed
  12906. */
  12907. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12908. /**
  12909. * Fired when the secondary button state has changed
  12910. */
  12911. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12912. /**
  12913. * Fired when the pad state has changed
  12914. */
  12915. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12916. /**
  12917. * Fired when controllers stick values have changed
  12918. */
  12919. onPadValuesChangedObservable: Observable<StickValues>;
  12920. /**
  12921. * Array of button availible on the controller
  12922. */
  12923. protected _buttons: Array<MutableGamepadButton>;
  12924. private _onButtonStateChange;
  12925. /**
  12926. * Fired when a controller button's state has changed
  12927. * @param callback the callback containing the button that was modified
  12928. */
  12929. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12930. /**
  12931. * X and Y axis corrisponding to the controllers joystick
  12932. */
  12933. pad: StickValues;
  12934. /**
  12935. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12936. */
  12937. hand: string;
  12938. /**
  12939. * The default controller model for the controller
  12940. */
  12941. readonly defaultModel: AbstractMesh;
  12942. /**
  12943. * Creates a new WebVRController from a gamepad
  12944. * @param vrGamepad the gamepad that the WebVRController should be created from
  12945. */
  12946. constructor(vrGamepad: any);
  12947. /**
  12948. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12949. */
  12950. update(): void;
  12951. /**
  12952. * Function to be called when a button is modified
  12953. */
  12954. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12955. /**
  12956. * Loads a mesh and attaches it to the controller
  12957. * @param scene the scene the mesh should be added to
  12958. * @param meshLoaded callback for when the mesh has been loaded
  12959. */
  12960. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12961. private _setButtonValue;
  12962. private _changes;
  12963. private _checkChanges;
  12964. /**
  12965. * Disposes of th webVRCOntroller
  12966. */
  12967. dispose(): void;
  12968. }
  12969. }
  12970. declare module "babylonjs/Lights/hemisphericLight" {
  12971. import { Nullable } from "babylonjs/types";
  12972. import { Scene } from "babylonjs/scene";
  12973. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12974. import { Effect } from "babylonjs/Materials/effect";
  12975. import { Light } from "babylonjs/Lights/light";
  12976. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12977. /**
  12978. * The HemisphericLight simulates the ambient environment light,
  12979. * so the passed direction is the light reflection direction, not the incoming direction.
  12980. */
  12981. export class HemisphericLight extends Light {
  12982. /**
  12983. * The groundColor is the light in the opposite direction to the one specified during creation.
  12984. * 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.
  12985. */
  12986. groundColor: Color3;
  12987. /**
  12988. * The light reflection direction, not the incoming direction.
  12989. */
  12990. direction: Vector3;
  12991. /**
  12992. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12993. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12994. * The HemisphericLight can't cast shadows.
  12995. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12996. * @param name The friendly name of the light
  12997. * @param direction The direction of the light reflection
  12998. * @param scene The scene the light belongs to
  12999. */
  13000. constructor(name: string, direction: Vector3, scene: Scene);
  13001. protected _buildUniformLayout(): void;
  13002. /**
  13003. * Returns the string "HemisphericLight".
  13004. * @return The class name
  13005. */
  13006. getClassName(): string;
  13007. /**
  13008. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13009. * Returns the updated direction.
  13010. * @param target The target the direction should point to
  13011. * @return The computed direction
  13012. */
  13013. setDirectionToTarget(target: Vector3): Vector3;
  13014. /**
  13015. * Returns the shadow generator associated to the light.
  13016. * @returns Always null for hemispheric lights because it does not support shadows.
  13017. */
  13018. getShadowGenerator(): Nullable<IShadowGenerator>;
  13019. /**
  13020. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13021. * @param effect The effect to update
  13022. * @param lightIndex The index of the light in the effect to update
  13023. * @returns The hemispheric light
  13024. */
  13025. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13026. /**
  13027. * Computes the world matrix of the node
  13028. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13029. * @param useWasUpdatedFlag defines a reserved property
  13030. * @returns the world matrix
  13031. */
  13032. computeWorldMatrix(): Matrix;
  13033. /**
  13034. * Returns the integer 3.
  13035. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13036. */
  13037. getTypeID(): number;
  13038. /**
  13039. * Prepares the list of defines specific to the light type.
  13040. * @param defines the list of defines
  13041. * @param lightIndex defines the index of the light for the effect
  13042. */
  13043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13044. }
  13045. }
  13046. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13047. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13048. import { Nullable } from "babylonjs/types";
  13049. import { Observable } from "babylonjs/Misc/observable";
  13050. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13051. import { Scene } from "babylonjs/scene";
  13052. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13053. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13054. import { Node } from "babylonjs/node";
  13055. import { Ray } from "babylonjs/Culling/ray";
  13056. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13057. /**
  13058. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13059. * IMPORTANT!! The data is right-hand data.
  13060. * @export
  13061. * @interface DevicePose
  13062. */
  13063. export interface DevicePose {
  13064. /**
  13065. * The position of the device, values in array are [x,y,z].
  13066. */
  13067. readonly position: Nullable<Float32Array>;
  13068. /**
  13069. * The linearVelocity of the device, values in array are [x,y,z].
  13070. */
  13071. readonly linearVelocity: Nullable<Float32Array>;
  13072. /**
  13073. * The linearAcceleration of the device, values in array are [x,y,z].
  13074. */
  13075. readonly linearAcceleration: Nullable<Float32Array>;
  13076. /**
  13077. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13078. */
  13079. readonly orientation: Nullable<Float32Array>;
  13080. /**
  13081. * The angularVelocity of the device, values in array are [x,y,z].
  13082. */
  13083. readonly angularVelocity: Nullable<Float32Array>;
  13084. /**
  13085. * The angularAcceleration of the device, values in array are [x,y,z].
  13086. */
  13087. readonly angularAcceleration: Nullable<Float32Array>;
  13088. }
  13089. /**
  13090. * Interface representing a pose controlled object in Babylon.
  13091. * A pose controlled object has both regular pose values as well as pose values
  13092. * from an external device such as a VR head mounted display
  13093. */
  13094. export interface PoseControlled {
  13095. /**
  13096. * The position of the object in babylon space.
  13097. */
  13098. position: Vector3;
  13099. /**
  13100. * The rotation quaternion of the object in babylon space.
  13101. */
  13102. rotationQuaternion: Quaternion;
  13103. /**
  13104. * The position of the device in babylon space.
  13105. */
  13106. devicePosition?: Vector3;
  13107. /**
  13108. * The rotation quaternion of the device in babylon space.
  13109. */
  13110. deviceRotationQuaternion: Quaternion;
  13111. /**
  13112. * The raw pose coming from the device.
  13113. */
  13114. rawPose: Nullable<DevicePose>;
  13115. /**
  13116. * The scale of the device to be used when translating from device space to babylon space.
  13117. */
  13118. deviceScaleFactor: number;
  13119. /**
  13120. * Updates the poseControlled values based on the input device pose.
  13121. * @param poseData the pose data to update the object with
  13122. */
  13123. updateFromDevice(poseData: DevicePose): void;
  13124. }
  13125. /**
  13126. * Set of options to customize the webVRCamera
  13127. */
  13128. export interface WebVROptions {
  13129. /**
  13130. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13131. */
  13132. trackPosition?: boolean;
  13133. /**
  13134. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13135. */
  13136. positionScale?: number;
  13137. /**
  13138. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13139. */
  13140. displayName?: string;
  13141. /**
  13142. * Should the native controller meshes be initialized. (default: true)
  13143. */
  13144. controllerMeshes?: boolean;
  13145. /**
  13146. * Creating a default HemiLight only on controllers. (default: true)
  13147. */
  13148. defaultLightingOnControllers?: boolean;
  13149. /**
  13150. * If you don't want to use the default VR button of the helper. (default: false)
  13151. */
  13152. useCustomVRButton?: boolean;
  13153. /**
  13154. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13155. */
  13156. customVRButton?: HTMLButtonElement;
  13157. /**
  13158. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13159. */
  13160. rayLength?: number;
  13161. /**
  13162. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13163. */
  13164. defaultHeight?: number;
  13165. }
  13166. /**
  13167. * This represents a WebVR camera.
  13168. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13169. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13170. */
  13171. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13172. private webVROptions;
  13173. /**
  13174. * @hidden
  13175. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13176. */
  13177. _vrDevice: any;
  13178. /**
  13179. * The rawPose of the vrDevice.
  13180. */
  13181. rawPose: Nullable<DevicePose>;
  13182. private _onVREnabled;
  13183. private _specsVersion;
  13184. private _attached;
  13185. private _frameData;
  13186. protected _descendants: Array<Node>;
  13187. private _deviceRoomPosition;
  13188. /** @hidden */
  13189. _deviceRoomRotationQuaternion: Quaternion;
  13190. private _standingMatrix;
  13191. /**
  13192. * Represents device position in babylon space.
  13193. */
  13194. devicePosition: Vector3;
  13195. /**
  13196. * Represents device rotation in babylon space.
  13197. */
  13198. deviceRotationQuaternion: Quaternion;
  13199. /**
  13200. * The scale of the device to be used when translating from device space to babylon space.
  13201. */
  13202. deviceScaleFactor: number;
  13203. private _deviceToWorld;
  13204. private _worldToDevice;
  13205. /**
  13206. * References to the webVR controllers for the vrDevice.
  13207. */
  13208. controllers: Array<WebVRController>;
  13209. /**
  13210. * Emits an event when a controller is attached.
  13211. */
  13212. onControllersAttachedObservable: Observable<WebVRController[]>;
  13213. /**
  13214. * Emits an event when a controller's mesh has been loaded;
  13215. */
  13216. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13217. /**
  13218. * Emits an event when the HMD's pose has been updated.
  13219. */
  13220. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13221. private _poseSet;
  13222. /**
  13223. * If the rig cameras be used as parent instead of this camera.
  13224. */
  13225. rigParenting: boolean;
  13226. private _lightOnControllers;
  13227. private _defaultHeight?;
  13228. /**
  13229. * Instantiates a WebVRFreeCamera.
  13230. * @param name The name of the WebVRFreeCamera
  13231. * @param position The starting anchor position for the camera
  13232. * @param scene The scene the camera belongs to
  13233. * @param webVROptions a set of customizable options for the webVRCamera
  13234. */
  13235. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13236. /**
  13237. * Gets the device distance from the ground in meters.
  13238. * @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.
  13239. */
  13240. deviceDistanceToRoomGround(): number;
  13241. /**
  13242. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13243. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13244. */
  13245. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13246. /**
  13247. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13248. * @returns A promise with a boolean set to if the standing matrix is supported.
  13249. */
  13250. useStandingMatrixAsync(): Promise<boolean>;
  13251. /**
  13252. * Disposes the camera
  13253. */
  13254. dispose(): void;
  13255. /**
  13256. * Gets a vrController by name.
  13257. * @param name The name of the controller to retreive
  13258. * @returns the controller matching the name specified or null if not found
  13259. */
  13260. getControllerByName(name: string): Nullable<WebVRController>;
  13261. private _leftController;
  13262. /**
  13263. * The controller corrisponding to the users left hand.
  13264. */
  13265. readonly leftController: Nullable<WebVRController>;
  13266. private _rightController;
  13267. /**
  13268. * The controller corrisponding to the users right hand.
  13269. */
  13270. readonly rightController: Nullable<WebVRController>;
  13271. /**
  13272. * Casts a ray forward from the vrCamera's gaze.
  13273. * @param length Length of the ray (default: 100)
  13274. * @returns the ray corrisponding to the gaze
  13275. */
  13276. getForwardRay(length?: number): Ray;
  13277. /**
  13278. * @hidden
  13279. * Updates the camera based on device's frame data
  13280. */
  13281. _checkInputs(): void;
  13282. /**
  13283. * Updates the poseControlled values based on the input device pose.
  13284. * @param poseData Pose coming from the device
  13285. */
  13286. updateFromDevice(poseData: DevicePose): void;
  13287. private _htmlElementAttached;
  13288. private _detachIfAttached;
  13289. /**
  13290. * WebVR's attach control will start broadcasting frames to the device.
  13291. * Note that in certain browsers (chrome for example) this function must be called
  13292. * within a user-interaction callback. Example:
  13293. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13294. *
  13295. * @param element html element to attach the vrDevice to
  13296. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13297. */
  13298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13299. /**
  13300. * Detaches the camera from the html element and disables VR
  13301. *
  13302. * @param element html element to detach from
  13303. */
  13304. detachControl(element: HTMLElement): void;
  13305. /**
  13306. * @returns the name of this class
  13307. */
  13308. getClassName(): string;
  13309. /**
  13310. * Calls resetPose on the vrDisplay
  13311. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13312. */
  13313. resetToCurrentRotation(): void;
  13314. /**
  13315. * @hidden
  13316. * Updates the rig cameras (left and right eye)
  13317. */
  13318. _updateRigCameras(): void;
  13319. private _workingVector;
  13320. private _oneVector;
  13321. private _workingMatrix;
  13322. private updateCacheCalled;
  13323. private _correctPositionIfNotTrackPosition;
  13324. /**
  13325. * @hidden
  13326. * Updates the cached values of the camera
  13327. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13328. */
  13329. _updateCache(ignoreParentClass?: boolean): void;
  13330. /**
  13331. * @hidden
  13332. * Get current device position in babylon world
  13333. */
  13334. _computeDevicePosition(): void;
  13335. /**
  13336. * Updates the current device position and rotation in the babylon world
  13337. */
  13338. update(): void;
  13339. /**
  13340. * @hidden
  13341. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13342. * @returns an identity matrix
  13343. */
  13344. _getViewMatrix(): Matrix;
  13345. private _tmpMatrix;
  13346. /**
  13347. * This function is called by the two RIG cameras.
  13348. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13349. * @hidden
  13350. */
  13351. _getWebVRViewMatrix(): Matrix;
  13352. /** @hidden */
  13353. _getWebVRProjectionMatrix(): Matrix;
  13354. private _onGamepadConnectedObserver;
  13355. private _onGamepadDisconnectedObserver;
  13356. private _updateCacheWhenTrackingDisabledObserver;
  13357. /**
  13358. * Initializes the controllers and their meshes
  13359. */
  13360. initControllers(): void;
  13361. }
  13362. }
  13363. declare module "babylonjs/PostProcesses/postProcess" {
  13364. import { Nullable } from "babylonjs/types";
  13365. import { SmartArray } from "babylonjs/Misc/smartArray";
  13366. import { Observable } from "babylonjs/Misc/observable";
  13367. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13368. import { Camera } from "babylonjs/Cameras/camera";
  13369. import { Effect } from "babylonjs/Materials/effect";
  13370. import "babylonjs/Shaders/postprocess.vertex";
  13371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13372. import { Engine } from "babylonjs/Engines/engine";
  13373. /**
  13374. * Size options for a post process
  13375. */
  13376. export type PostProcessOptions = {
  13377. width: number;
  13378. height: number;
  13379. };
  13380. /**
  13381. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13382. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13383. */
  13384. export class PostProcess {
  13385. /** Name of the PostProcess. */
  13386. name: string;
  13387. /**
  13388. * Gets or sets the unique id of the post process
  13389. */
  13390. uniqueId: number;
  13391. /**
  13392. * Width of the texture to apply the post process on
  13393. */
  13394. width: number;
  13395. /**
  13396. * Height of the texture to apply the post process on
  13397. */
  13398. height: number;
  13399. /**
  13400. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13401. * @hidden
  13402. */
  13403. _outputTexture: Nullable<InternalTexture>;
  13404. /**
  13405. * Sampling mode used by the shader
  13406. * See https://doc.babylonjs.com/classes/3.1/texture
  13407. */
  13408. renderTargetSamplingMode: number;
  13409. /**
  13410. * Clear color to use when screen clearing
  13411. */
  13412. clearColor: Color4;
  13413. /**
  13414. * If the buffer needs to be cleared before applying the post process. (default: true)
  13415. * Should be set to false if shader will overwrite all previous pixels.
  13416. */
  13417. autoClear: boolean;
  13418. /**
  13419. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13420. */
  13421. alphaMode: number;
  13422. /**
  13423. * Sets the setAlphaBlendConstants of the babylon engine
  13424. */
  13425. alphaConstants: Color4;
  13426. /**
  13427. * Animations to be used for the post processing
  13428. */
  13429. animations: import("babylonjs/Animations/animation").Animation[];
  13430. /**
  13431. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13432. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13433. */
  13434. enablePixelPerfectMode: boolean;
  13435. /**
  13436. * Force the postprocess to be applied without taking in account viewport
  13437. */
  13438. forceFullscreenViewport: boolean;
  13439. /**
  13440. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13441. *
  13442. * | Value | Type | Description |
  13443. * | ----- | ----------------------------------- | ----------- |
  13444. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13445. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13446. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13447. *
  13448. */
  13449. scaleMode: number;
  13450. /**
  13451. * Force textures to be a power of two (default: false)
  13452. */
  13453. alwaysForcePOT: boolean;
  13454. private _samples;
  13455. /**
  13456. * Number of sample textures (default: 1)
  13457. */
  13458. samples: number;
  13459. /**
  13460. * Modify the scale of the post process to be the same as the viewport (default: false)
  13461. */
  13462. adaptScaleToCurrentViewport: boolean;
  13463. private _camera;
  13464. private _scene;
  13465. private _engine;
  13466. private _options;
  13467. private _reusable;
  13468. private _textureType;
  13469. /**
  13470. * Smart array of input and output textures for the post process.
  13471. * @hidden
  13472. */
  13473. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13474. /**
  13475. * The index in _textures that corresponds to the output texture.
  13476. * @hidden
  13477. */
  13478. _currentRenderTextureInd: number;
  13479. private _effect;
  13480. private _samplers;
  13481. private _fragmentUrl;
  13482. private _vertexUrl;
  13483. private _parameters;
  13484. private _scaleRatio;
  13485. protected _indexParameters: any;
  13486. private _shareOutputWithPostProcess;
  13487. private _texelSize;
  13488. private _forcedOutputTexture;
  13489. /**
  13490. * Returns the fragment url or shader name used in the post process.
  13491. * @returns the fragment url or name in the shader store.
  13492. */
  13493. getEffectName(): string;
  13494. /**
  13495. * An event triggered when the postprocess is activated.
  13496. */
  13497. onActivateObservable: Observable<Camera>;
  13498. private _onActivateObserver;
  13499. /**
  13500. * A function that is added to the onActivateObservable
  13501. */
  13502. onActivate: Nullable<(camera: Camera) => void>;
  13503. /**
  13504. * An event triggered when the postprocess changes its size.
  13505. */
  13506. onSizeChangedObservable: Observable<PostProcess>;
  13507. private _onSizeChangedObserver;
  13508. /**
  13509. * A function that is added to the onSizeChangedObservable
  13510. */
  13511. onSizeChanged: (postProcess: PostProcess) => void;
  13512. /**
  13513. * An event triggered when the postprocess applies its effect.
  13514. */
  13515. onApplyObservable: Observable<Effect>;
  13516. private _onApplyObserver;
  13517. /**
  13518. * A function that is added to the onApplyObservable
  13519. */
  13520. onApply: (effect: Effect) => void;
  13521. /**
  13522. * An event triggered before rendering the postprocess
  13523. */
  13524. onBeforeRenderObservable: Observable<Effect>;
  13525. private _onBeforeRenderObserver;
  13526. /**
  13527. * A function that is added to the onBeforeRenderObservable
  13528. */
  13529. onBeforeRender: (effect: Effect) => void;
  13530. /**
  13531. * An event triggered after rendering the postprocess
  13532. */
  13533. onAfterRenderObservable: Observable<Effect>;
  13534. private _onAfterRenderObserver;
  13535. /**
  13536. * A function that is added to the onAfterRenderObservable
  13537. */
  13538. onAfterRender: (efect: Effect) => void;
  13539. /**
  13540. * 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
  13541. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13542. */
  13543. inputTexture: InternalTexture;
  13544. /**
  13545. * Gets the camera which post process is applied to.
  13546. * @returns The camera the post process is applied to.
  13547. */
  13548. getCamera(): Camera;
  13549. /**
  13550. * Gets the texel size of the postprocess.
  13551. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13552. */
  13553. readonly texelSize: Vector2;
  13554. /**
  13555. * Creates a new instance PostProcess
  13556. * @param name The name of the PostProcess.
  13557. * @param fragmentUrl The url of the fragment shader to be used.
  13558. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13559. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13561. * @param camera The camera to apply the render pass to.
  13562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13563. * @param engine The engine which the post process will be applied. (default: current engine)
  13564. * @param reusable If the post process can be reused on the same frame. (default: false)
  13565. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13566. * @param textureType Type of textures used when performing the post process. (default: 0)
  13567. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13568. * @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
  13569. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13570. */
  13571. constructor(
  13572. /** Name of the PostProcess. */
  13573. 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);
  13574. /**
  13575. * Gets a string idenfifying the name of the class
  13576. * @returns "PostProcess" string
  13577. */
  13578. getClassName(): string;
  13579. /**
  13580. * Gets the engine which this post process belongs to.
  13581. * @returns The engine the post process was enabled with.
  13582. */
  13583. getEngine(): Engine;
  13584. /**
  13585. * The effect that is created when initializing the post process.
  13586. * @returns The created effect corrisponding the the postprocess.
  13587. */
  13588. getEffect(): Effect;
  13589. /**
  13590. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13591. * @param postProcess The post process to share the output with.
  13592. * @returns This post process.
  13593. */
  13594. shareOutputWith(postProcess: PostProcess): PostProcess;
  13595. /**
  13596. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13597. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13598. */
  13599. useOwnOutput(): void;
  13600. /**
  13601. * Updates the effect with the current post process compile time values and recompiles the shader.
  13602. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13603. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13604. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13605. * @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
  13606. * @param onCompiled Called when the shader has been compiled.
  13607. * @param onError Called if there is an error when compiling a shader.
  13608. */
  13609. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13610. /**
  13611. * The post process is reusable if it can be used multiple times within one frame.
  13612. * @returns If the post process is reusable
  13613. */
  13614. isReusable(): boolean;
  13615. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13616. markTextureDirty(): void;
  13617. /**
  13618. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13619. * 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.
  13620. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13621. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13622. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13623. * @returns The target texture that was bound to be written to.
  13624. */
  13625. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13626. /**
  13627. * If the post process is supported.
  13628. */
  13629. readonly isSupported: boolean;
  13630. /**
  13631. * The aspect ratio of the output texture.
  13632. */
  13633. readonly aspectRatio: number;
  13634. /**
  13635. * Get a value indicating if the post-process is ready to be used
  13636. * @returns true if the post-process is ready (shader is compiled)
  13637. */
  13638. isReady(): boolean;
  13639. /**
  13640. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13641. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13642. */
  13643. apply(): Nullable<Effect>;
  13644. private _disposeTextures;
  13645. /**
  13646. * Disposes the post process.
  13647. * @param camera The camera to dispose the post process on.
  13648. */
  13649. dispose(camera?: Camera): void;
  13650. }
  13651. }
  13652. declare module "babylonjs/PostProcesses/postProcessManager" {
  13653. import { Nullable } from "babylonjs/types";
  13654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13655. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13656. import { Scene } from "babylonjs/scene";
  13657. /**
  13658. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13659. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13660. */
  13661. export class PostProcessManager {
  13662. private _scene;
  13663. private _indexBuffer;
  13664. private _vertexBuffers;
  13665. /**
  13666. * Creates a new instance PostProcess
  13667. * @param scene The scene that the post process is associated with.
  13668. */
  13669. constructor(scene: Scene);
  13670. private _prepareBuffers;
  13671. private _buildIndexBuffer;
  13672. /**
  13673. * Rebuilds the vertex buffers of the manager.
  13674. * @hidden
  13675. */
  13676. _rebuild(): void;
  13677. /**
  13678. * Prepares a frame to be run through a post process.
  13679. * @param sourceTexture The input texture to the post procesess. (default: null)
  13680. * @param postProcesses An array of post processes to be run. (default: null)
  13681. * @returns True if the post processes were able to be run.
  13682. * @hidden
  13683. */
  13684. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13685. /**
  13686. * Manually render a set of post processes to a texture.
  13687. * @param postProcesses An array of post processes to be run.
  13688. * @param targetTexture The target texture to render to.
  13689. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13690. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13691. * @param lodLevel defines which lod of the texture to render to
  13692. */
  13693. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13694. /**
  13695. * Finalize the result of the output of the postprocesses.
  13696. * @param doNotPresent If true the result will not be displayed to the screen.
  13697. * @param targetTexture The target texture to render to.
  13698. * @param faceIndex The index of the face to bind the target texture to.
  13699. * @param postProcesses The array of post processes to render.
  13700. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13701. * @hidden
  13702. */
  13703. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13704. /**
  13705. * Disposes of the post process manager.
  13706. */
  13707. dispose(): void;
  13708. }
  13709. }
  13710. declare module "babylonjs/Layers/layerSceneComponent" {
  13711. import { Scene } from "babylonjs/scene";
  13712. import { ISceneComponent } from "babylonjs/sceneComponent";
  13713. import { Layer } from "babylonjs/Layers/layer";
  13714. module "babylonjs/abstractScene" {
  13715. interface AbstractScene {
  13716. /**
  13717. * The list of layers (background and foreground) of the scene
  13718. */
  13719. layers: Array<Layer>;
  13720. }
  13721. }
  13722. /**
  13723. * Defines the layer scene component responsible to manage any layers
  13724. * in a given scene.
  13725. */
  13726. export class LayerSceneComponent implements ISceneComponent {
  13727. /**
  13728. * The component name helpfull to identify the component in the list of scene components.
  13729. */
  13730. readonly name: string;
  13731. /**
  13732. * The scene the component belongs to.
  13733. */
  13734. scene: Scene;
  13735. private _engine;
  13736. /**
  13737. * Creates a new instance of the component for the given scene
  13738. * @param scene Defines the scene to register the component in
  13739. */
  13740. constructor(scene: Scene);
  13741. /**
  13742. * Registers the component in a given scene
  13743. */
  13744. register(): void;
  13745. /**
  13746. * Rebuilds the elements related to this component in case of
  13747. * context lost for instance.
  13748. */
  13749. rebuild(): void;
  13750. /**
  13751. * Disposes the component and the associated ressources.
  13752. */
  13753. dispose(): void;
  13754. private _draw;
  13755. private _drawCameraPredicate;
  13756. private _drawCameraBackground;
  13757. private _drawCameraForeground;
  13758. private _drawRenderTargetPredicate;
  13759. private _drawRenderTargetBackground;
  13760. private _drawRenderTargetForeground;
  13761. }
  13762. }
  13763. declare module "babylonjs/Shaders/layer.fragment" {
  13764. /** @hidden */
  13765. export var layerPixelShader: {
  13766. name: string;
  13767. shader: string;
  13768. };
  13769. }
  13770. declare module "babylonjs/Shaders/layer.vertex" {
  13771. /** @hidden */
  13772. export var layerVertexShader: {
  13773. name: string;
  13774. shader: string;
  13775. };
  13776. }
  13777. declare module "babylonjs/Layers/layer" {
  13778. import { Observable } from "babylonjs/Misc/observable";
  13779. import { Nullable } from "babylonjs/types";
  13780. import { Scene } from "babylonjs/scene";
  13781. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13782. import { Texture } from "babylonjs/Materials/Textures/texture";
  13783. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13784. import "babylonjs/Shaders/layer.fragment";
  13785. import "babylonjs/Shaders/layer.vertex";
  13786. /**
  13787. * This represents a full screen 2d layer.
  13788. * This can be useful to display a picture in the background of your scene for instance.
  13789. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13790. */
  13791. export class Layer {
  13792. /**
  13793. * Define the name of the layer.
  13794. */
  13795. name: string;
  13796. /**
  13797. * Define the texture the layer should display.
  13798. */
  13799. texture: Nullable<Texture>;
  13800. /**
  13801. * Is the layer in background or foreground.
  13802. */
  13803. isBackground: boolean;
  13804. /**
  13805. * Define the color of the layer (instead of texture).
  13806. */
  13807. color: Color4;
  13808. /**
  13809. * Define the scale of the layer in order to zoom in out of the texture.
  13810. */
  13811. scale: Vector2;
  13812. /**
  13813. * Define an offset for the layer in order to shift the texture.
  13814. */
  13815. offset: Vector2;
  13816. /**
  13817. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13818. */
  13819. alphaBlendingMode: number;
  13820. /**
  13821. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13822. * Alpha test will not mix with the background color in case of transparency.
  13823. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13824. */
  13825. alphaTest: boolean;
  13826. /**
  13827. * Define a mask to restrict the layer to only some of the scene cameras.
  13828. */
  13829. layerMask: number;
  13830. /**
  13831. * Define the list of render target the layer is visible into.
  13832. */
  13833. renderTargetTextures: RenderTargetTexture[];
  13834. /**
  13835. * Define if the layer is only used in renderTarget or if it also
  13836. * renders in the main frame buffer of the canvas.
  13837. */
  13838. renderOnlyInRenderTargetTextures: boolean;
  13839. private _scene;
  13840. private _vertexBuffers;
  13841. private _indexBuffer;
  13842. private _effect;
  13843. private _alphaTestEffect;
  13844. /**
  13845. * An event triggered when the layer is disposed.
  13846. */
  13847. onDisposeObservable: Observable<Layer>;
  13848. private _onDisposeObserver;
  13849. /**
  13850. * Back compatibility with callback before the onDisposeObservable existed.
  13851. * The set callback will be triggered when the layer has been disposed.
  13852. */
  13853. onDispose: () => void;
  13854. /**
  13855. * An event triggered before rendering the scene
  13856. */
  13857. onBeforeRenderObservable: Observable<Layer>;
  13858. private _onBeforeRenderObserver;
  13859. /**
  13860. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13861. * The set callback will be triggered just before rendering the layer.
  13862. */
  13863. onBeforeRender: () => void;
  13864. /**
  13865. * An event triggered after rendering the scene
  13866. */
  13867. onAfterRenderObservable: Observable<Layer>;
  13868. private _onAfterRenderObserver;
  13869. /**
  13870. * Back compatibility with callback before the onAfterRenderObservable existed.
  13871. * The set callback will be triggered just after rendering the layer.
  13872. */
  13873. onAfterRender: () => void;
  13874. /**
  13875. * Instantiates a new layer.
  13876. * This represents a full screen 2d layer.
  13877. * This can be useful to display a picture in the background of your scene for instance.
  13878. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13879. * @param name Define the name of the layer in the scene
  13880. * @param imgUrl Define the url of the texture to display in the layer
  13881. * @param scene Define the scene the layer belongs to
  13882. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13883. * @param color Defines a color for the layer
  13884. */
  13885. constructor(
  13886. /**
  13887. * Define the name of the layer.
  13888. */
  13889. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13890. private _createIndexBuffer;
  13891. /** @hidden */
  13892. _rebuild(): void;
  13893. /**
  13894. * Renders the layer in the scene.
  13895. */
  13896. render(): void;
  13897. /**
  13898. * Disposes and releases the associated ressources.
  13899. */
  13900. dispose(): void;
  13901. }
  13902. }
  13903. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13904. import { Scene } from "babylonjs/scene";
  13905. import { ISceneComponent } from "babylonjs/sceneComponent";
  13906. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13907. module "babylonjs/abstractScene" {
  13908. interface AbstractScene {
  13909. /**
  13910. * The list of procedural textures added to the scene
  13911. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13912. */
  13913. proceduralTextures: Array<ProceduralTexture>;
  13914. }
  13915. }
  13916. /**
  13917. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13918. * in a given scene.
  13919. */
  13920. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13921. /**
  13922. * The component name helpfull to identify the component in the list of scene components.
  13923. */
  13924. readonly name: string;
  13925. /**
  13926. * The scene the component belongs to.
  13927. */
  13928. scene: Scene;
  13929. /**
  13930. * Creates a new instance of the component for the given scene
  13931. * @param scene Defines the scene to register the component in
  13932. */
  13933. constructor(scene: Scene);
  13934. /**
  13935. * Registers the component in a given scene
  13936. */
  13937. register(): void;
  13938. /**
  13939. * Rebuilds the elements related to this component in case of
  13940. * context lost for instance.
  13941. */
  13942. rebuild(): void;
  13943. /**
  13944. * Disposes the component and the associated ressources.
  13945. */
  13946. dispose(): void;
  13947. private _beforeClear;
  13948. }
  13949. }
  13950. declare module "babylonjs/Shaders/procedural.vertex" {
  13951. /** @hidden */
  13952. export var proceduralVertexShader: {
  13953. name: string;
  13954. shader: string;
  13955. };
  13956. }
  13957. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13958. import { Observable } from "babylonjs/Misc/observable";
  13959. import { Nullable } from "babylonjs/types";
  13960. import { Scene } from "babylonjs/scene";
  13961. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13962. import { Effect } from "babylonjs/Materials/effect";
  13963. import { Texture } from "babylonjs/Materials/Textures/texture";
  13964. import "babylonjs/Shaders/procedural.vertex";
  13965. /**
  13966. * 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.
  13967. * This is the base class of any Procedural texture and contains most of the shareable code.
  13968. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13969. */
  13970. export class ProceduralTexture extends Texture {
  13971. isCube: boolean;
  13972. /**
  13973. * Define if the texture is enabled or not (disabled texture will not render)
  13974. */
  13975. isEnabled: boolean;
  13976. /**
  13977. * Define if the texture must be cleared before rendering (default is true)
  13978. */
  13979. autoClear: boolean;
  13980. /**
  13981. * Callback called when the texture is generated
  13982. */
  13983. onGenerated: () => void;
  13984. /**
  13985. * Event raised when the texture is generated
  13986. */
  13987. onGeneratedObservable: Observable<ProceduralTexture>;
  13988. /** @hidden */
  13989. _generateMipMaps: boolean;
  13990. /** @hidden **/
  13991. _effect: Effect;
  13992. /** @hidden */
  13993. _textures: {
  13994. [key: string]: Texture;
  13995. };
  13996. private _size;
  13997. private _currentRefreshId;
  13998. private _refreshRate;
  13999. private _vertexBuffers;
  14000. private _indexBuffer;
  14001. private _uniforms;
  14002. private _samplers;
  14003. private _fragment;
  14004. private _floats;
  14005. private _ints;
  14006. private _floatsArrays;
  14007. private _colors3;
  14008. private _colors4;
  14009. private _vectors2;
  14010. private _vectors3;
  14011. private _matrices;
  14012. private _fallbackTexture;
  14013. private _fallbackTextureUsed;
  14014. private _engine;
  14015. private _cachedDefines;
  14016. private _contentUpdateId;
  14017. private _contentData;
  14018. /**
  14019. * Instantiates a new procedural texture.
  14020. * 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.
  14021. * This is the base class of any Procedural texture and contains most of the shareable code.
  14022. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14023. * @param name Define the name of the texture
  14024. * @param size Define the size of the texture to create
  14025. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14026. * @param scene Define the scene the texture belongs to
  14027. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14028. * @param generateMipMaps Define if the texture should creates mip maps or not
  14029. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14030. */
  14031. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14032. /**
  14033. * The effect that is created when initializing the post process.
  14034. * @returns The created effect corrisponding the the postprocess.
  14035. */
  14036. getEffect(): Effect;
  14037. /**
  14038. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14039. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14040. */
  14041. getContent(): Nullable<ArrayBufferView>;
  14042. private _createIndexBuffer;
  14043. /** @hidden */
  14044. _rebuild(): void;
  14045. /**
  14046. * Resets the texture in order to recreate its associated resources.
  14047. * This can be called in case of context loss
  14048. */
  14049. reset(): void;
  14050. protected _getDefines(): string;
  14051. /**
  14052. * Is the texture ready to be used ? (rendered at least once)
  14053. * @returns true if ready, otherwise, false.
  14054. */
  14055. isReady(): boolean;
  14056. /**
  14057. * Resets the refresh counter of the texture and start bak from scratch.
  14058. * Could be useful to regenerate the texture if it is setup to render only once.
  14059. */
  14060. resetRefreshCounter(): void;
  14061. /**
  14062. * Set the fragment shader to use in order to render the texture.
  14063. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14064. */
  14065. setFragment(fragment: any): void;
  14066. /**
  14067. * Define the refresh rate of the texture or the rendering frequency.
  14068. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14069. */
  14070. refreshRate: number;
  14071. /** @hidden */
  14072. _shouldRender(): boolean;
  14073. /**
  14074. * Get the size the texture is rendering at.
  14075. * @returns the size (texture is always squared)
  14076. */
  14077. getRenderSize(): number;
  14078. /**
  14079. * Resize the texture to new value.
  14080. * @param size Define the new size the texture should have
  14081. * @param generateMipMaps Define whether the new texture should create mip maps
  14082. */
  14083. resize(size: number, generateMipMaps: boolean): void;
  14084. private _checkUniform;
  14085. /**
  14086. * Set a texture in the shader program used to render.
  14087. * @param name Define the name of the uniform samplers as defined in the shader
  14088. * @param texture Define the texture to bind to this sampler
  14089. * @return the texture itself allowing "fluent" like uniform updates
  14090. */
  14091. setTexture(name: string, texture: Texture): ProceduralTexture;
  14092. /**
  14093. * Set a float in the shader.
  14094. * @param name Define the name of the uniform as defined in the shader
  14095. * @param value Define the value to give to the uniform
  14096. * @return the texture itself allowing "fluent" like uniform updates
  14097. */
  14098. setFloat(name: string, value: number): ProceduralTexture;
  14099. /**
  14100. * Set a int in the shader.
  14101. * @param name Define the name of the uniform as defined in the shader
  14102. * @param value Define the value to give to the uniform
  14103. * @return the texture itself allowing "fluent" like uniform updates
  14104. */
  14105. setInt(name: string, value: number): ProceduralTexture;
  14106. /**
  14107. * Set an array of floats in the shader.
  14108. * @param name Define the name of the uniform as defined in the shader
  14109. * @param value Define the value to give to the uniform
  14110. * @return the texture itself allowing "fluent" like uniform updates
  14111. */
  14112. setFloats(name: string, value: number[]): ProceduralTexture;
  14113. /**
  14114. * Set a vec3 in the shader from a Color3.
  14115. * @param name Define the name of the uniform as defined in the shader
  14116. * @param value Define the value to give to the uniform
  14117. * @return the texture itself allowing "fluent" like uniform updates
  14118. */
  14119. setColor3(name: string, value: Color3): ProceduralTexture;
  14120. /**
  14121. * Set a vec4 in the shader from a Color4.
  14122. * @param name Define the name of the uniform as defined in the shader
  14123. * @param value Define the value to give to the uniform
  14124. * @return the texture itself allowing "fluent" like uniform updates
  14125. */
  14126. setColor4(name: string, value: Color4): ProceduralTexture;
  14127. /**
  14128. * Set a vec2 in the shader from a Vector2.
  14129. * @param name Define the name of the uniform as defined in the shader
  14130. * @param value Define the value to give to the uniform
  14131. * @return the texture itself allowing "fluent" like uniform updates
  14132. */
  14133. setVector2(name: string, value: Vector2): ProceduralTexture;
  14134. /**
  14135. * Set a vec3 in the shader from a Vector3.
  14136. * @param name Define the name of the uniform as defined in the shader
  14137. * @param value Define the value to give to the uniform
  14138. * @return the texture itself allowing "fluent" like uniform updates
  14139. */
  14140. setVector3(name: string, value: Vector3): ProceduralTexture;
  14141. /**
  14142. * Set a mat4 in the shader from a MAtrix.
  14143. * @param name Define the name of the uniform as defined in the shader
  14144. * @param value Define the value to give to the uniform
  14145. * @return the texture itself allowing "fluent" like uniform updates
  14146. */
  14147. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14148. /**
  14149. * Render the texture to its associated render target.
  14150. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14151. */
  14152. render(useCameraPostProcess?: boolean): void;
  14153. /**
  14154. * Clone the texture.
  14155. * @returns the cloned texture
  14156. */
  14157. clone(): ProceduralTexture;
  14158. /**
  14159. * Dispose the texture and release its asoociated resources.
  14160. */
  14161. dispose(): void;
  14162. }
  14163. }
  14164. declare module "babylonjs/Particles/baseParticleSystem" {
  14165. import { Nullable } from "babylonjs/types";
  14166. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14168. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14169. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14170. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14171. import { Scene } from "babylonjs/scene";
  14172. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14173. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14174. import { Texture } from "babylonjs/Materials/Textures/texture";
  14175. import { Animation } from "babylonjs/Animations/animation";
  14176. /**
  14177. * This represents the base class for particle system in Babylon.
  14178. * 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.
  14179. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14180. * @example https://doc.babylonjs.com/babylon101/particles
  14181. */
  14182. export class BaseParticleSystem {
  14183. /**
  14184. * Source color is added to the destination color without alpha affecting the result
  14185. */
  14186. static BLENDMODE_ONEONE: number;
  14187. /**
  14188. * Blend current color and particle color using particle’s alpha
  14189. */
  14190. static BLENDMODE_STANDARD: number;
  14191. /**
  14192. * Add current color and particle color multiplied by particle’s alpha
  14193. */
  14194. static BLENDMODE_ADD: number;
  14195. /**
  14196. * Multiply current color with particle color
  14197. */
  14198. static BLENDMODE_MULTIPLY: number;
  14199. /**
  14200. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14201. */
  14202. static BLENDMODE_MULTIPLYADD: number;
  14203. /**
  14204. * List of animations used by the particle system.
  14205. */
  14206. animations: Animation[];
  14207. /**
  14208. * The id of the Particle system.
  14209. */
  14210. id: string;
  14211. /**
  14212. * The friendly name of the Particle system.
  14213. */
  14214. name: string;
  14215. /**
  14216. * The rendering group used by the Particle system to chose when to render.
  14217. */
  14218. renderingGroupId: number;
  14219. /**
  14220. * The emitter represents the Mesh or position we are attaching the particle system to.
  14221. */
  14222. emitter: Nullable<AbstractMesh | Vector3>;
  14223. /**
  14224. * The maximum number of particles to emit per frame
  14225. */
  14226. emitRate: number;
  14227. /**
  14228. * If you want to launch only a few particles at once, that can be done, as well.
  14229. */
  14230. manualEmitCount: number;
  14231. /**
  14232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14233. */
  14234. updateSpeed: number;
  14235. /**
  14236. * The amount of time the particle system is running (depends of the overall update speed).
  14237. */
  14238. targetStopDuration: number;
  14239. /**
  14240. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14241. */
  14242. disposeOnStop: boolean;
  14243. /**
  14244. * Minimum power of emitting particles.
  14245. */
  14246. minEmitPower: number;
  14247. /**
  14248. * Maximum power of emitting particles.
  14249. */
  14250. maxEmitPower: number;
  14251. /**
  14252. * Minimum life time of emitting particles.
  14253. */
  14254. minLifeTime: number;
  14255. /**
  14256. * Maximum life time of emitting particles.
  14257. */
  14258. maxLifeTime: number;
  14259. /**
  14260. * Minimum Size of emitting particles.
  14261. */
  14262. minSize: number;
  14263. /**
  14264. * Maximum Size of emitting particles.
  14265. */
  14266. maxSize: number;
  14267. /**
  14268. * Minimum scale of emitting particles on X axis.
  14269. */
  14270. minScaleX: number;
  14271. /**
  14272. * Maximum scale of emitting particles on X axis.
  14273. */
  14274. maxScaleX: number;
  14275. /**
  14276. * Minimum scale of emitting particles on Y axis.
  14277. */
  14278. minScaleY: number;
  14279. /**
  14280. * Maximum scale of emitting particles on Y axis.
  14281. */
  14282. maxScaleY: number;
  14283. /**
  14284. * Gets or sets the minimal initial rotation in radians.
  14285. */
  14286. minInitialRotation: number;
  14287. /**
  14288. * Gets or sets the maximal initial rotation in radians.
  14289. */
  14290. maxInitialRotation: number;
  14291. /**
  14292. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14293. */
  14294. minAngularSpeed: number;
  14295. /**
  14296. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14297. */
  14298. maxAngularSpeed: number;
  14299. /**
  14300. * The texture used to render each particle. (this can be a spritesheet)
  14301. */
  14302. particleTexture: Nullable<Texture>;
  14303. /**
  14304. * The layer mask we are rendering the particles through.
  14305. */
  14306. layerMask: number;
  14307. /**
  14308. * This can help using your own shader to render the particle system.
  14309. * The according effect will be created
  14310. */
  14311. customShader: any;
  14312. /**
  14313. * By default particle system starts as soon as they are created. This prevents the
  14314. * automatic start to happen and let you decide when to start emitting particles.
  14315. */
  14316. preventAutoStart: boolean;
  14317. private _noiseTexture;
  14318. /**
  14319. * Gets or sets a texture used to add random noise to particle positions
  14320. */
  14321. noiseTexture: Nullable<ProceduralTexture>;
  14322. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14323. noiseStrength: Vector3;
  14324. /**
  14325. * Callback triggered when the particle animation is ending.
  14326. */
  14327. onAnimationEnd: Nullable<() => void>;
  14328. /**
  14329. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14330. */
  14331. blendMode: number;
  14332. /**
  14333. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14334. * to override the particles.
  14335. */
  14336. forceDepthWrite: boolean;
  14337. /** 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 */
  14338. preWarmCycles: number;
  14339. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14340. preWarmStepOffset: number;
  14341. /**
  14342. * 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)
  14343. */
  14344. spriteCellChangeSpeed: number;
  14345. /**
  14346. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14347. */
  14348. startSpriteCellID: number;
  14349. /**
  14350. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14351. */
  14352. endSpriteCellID: number;
  14353. /**
  14354. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14355. */
  14356. spriteCellWidth: number;
  14357. /**
  14358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14359. */
  14360. spriteCellHeight: number;
  14361. /**
  14362. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14363. */
  14364. spriteRandomStartCell: boolean;
  14365. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14366. translationPivot: Vector2;
  14367. /** @hidden */
  14368. protected _isAnimationSheetEnabled: boolean;
  14369. /**
  14370. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14371. */
  14372. beginAnimationOnStart: boolean;
  14373. /**
  14374. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14375. */
  14376. beginAnimationFrom: number;
  14377. /**
  14378. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14379. */
  14380. beginAnimationTo: number;
  14381. /**
  14382. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14383. */
  14384. beginAnimationLoop: boolean;
  14385. /**
  14386. * Gets or sets a world offset applied to all particles
  14387. */
  14388. worldOffset: Vector3;
  14389. /**
  14390. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14391. */
  14392. isAnimationSheetEnabled: boolean;
  14393. /**
  14394. * Get hosting scene
  14395. * @returns the scene
  14396. */
  14397. getScene(): Scene;
  14398. /**
  14399. * You can use gravity if you want to give an orientation to your particles.
  14400. */
  14401. gravity: Vector3;
  14402. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14403. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14404. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14405. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14406. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14407. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14408. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14409. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14410. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14411. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14412. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14413. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14414. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14415. /**
  14416. * Defines the delay in milliseconds before starting the system (0 by default)
  14417. */
  14418. startDelay: number;
  14419. /**
  14420. * Gets the current list of drag gradients.
  14421. * You must use addDragGradient and removeDragGradient to udpate this list
  14422. * @returns the list of drag gradients
  14423. */
  14424. getDragGradients(): Nullable<Array<FactorGradient>>;
  14425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14426. limitVelocityDamping: number;
  14427. /**
  14428. * Gets the current list of limit velocity gradients.
  14429. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14430. * @returns the list of limit velocity gradients
  14431. */
  14432. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14433. /**
  14434. * Gets the current list of color gradients.
  14435. * You must use addColorGradient and removeColorGradient to udpate this list
  14436. * @returns the list of color gradients
  14437. */
  14438. getColorGradients(): Nullable<Array<ColorGradient>>;
  14439. /**
  14440. * Gets the current list of size gradients.
  14441. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14442. * @returns the list of size gradients
  14443. */
  14444. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14445. /**
  14446. * Gets the current list of color remap gradients.
  14447. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14448. * @returns the list of color remap gradients
  14449. */
  14450. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14451. /**
  14452. * Gets the current list of alpha remap gradients.
  14453. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14454. * @returns the list of alpha remap gradients
  14455. */
  14456. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14457. /**
  14458. * Gets the current list of life time gradients.
  14459. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14460. * @returns the list of life time gradients
  14461. */
  14462. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14463. /**
  14464. * Gets the current list of angular speed gradients.
  14465. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14466. * @returns the list of angular speed gradients
  14467. */
  14468. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14469. /**
  14470. * Gets the current list of velocity gradients.
  14471. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14472. * @returns the list of velocity gradients
  14473. */
  14474. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14475. /**
  14476. * Gets the current list of start size gradients.
  14477. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14478. * @returns the list of start size gradients
  14479. */
  14480. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of emit rate gradients.
  14483. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14484. * @returns the list of emit rate gradients
  14485. */
  14486. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14487. /**
  14488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14490. */
  14491. direction1: Vector3;
  14492. /**
  14493. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14495. */
  14496. direction2: Vector3;
  14497. /**
  14498. * 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.
  14499. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14500. */
  14501. minEmitBox: Vector3;
  14502. /**
  14503. * 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.
  14504. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14505. */
  14506. maxEmitBox: Vector3;
  14507. /**
  14508. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14509. */
  14510. color1: Color4;
  14511. /**
  14512. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14513. */
  14514. color2: Color4;
  14515. /**
  14516. * Color the particle will have at the end of its lifetime
  14517. */
  14518. colorDead: Color4;
  14519. /**
  14520. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14521. */
  14522. textureMask: Color4;
  14523. /**
  14524. * The particle emitter type defines the emitter used by the particle system.
  14525. * It can be for example box, sphere, or cone...
  14526. */
  14527. particleEmitterType: IParticleEmitterType;
  14528. /** @hidden */
  14529. _isSubEmitter: boolean;
  14530. /**
  14531. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14532. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14533. */
  14534. billboardMode: number;
  14535. protected _isBillboardBased: boolean;
  14536. /**
  14537. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14538. */
  14539. isBillboardBased: boolean;
  14540. /**
  14541. * The scene the particle system belongs to.
  14542. */
  14543. protected _scene: Scene;
  14544. /**
  14545. * Local cache of defines for image processing.
  14546. */
  14547. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14548. /**
  14549. * Default configuration related to image processing available in the standard Material.
  14550. */
  14551. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14552. /**
  14553. * Gets the image processing configuration used either in this material.
  14554. */
  14555. /**
  14556. * Sets the Default image processing configuration used either in the this material.
  14557. *
  14558. * If sets to null, the scene one is in use.
  14559. */
  14560. imageProcessingConfiguration: ImageProcessingConfiguration;
  14561. /**
  14562. * Attaches a new image processing configuration to the Standard Material.
  14563. * @param configuration
  14564. */
  14565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14566. /** @hidden */
  14567. protected _reset(): void;
  14568. /** @hidden */
  14569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14570. /**
  14571. * Instantiates a particle system.
  14572. * 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.
  14573. * @param name The name of the particle system
  14574. */
  14575. constructor(name: string);
  14576. /**
  14577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14580. * @returns the emitter
  14581. */
  14582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14583. /**
  14584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14585. * @param radius The radius of the hemisphere to emit from
  14586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14587. * @returns the emitter
  14588. */
  14589. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14590. /**
  14591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14592. * @param radius The radius of the sphere to emit from
  14593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14594. * @returns the emitter
  14595. */
  14596. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14597. /**
  14598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14599. * @param radius The radius of the sphere to emit from
  14600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14602. * @returns the emitter
  14603. */
  14604. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14605. /**
  14606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14607. * @param radius The radius of the emission cylinder
  14608. * @param height The height of the emission cylinder
  14609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14611. * @returns the emitter
  14612. */
  14613. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14614. /**
  14615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14616. * @param radius The radius of the cylinder to emit from
  14617. * @param height The height of the emission cylinder
  14618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14621. * @returns the emitter
  14622. */
  14623. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14624. /**
  14625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14626. * @param radius The radius of the cone to emit from
  14627. * @param angle The base angle of the cone
  14628. * @returns the emitter
  14629. */
  14630. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14631. /**
  14632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14637. * @returns the emitter
  14638. */
  14639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14640. }
  14641. }
  14642. declare module "babylonjs/Particles/subEmitter" {
  14643. import { Scene } from "babylonjs/scene";
  14644. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14645. /**
  14646. * Type of sub emitter
  14647. */
  14648. export enum SubEmitterType {
  14649. /**
  14650. * Attached to the particle over it's lifetime
  14651. */
  14652. ATTACHED = 0,
  14653. /**
  14654. * Created when the particle dies
  14655. */
  14656. END = 1
  14657. }
  14658. /**
  14659. * Sub emitter class used to emit particles from an existing particle
  14660. */
  14661. export class SubEmitter {
  14662. /**
  14663. * the particle system to be used by the sub emitter
  14664. */
  14665. particleSystem: ParticleSystem;
  14666. /**
  14667. * Type of the submitter (Default: END)
  14668. */
  14669. type: SubEmitterType;
  14670. /**
  14671. * 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)
  14672. * Note: This only is supported when using an emitter of type Mesh
  14673. */
  14674. inheritDirection: boolean;
  14675. /**
  14676. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14677. */
  14678. inheritedVelocityAmount: number;
  14679. /**
  14680. * Creates a sub emitter
  14681. * @param particleSystem the particle system to be used by the sub emitter
  14682. */
  14683. constructor(
  14684. /**
  14685. * the particle system to be used by the sub emitter
  14686. */
  14687. particleSystem: ParticleSystem);
  14688. /**
  14689. * Clones the sub emitter
  14690. * @returns the cloned sub emitter
  14691. */
  14692. clone(): SubEmitter;
  14693. /**
  14694. * Serialize current object to a JSON object
  14695. * @returns the serialized object
  14696. */
  14697. serialize(): any;
  14698. /** @hidden */
  14699. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14700. /**
  14701. * Creates a new SubEmitter from a serialized JSON version
  14702. * @param serializationObject defines the JSON object to read from
  14703. * @param scene defines the hosting scene
  14704. * @param rootUrl defines the rootUrl for data loading
  14705. * @returns a new SubEmitter
  14706. */
  14707. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14708. /** Release associated resources */
  14709. dispose(): void;
  14710. }
  14711. }
  14712. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14713. /** @hidden */
  14714. export var clipPlaneFragmentDeclaration: {
  14715. name: string;
  14716. shader: string;
  14717. };
  14718. }
  14719. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14720. /** @hidden */
  14721. export var imageProcessingDeclaration: {
  14722. name: string;
  14723. shader: string;
  14724. };
  14725. }
  14726. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14727. /** @hidden */
  14728. export var imageProcessingFunctions: {
  14729. name: string;
  14730. shader: string;
  14731. };
  14732. }
  14733. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14734. /** @hidden */
  14735. export var clipPlaneFragment: {
  14736. name: string;
  14737. shader: string;
  14738. };
  14739. }
  14740. declare module "babylonjs/Shaders/particles.fragment" {
  14741. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14742. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14744. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14745. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14746. /** @hidden */
  14747. export var particlesPixelShader: {
  14748. name: string;
  14749. shader: string;
  14750. };
  14751. }
  14752. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14753. /** @hidden */
  14754. export var clipPlaneVertexDeclaration: {
  14755. name: string;
  14756. shader: string;
  14757. };
  14758. }
  14759. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14760. /** @hidden */
  14761. export var clipPlaneVertex: {
  14762. name: string;
  14763. shader: string;
  14764. };
  14765. }
  14766. declare module "babylonjs/Shaders/particles.vertex" {
  14767. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14768. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14769. /** @hidden */
  14770. export var particlesVertexShader: {
  14771. name: string;
  14772. shader: string;
  14773. };
  14774. }
  14775. declare module "babylonjs/Particles/particleSystem" {
  14776. import { Nullable } from "babylonjs/types";
  14777. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14778. import { Observable } from "babylonjs/Misc/observable";
  14779. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14780. import { Effect } from "babylonjs/Materials/effect";
  14781. import { Scene, IDisposable } from "babylonjs/scene";
  14782. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14783. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14784. import { Particle } from "babylonjs/Particles/particle";
  14785. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14786. import "babylonjs/Shaders/particles.fragment";
  14787. import "babylonjs/Shaders/particles.vertex";
  14788. /**
  14789. * This represents a particle system in Babylon.
  14790. * 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.
  14791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14792. * @example https://doc.babylonjs.com/babylon101/particles
  14793. */
  14794. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14795. /**
  14796. * Billboard mode will only apply to Y axis
  14797. */
  14798. static readonly BILLBOARDMODE_Y: number;
  14799. /**
  14800. * Billboard mode will apply to all axes
  14801. */
  14802. static readonly BILLBOARDMODE_ALL: number;
  14803. /**
  14804. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14805. */
  14806. static readonly BILLBOARDMODE_STRETCHED: number;
  14807. /**
  14808. * This function can be defined to provide custom update for active particles.
  14809. * This function will be called instead of regular update (age, position, color, etc.).
  14810. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14811. */
  14812. updateFunction: (particles: Particle[]) => void;
  14813. private _emitterWorldMatrix;
  14814. /**
  14815. * This function can be defined to specify initial direction for every new particle.
  14816. * It by default use the emitterType defined function
  14817. */
  14818. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14819. /**
  14820. * This function can be defined to specify initial position for every new particle.
  14821. * It by default use the emitterType defined function
  14822. */
  14823. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14824. /**
  14825. * @hidden
  14826. */
  14827. _inheritedVelocityOffset: Vector3;
  14828. /**
  14829. * An event triggered when the system is disposed
  14830. */
  14831. onDisposeObservable: Observable<ParticleSystem>;
  14832. private _onDisposeObserver;
  14833. /**
  14834. * Sets a callback that will be triggered when the system is disposed
  14835. */
  14836. onDispose: () => void;
  14837. private _particles;
  14838. private _epsilon;
  14839. private _capacity;
  14840. private _stockParticles;
  14841. private _newPartsExcess;
  14842. private _vertexData;
  14843. private _vertexBuffer;
  14844. private _vertexBuffers;
  14845. private _spriteBuffer;
  14846. private _indexBuffer;
  14847. private _effect;
  14848. private _customEffect;
  14849. private _cachedDefines;
  14850. private _scaledColorStep;
  14851. private _colorDiff;
  14852. private _scaledDirection;
  14853. private _scaledGravity;
  14854. private _currentRenderId;
  14855. private _alive;
  14856. private _useInstancing;
  14857. private _started;
  14858. private _stopped;
  14859. private _actualFrame;
  14860. private _scaledUpdateSpeed;
  14861. private _vertexBufferSize;
  14862. /** @hidden */
  14863. _currentEmitRateGradient: Nullable<FactorGradient>;
  14864. /** @hidden */
  14865. _currentEmitRate1: number;
  14866. /** @hidden */
  14867. _currentEmitRate2: number;
  14868. /** @hidden */
  14869. _currentStartSizeGradient: Nullable<FactorGradient>;
  14870. /** @hidden */
  14871. _currentStartSize1: number;
  14872. /** @hidden */
  14873. _currentStartSize2: number;
  14874. private readonly _rawTextureWidth;
  14875. private _rampGradientsTexture;
  14876. private _useRampGradients;
  14877. /** Gets or sets a boolean indicating that ramp gradients must be used
  14878. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14879. */
  14880. useRampGradients: boolean;
  14881. /**
  14882. * 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.
  14883. * 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: [])
  14884. */
  14885. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14886. private _subEmitters;
  14887. /**
  14888. * @hidden
  14889. * If the particle systems emitter should be disposed when the particle system is disposed
  14890. */
  14891. _disposeEmitterOnDispose: boolean;
  14892. /**
  14893. * The current active Sub-systems, this property is used by the root particle system only.
  14894. */
  14895. activeSubSystems: Array<ParticleSystem>;
  14896. private _rootParticleSystem;
  14897. /**
  14898. * Gets the current list of active particles
  14899. */
  14900. readonly particles: Particle[];
  14901. /**
  14902. * Returns the string "ParticleSystem"
  14903. * @returns a string containing the class name
  14904. */
  14905. getClassName(): string;
  14906. /**
  14907. * Instantiates a particle system.
  14908. * 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.
  14909. * @param name The name of the particle system
  14910. * @param capacity The max number of particles alive at the same time
  14911. * @param scene The scene the particle system belongs to
  14912. * @param customEffect a custom effect used to change the way particles are rendered by default
  14913. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14914. * @param epsilon Offset used to render the particles
  14915. */
  14916. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14917. private _addFactorGradient;
  14918. private _removeFactorGradient;
  14919. /**
  14920. * Adds a new life time gradient
  14921. * @param gradient defines the gradient to use (between 0 and 1)
  14922. * @param factor defines the life time factor to affect to the specified gradient
  14923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14924. * @returns the current particle system
  14925. */
  14926. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14927. /**
  14928. * Remove a specific life time gradient
  14929. * @param gradient defines the gradient to remove
  14930. * @returns the current particle system
  14931. */
  14932. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14933. /**
  14934. * Adds a new size gradient
  14935. * @param gradient defines the gradient to use (between 0 and 1)
  14936. * @param factor defines the size factor to affect to the specified gradient
  14937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14938. * @returns the current particle system
  14939. */
  14940. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14941. /**
  14942. * Remove a specific size gradient
  14943. * @param gradient defines the gradient to remove
  14944. * @returns the current particle system
  14945. */
  14946. removeSizeGradient(gradient: number): IParticleSystem;
  14947. /**
  14948. * Adds a new color remap gradient
  14949. * @param gradient defines the gradient to use (between 0 and 1)
  14950. * @param min defines the color remap minimal range
  14951. * @param max defines the color remap maximal range
  14952. * @returns the current particle system
  14953. */
  14954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14955. /**
  14956. * Remove a specific color remap gradient
  14957. * @param gradient defines the gradient to remove
  14958. * @returns the current particle system
  14959. */
  14960. removeColorRemapGradient(gradient: number): IParticleSystem;
  14961. /**
  14962. * Adds a new alpha remap gradient
  14963. * @param gradient defines the gradient to use (between 0 and 1)
  14964. * @param min defines the alpha remap minimal range
  14965. * @param max defines the alpha remap maximal range
  14966. * @returns the current particle system
  14967. */
  14968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14969. /**
  14970. * Remove a specific alpha remap gradient
  14971. * @param gradient defines the gradient to remove
  14972. * @returns the current particle system
  14973. */
  14974. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14975. /**
  14976. * Adds a new angular speed gradient
  14977. * @param gradient defines the gradient to use (between 0 and 1)
  14978. * @param factor defines the angular speed to affect to the specified gradient
  14979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14980. * @returns the current particle system
  14981. */
  14982. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14983. /**
  14984. * Remove a specific angular speed gradient
  14985. * @param gradient defines the gradient to remove
  14986. * @returns the current particle system
  14987. */
  14988. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14989. /**
  14990. * Adds a new velocity gradient
  14991. * @param gradient defines the gradient to use (between 0 and 1)
  14992. * @param factor defines the velocity to affect to the specified gradient
  14993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14994. * @returns the current particle system
  14995. */
  14996. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14997. /**
  14998. * Remove a specific velocity gradient
  14999. * @param gradient defines the gradient to remove
  15000. * @returns the current particle system
  15001. */
  15002. removeVelocityGradient(gradient: number): IParticleSystem;
  15003. /**
  15004. * Adds a new limit velocity gradient
  15005. * @param gradient defines the gradient to use (between 0 and 1)
  15006. * @param factor defines the limit velocity value to affect to the specified gradient
  15007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15008. * @returns the current particle system
  15009. */
  15010. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15011. /**
  15012. * Remove a specific limit velocity gradient
  15013. * @param gradient defines the gradient to remove
  15014. * @returns the current particle system
  15015. */
  15016. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15017. /**
  15018. * Adds a new drag gradient
  15019. * @param gradient defines the gradient to use (between 0 and 1)
  15020. * @param factor defines the drag value to affect to the specified gradient
  15021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15022. * @returns the current particle system
  15023. */
  15024. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15025. /**
  15026. * Remove a specific drag gradient
  15027. * @param gradient defines the gradient to remove
  15028. * @returns the current particle system
  15029. */
  15030. removeDragGradient(gradient: number): IParticleSystem;
  15031. /**
  15032. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15033. * @param gradient defines the gradient to use (between 0 and 1)
  15034. * @param factor defines the emit rate value to affect to the specified gradient
  15035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15036. * @returns the current particle system
  15037. */
  15038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15039. /**
  15040. * Remove a specific emit rate gradient
  15041. * @param gradient defines the gradient to remove
  15042. * @returns the current particle system
  15043. */
  15044. removeEmitRateGradient(gradient: number): IParticleSystem;
  15045. /**
  15046. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15047. * @param gradient defines the gradient to use (between 0 and 1)
  15048. * @param factor defines the start size value to affect to the specified gradient
  15049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15050. * @returns the current particle system
  15051. */
  15052. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15053. /**
  15054. * Remove a specific start size gradient
  15055. * @param gradient defines the gradient to remove
  15056. * @returns the current particle system
  15057. */
  15058. removeStartSizeGradient(gradient: number): IParticleSystem;
  15059. private _createRampGradientTexture;
  15060. /**
  15061. * Gets the current list of ramp gradients.
  15062. * You must use addRampGradient and removeRampGradient to udpate this list
  15063. * @returns the list of ramp gradients
  15064. */
  15065. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15066. /**
  15067. * Adds a new ramp gradient used to remap particle colors
  15068. * @param gradient defines the gradient to use (between 0 and 1)
  15069. * @param color defines the color to affect to the specified gradient
  15070. * @returns the current particle system
  15071. */
  15072. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15073. /**
  15074. * Remove a specific ramp gradient
  15075. * @param gradient defines the gradient to remove
  15076. * @returns the current particle system
  15077. */
  15078. removeRampGradient(gradient: number): ParticleSystem;
  15079. /**
  15080. * Adds a new color gradient
  15081. * @param gradient defines the gradient to use (between 0 and 1)
  15082. * @param color1 defines the color to affect to the specified gradient
  15083. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15084. * @returns this particle system
  15085. */
  15086. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15087. /**
  15088. * Remove a specific color gradient
  15089. * @param gradient defines the gradient to remove
  15090. * @returns this particle system
  15091. */
  15092. removeColorGradient(gradient: number): IParticleSystem;
  15093. private _fetchR;
  15094. protected _reset(): void;
  15095. private _resetEffect;
  15096. private _createVertexBuffers;
  15097. private _createIndexBuffer;
  15098. /**
  15099. * Gets the maximum number of particles active at the same time.
  15100. * @returns The max number of active particles.
  15101. */
  15102. getCapacity(): number;
  15103. /**
  15104. * Gets whether there are still active particles in the system.
  15105. * @returns True if it is alive, otherwise false.
  15106. */
  15107. isAlive(): boolean;
  15108. /**
  15109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15110. * @returns True if it has been started, otherwise false.
  15111. */
  15112. isStarted(): boolean;
  15113. private _prepareSubEmitterInternalArray;
  15114. /**
  15115. * Starts the particle system and begins to emit
  15116. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15117. */
  15118. start(delay?: number): void;
  15119. /**
  15120. * Stops the particle system.
  15121. * @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.
  15122. */
  15123. stop(stopSubEmitters?: boolean): void;
  15124. /**
  15125. * Remove all active particles
  15126. */
  15127. reset(): void;
  15128. /**
  15129. * @hidden (for internal use only)
  15130. */
  15131. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15132. /**
  15133. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15134. * Its lifetime will start back at 0.
  15135. */
  15136. recycleParticle: (particle: Particle) => void;
  15137. private _stopSubEmitters;
  15138. private _createParticle;
  15139. private _removeFromRoot;
  15140. private _emitFromParticle;
  15141. private _update;
  15142. /** @hidden */
  15143. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15144. /** @hidden */
  15145. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15146. /** @hidden */
  15147. private _getEffect;
  15148. /**
  15149. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15150. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15151. */
  15152. animate(preWarmOnly?: boolean): void;
  15153. private _appendParticleVertices;
  15154. /**
  15155. * Rebuilds the particle system.
  15156. */
  15157. rebuild(): void;
  15158. /**
  15159. * Is this system ready to be used/rendered
  15160. * @return true if the system is ready
  15161. */
  15162. isReady(): boolean;
  15163. private _render;
  15164. /**
  15165. * Renders the particle system in its current state.
  15166. * @returns the current number of particles
  15167. */
  15168. render(): number;
  15169. /**
  15170. * Disposes the particle system and free the associated resources
  15171. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15172. */
  15173. dispose(disposeTexture?: boolean): void;
  15174. /**
  15175. * Clones the particle system.
  15176. * @param name The name of the cloned object
  15177. * @param newEmitter The new emitter to use
  15178. * @returns the cloned particle system
  15179. */
  15180. clone(name: string, newEmitter: any): ParticleSystem;
  15181. /**
  15182. * Serializes the particle system to a JSON object.
  15183. * @returns the JSON object
  15184. */
  15185. serialize(): any;
  15186. /** @hidden */
  15187. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15188. /** @hidden */
  15189. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15190. /**
  15191. * Parses a JSON object to create a particle system.
  15192. * @param parsedParticleSystem The JSON object to parse
  15193. * @param scene The scene to create the particle system in
  15194. * @param rootUrl The root url to use to load external dependencies like texture
  15195. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15196. * @returns the Parsed particle system
  15197. */
  15198. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15199. }
  15200. }
  15201. declare module "babylonjs/Particles/particle" {
  15202. import { Nullable } from "babylonjs/types";
  15203. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15204. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15205. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15206. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15207. /**
  15208. * A particle represents one of the element emitted by a particle system.
  15209. * This is mainly define by its coordinates, direction, velocity and age.
  15210. */
  15211. export class Particle {
  15212. /**
  15213. * The particle system the particle belongs to.
  15214. */
  15215. particleSystem: ParticleSystem;
  15216. private static _Count;
  15217. /**
  15218. * Unique ID of the particle
  15219. */
  15220. id: number;
  15221. /**
  15222. * The world position of the particle in the scene.
  15223. */
  15224. position: Vector3;
  15225. /**
  15226. * The world direction of the particle in the scene.
  15227. */
  15228. direction: Vector3;
  15229. /**
  15230. * The color of the particle.
  15231. */
  15232. color: Color4;
  15233. /**
  15234. * The color change of the particle per step.
  15235. */
  15236. colorStep: Color4;
  15237. /**
  15238. * Defines how long will the life of the particle be.
  15239. */
  15240. lifeTime: number;
  15241. /**
  15242. * The current age of the particle.
  15243. */
  15244. age: number;
  15245. /**
  15246. * The current size of the particle.
  15247. */
  15248. size: number;
  15249. /**
  15250. * The current scale of the particle.
  15251. */
  15252. scale: Vector2;
  15253. /**
  15254. * The current angle of the particle.
  15255. */
  15256. angle: number;
  15257. /**
  15258. * Defines how fast is the angle changing.
  15259. */
  15260. angularSpeed: number;
  15261. /**
  15262. * Defines the cell index used by the particle to be rendered from a sprite.
  15263. */
  15264. cellIndex: number;
  15265. /**
  15266. * The information required to support color remapping
  15267. */
  15268. remapData: Vector4;
  15269. /** @hidden */
  15270. _randomCellOffset?: number;
  15271. /** @hidden */
  15272. _initialDirection: Nullable<Vector3>;
  15273. /** @hidden */
  15274. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15275. /** @hidden */
  15276. _initialStartSpriteCellID: number;
  15277. /** @hidden */
  15278. _initialEndSpriteCellID: number;
  15279. /** @hidden */
  15280. _currentColorGradient: Nullable<ColorGradient>;
  15281. /** @hidden */
  15282. _currentColor1: Color4;
  15283. /** @hidden */
  15284. _currentColor2: Color4;
  15285. /** @hidden */
  15286. _currentSizeGradient: Nullable<FactorGradient>;
  15287. /** @hidden */
  15288. _currentSize1: number;
  15289. /** @hidden */
  15290. _currentSize2: number;
  15291. /** @hidden */
  15292. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15293. /** @hidden */
  15294. _currentAngularSpeed1: number;
  15295. /** @hidden */
  15296. _currentAngularSpeed2: number;
  15297. /** @hidden */
  15298. _currentVelocityGradient: Nullable<FactorGradient>;
  15299. /** @hidden */
  15300. _currentVelocity1: number;
  15301. /** @hidden */
  15302. _currentVelocity2: number;
  15303. /** @hidden */
  15304. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15305. /** @hidden */
  15306. _currentLimitVelocity1: number;
  15307. /** @hidden */
  15308. _currentLimitVelocity2: number;
  15309. /** @hidden */
  15310. _currentDragGradient: Nullable<FactorGradient>;
  15311. /** @hidden */
  15312. _currentDrag1: number;
  15313. /** @hidden */
  15314. _currentDrag2: number;
  15315. /** @hidden */
  15316. _randomNoiseCoordinates1: Vector3;
  15317. /** @hidden */
  15318. _randomNoiseCoordinates2: Vector3;
  15319. /**
  15320. * Creates a new instance Particle
  15321. * @param particleSystem the particle system the particle belongs to
  15322. */
  15323. constructor(
  15324. /**
  15325. * The particle system the particle belongs to.
  15326. */
  15327. particleSystem: ParticleSystem);
  15328. private updateCellInfoFromSystem;
  15329. /**
  15330. * Defines how the sprite cell index is updated for the particle
  15331. */
  15332. updateCellIndex(): void;
  15333. /** @hidden */
  15334. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15335. /** @hidden */
  15336. _inheritParticleInfoToSubEmitters(): void;
  15337. /** @hidden */
  15338. _reset(): void;
  15339. /**
  15340. * Copy the properties of particle to another one.
  15341. * @param other the particle to copy the information to.
  15342. */
  15343. copyTo(other: Particle): void;
  15344. }
  15345. }
  15346. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15347. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15348. import { Effect } from "babylonjs/Materials/effect";
  15349. import { Particle } from "babylonjs/Particles/particle";
  15350. /**
  15351. * Particle emitter represents a volume emitting particles.
  15352. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15353. */
  15354. export interface IParticleEmitterType {
  15355. /**
  15356. * Called by the particle System when the direction is computed for the created particle.
  15357. * @param worldMatrix is the world matrix of the particle system
  15358. * @param directionToUpdate is the direction vector to update with the result
  15359. * @param particle is the particle we are computed the direction for
  15360. */
  15361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15362. /**
  15363. * Called by the particle System when the position is computed for the created particle.
  15364. * @param worldMatrix is the world matrix of the particle system
  15365. * @param positionToUpdate is the position vector to update with the result
  15366. * @param particle is the particle we are computed the position for
  15367. */
  15368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15369. /**
  15370. * Clones the current emitter and returns a copy of it
  15371. * @returns the new emitter
  15372. */
  15373. clone(): IParticleEmitterType;
  15374. /**
  15375. * Called by the GPUParticleSystem to setup the update shader
  15376. * @param effect defines the update shader
  15377. */
  15378. applyToShader(effect: Effect): void;
  15379. /**
  15380. * Returns a string to use to update the GPU particles update shader
  15381. * @returns the effect defines string
  15382. */
  15383. getEffectDefines(): string;
  15384. /**
  15385. * Returns a string representing the class name
  15386. * @returns a string containing the class name
  15387. */
  15388. getClassName(): string;
  15389. /**
  15390. * Serializes the particle system to a JSON object.
  15391. * @returns the JSON object
  15392. */
  15393. serialize(): any;
  15394. /**
  15395. * Parse properties from a JSON object
  15396. * @param serializationObject defines the JSON object
  15397. */
  15398. parse(serializationObject: any): void;
  15399. }
  15400. }
  15401. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15402. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15403. import { Effect } from "babylonjs/Materials/effect";
  15404. import { Particle } from "babylonjs/Particles/particle";
  15405. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15406. /**
  15407. * Particle emitter emitting particles from the inside of a box.
  15408. * It emits the particles randomly between 2 given directions.
  15409. */
  15410. export class BoxParticleEmitter implements IParticleEmitterType {
  15411. /**
  15412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15413. */
  15414. direction1: Vector3;
  15415. /**
  15416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15417. */
  15418. direction2: Vector3;
  15419. /**
  15420. * 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.
  15421. */
  15422. minEmitBox: Vector3;
  15423. /**
  15424. * 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.
  15425. */
  15426. maxEmitBox: Vector3;
  15427. /**
  15428. * Creates a new instance BoxParticleEmitter
  15429. */
  15430. constructor();
  15431. /**
  15432. * Called by the particle System when the direction is computed for the created particle.
  15433. * @param worldMatrix is the world matrix of the particle system
  15434. * @param directionToUpdate is the direction vector to update with the result
  15435. * @param particle is the particle we are computed the direction for
  15436. */
  15437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15438. /**
  15439. * Called by the particle System when the position is computed for the created particle.
  15440. * @param worldMatrix is the world matrix of the particle system
  15441. * @param positionToUpdate is the position vector to update with the result
  15442. * @param particle is the particle we are computed the position for
  15443. */
  15444. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15445. /**
  15446. * Clones the current emitter and returns a copy of it
  15447. * @returns the new emitter
  15448. */
  15449. clone(): BoxParticleEmitter;
  15450. /**
  15451. * Called by the GPUParticleSystem to setup the update shader
  15452. * @param effect defines the update shader
  15453. */
  15454. applyToShader(effect: Effect): void;
  15455. /**
  15456. * Returns a string to use to update the GPU particles update shader
  15457. * @returns a string containng the defines string
  15458. */
  15459. getEffectDefines(): string;
  15460. /**
  15461. * Returns the string "BoxParticleEmitter"
  15462. * @returns a string containing the class name
  15463. */
  15464. getClassName(): string;
  15465. /**
  15466. * Serializes the particle system to a JSON object.
  15467. * @returns the JSON object
  15468. */
  15469. serialize(): any;
  15470. /**
  15471. * Parse properties from a JSON object
  15472. * @param serializationObject defines the JSON object
  15473. */
  15474. parse(serializationObject: any): void;
  15475. }
  15476. }
  15477. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15478. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15479. import { Effect } from "babylonjs/Materials/effect";
  15480. import { Particle } from "babylonjs/Particles/particle";
  15481. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15482. /**
  15483. * Particle emitter emitting particles from the inside of a cone.
  15484. * It emits the particles alongside the cone volume from the base to the particle.
  15485. * The emission direction might be randomized.
  15486. */
  15487. export class ConeParticleEmitter implements IParticleEmitterType {
  15488. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15489. directionRandomizer: number;
  15490. private _radius;
  15491. private _angle;
  15492. private _height;
  15493. /**
  15494. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15495. */
  15496. radiusRange: number;
  15497. /**
  15498. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15499. */
  15500. heightRange: number;
  15501. /**
  15502. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15503. */
  15504. emitFromSpawnPointOnly: boolean;
  15505. /**
  15506. * Gets or sets the radius of the emission cone
  15507. */
  15508. radius: number;
  15509. /**
  15510. * Gets or sets the angle of the emission cone
  15511. */
  15512. angle: number;
  15513. private _buildHeight;
  15514. /**
  15515. * Creates a new instance ConeParticleEmitter
  15516. * @param radius the radius of the emission cone (1 by default)
  15517. * @param angle the cone base angle (PI by default)
  15518. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15519. */
  15520. constructor(radius?: number, angle?: number,
  15521. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15522. directionRandomizer?: number);
  15523. /**
  15524. * Called by the particle System when the direction is computed for the created particle.
  15525. * @param worldMatrix is the world matrix of the particle system
  15526. * @param directionToUpdate is the direction vector to update with the result
  15527. * @param particle is the particle we are computed the direction for
  15528. */
  15529. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15530. /**
  15531. * Called by the particle System when the position is computed for the created particle.
  15532. * @param worldMatrix is the world matrix of the particle system
  15533. * @param positionToUpdate is the position vector to update with the result
  15534. * @param particle is the particle we are computed the position for
  15535. */
  15536. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15537. /**
  15538. * Clones the current emitter and returns a copy of it
  15539. * @returns the new emitter
  15540. */
  15541. clone(): ConeParticleEmitter;
  15542. /**
  15543. * Called by the GPUParticleSystem to setup the update shader
  15544. * @param effect defines the update shader
  15545. */
  15546. applyToShader(effect: Effect): void;
  15547. /**
  15548. * Returns a string to use to update the GPU particles update shader
  15549. * @returns a string containng the defines string
  15550. */
  15551. getEffectDefines(): string;
  15552. /**
  15553. * Returns the string "ConeParticleEmitter"
  15554. * @returns a string containing the class name
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Serializes the particle system to a JSON object.
  15559. * @returns the JSON object
  15560. */
  15561. serialize(): any;
  15562. /**
  15563. * Parse properties from a JSON object
  15564. * @param serializationObject defines the JSON object
  15565. */
  15566. parse(serializationObject: any): void;
  15567. }
  15568. }
  15569. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15570. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15571. import { Effect } from "babylonjs/Materials/effect";
  15572. import { Particle } from "babylonjs/Particles/particle";
  15573. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15574. /**
  15575. * Particle emitter emitting particles from the inside of a cylinder.
  15576. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15577. */
  15578. export class CylinderParticleEmitter implements IParticleEmitterType {
  15579. /**
  15580. * The radius of the emission cylinder.
  15581. */
  15582. radius: number;
  15583. /**
  15584. * The height of the emission cylinder.
  15585. */
  15586. height: number;
  15587. /**
  15588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15589. */
  15590. radiusRange: number;
  15591. /**
  15592. * How much to randomize the particle direction [0-1].
  15593. */
  15594. directionRandomizer: number;
  15595. /**
  15596. * Creates a new instance CylinderParticleEmitter
  15597. * @param radius the radius of the emission cylinder (1 by default)
  15598. * @param height the height of the emission cylinder (1 by default)
  15599. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15600. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15601. */
  15602. constructor(
  15603. /**
  15604. * The radius of the emission cylinder.
  15605. */
  15606. radius?: number,
  15607. /**
  15608. * The height of the emission cylinder.
  15609. */
  15610. height?: number,
  15611. /**
  15612. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15613. */
  15614. radiusRange?: number,
  15615. /**
  15616. * How much to randomize the particle direction [0-1].
  15617. */
  15618. directionRandomizer?: number);
  15619. /**
  15620. * Called by the particle System when the direction is computed for the created particle.
  15621. * @param worldMatrix is the world matrix of the particle system
  15622. * @param directionToUpdate is the direction vector to update with the result
  15623. * @param particle is the particle we are computed the direction for
  15624. */
  15625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15626. /**
  15627. * Called by the particle System when the position is computed for the created particle.
  15628. * @param worldMatrix is the world matrix of the particle system
  15629. * @param positionToUpdate is the position vector to update with the result
  15630. * @param particle is the particle we are computed the position for
  15631. */
  15632. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15633. /**
  15634. * Clones the current emitter and returns a copy of it
  15635. * @returns the new emitter
  15636. */
  15637. clone(): CylinderParticleEmitter;
  15638. /**
  15639. * Called by the GPUParticleSystem to setup the update shader
  15640. * @param effect defines the update shader
  15641. */
  15642. applyToShader(effect: Effect): void;
  15643. /**
  15644. * Returns a string to use to update the GPU particles update shader
  15645. * @returns a string containng the defines string
  15646. */
  15647. getEffectDefines(): string;
  15648. /**
  15649. * Returns the string "CylinderParticleEmitter"
  15650. * @returns a string containing the class name
  15651. */
  15652. getClassName(): string;
  15653. /**
  15654. * Serializes the particle system to a JSON object.
  15655. * @returns the JSON object
  15656. */
  15657. serialize(): any;
  15658. /**
  15659. * Parse properties from a JSON object
  15660. * @param serializationObject defines the JSON object
  15661. */
  15662. parse(serializationObject: any): void;
  15663. }
  15664. /**
  15665. * Particle emitter emitting particles from the inside of a cylinder.
  15666. * It emits the particles randomly between two vectors.
  15667. */
  15668. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15669. /**
  15670. * The min limit of the emission direction.
  15671. */
  15672. direction1: Vector3;
  15673. /**
  15674. * The max limit of the emission direction.
  15675. */
  15676. direction2: Vector3;
  15677. /**
  15678. * Creates a new instance CylinderDirectedParticleEmitter
  15679. * @param radius the radius of the emission cylinder (1 by default)
  15680. * @param height the height of the emission cylinder (1 by default)
  15681. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15682. * @param direction1 the min limit of the emission direction (up vector by default)
  15683. * @param direction2 the max limit of the emission direction (up vector by default)
  15684. */
  15685. constructor(radius?: number, height?: number, radiusRange?: number,
  15686. /**
  15687. * The min limit of the emission direction.
  15688. */
  15689. direction1?: Vector3,
  15690. /**
  15691. * The max limit of the emission direction.
  15692. */
  15693. direction2?: Vector3);
  15694. /**
  15695. * Called by the particle System when the direction is computed for the created particle.
  15696. * @param worldMatrix is the world matrix of the particle system
  15697. * @param directionToUpdate is the direction vector to update with the result
  15698. * @param particle is the particle we are computed the direction for
  15699. */
  15700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15701. /**
  15702. * Clones the current emitter and returns a copy of it
  15703. * @returns the new emitter
  15704. */
  15705. clone(): CylinderDirectedParticleEmitter;
  15706. /**
  15707. * Called by the GPUParticleSystem to setup the update shader
  15708. * @param effect defines the update shader
  15709. */
  15710. applyToShader(effect: Effect): void;
  15711. /**
  15712. * Returns a string to use to update the GPU particles update shader
  15713. * @returns a string containng the defines string
  15714. */
  15715. getEffectDefines(): string;
  15716. /**
  15717. * Returns the string "CylinderDirectedParticleEmitter"
  15718. * @returns a string containing the class name
  15719. */
  15720. getClassName(): string;
  15721. /**
  15722. * Serializes the particle system to a JSON object.
  15723. * @returns the JSON object
  15724. */
  15725. serialize(): any;
  15726. /**
  15727. * Parse properties from a JSON object
  15728. * @param serializationObject defines the JSON object
  15729. */
  15730. parse(serializationObject: any): void;
  15731. }
  15732. }
  15733. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15734. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15735. import { Effect } from "babylonjs/Materials/effect";
  15736. import { Particle } from "babylonjs/Particles/particle";
  15737. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15738. /**
  15739. * Particle emitter emitting particles from the inside of a hemisphere.
  15740. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15741. */
  15742. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15743. /**
  15744. * The radius of the emission hemisphere.
  15745. */
  15746. radius: number;
  15747. /**
  15748. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15749. */
  15750. radiusRange: number;
  15751. /**
  15752. * How much to randomize the particle direction [0-1].
  15753. */
  15754. directionRandomizer: number;
  15755. /**
  15756. * Creates a new instance HemisphericParticleEmitter
  15757. * @param radius the radius of the emission hemisphere (1 by default)
  15758. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15759. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15760. */
  15761. constructor(
  15762. /**
  15763. * The radius of the emission hemisphere.
  15764. */
  15765. radius?: number,
  15766. /**
  15767. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15768. */
  15769. radiusRange?: number,
  15770. /**
  15771. * How much to randomize the particle direction [0-1].
  15772. */
  15773. directionRandomizer?: number);
  15774. /**
  15775. * Called by the particle System when the direction is computed for the created particle.
  15776. * @param worldMatrix is the world matrix of the particle system
  15777. * @param directionToUpdate is the direction vector to update with the result
  15778. * @param particle is the particle we are computed the direction for
  15779. */
  15780. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15781. /**
  15782. * Called by the particle System when the position is computed for the created particle.
  15783. * @param worldMatrix is the world matrix of the particle system
  15784. * @param positionToUpdate is the position vector to update with the result
  15785. * @param particle is the particle we are computed the position for
  15786. */
  15787. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15788. /**
  15789. * Clones the current emitter and returns a copy of it
  15790. * @returns the new emitter
  15791. */
  15792. clone(): HemisphericParticleEmitter;
  15793. /**
  15794. * Called by the GPUParticleSystem to setup the update shader
  15795. * @param effect defines the update shader
  15796. */
  15797. applyToShader(effect: Effect): void;
  15798. /**
  15799. * Returns a string to use to update the GPU particles update shader
  15800. * @returns a string containng the defines string
  15801. */
  15802. getEffectDefines(): string;
  15803. /**
  15804. * Returns the string "HemisphericParticleEmitter"
  15805. * @returns a string containing the class name
  15806. */
  15807. getClassName(): string;
  15808. /**
  15809. * Serializes the particle system to a JSON object.
  15810. * @returns the JSON object
  15811. */
  15812. serialize(): any;
  15813. /**
  15814. * Parse properties from a JSON object
  15815. * @param serializationObject defines the JSON object
  15816. */
  15817. parse(serializationObject: any): void;
  15818. }
  15819. }
  15820. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15821. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15822. import { Effect } from "babylonjs/Materials/effect";
  15823. import { Particle } from "babylonjs/Particles/particle";
  15824. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15825. /**
  15826. * Particle emitter emitting particles from a point.
  15827. * It emits the particles randomly between 2 given directions.
  15828. */
  15829. export class PointParticleEmitter implements IParticleEmitterType {
  15830. /**
  15831. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15832. */
  15833. direction1: Vector3;
  15834. /**
  15835. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15836. */
  15837. direction2: Vector3;
  15838. /**
  15839. * Creates a new instance PointParticleEmitter
  15840. */
  15841. constructor();
  15842. /**
  15843. * Called by the particle System when the direction is computed for the created particle.
  15844. * @param worldMatrix is the world matrix of the particle system
  15845. * @param directionToUpdate is the direction vector to update with the result
  15846. * @param particle is the particle we are computed the direction for
  15847. */
  15848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15849. /**
  15850. * Called by the particle System when the position is computed for the created particle.
  15851. * @param worldMatrix is the world matrix of the particle system
  15852. * @param positionToUpdate is the position vector to update with the result
  15853. * @param particle is the particle we are computed the position for
  15854. */
  15855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15856. /**
  15857. * Clones the current emitter and returns a copy of it
  15858. * @returns the new emitter
  15859. */
  15860. clone(): PointParticleEmitter;
  15861. /**
  15862. * Called by the GPUParticleSystem to setup the update shader
  15863. * @param effect defines the update shader
  15864. */
  15865. applyToShader(effect: Effect): void;
  15866. /**
  15867. * Returns a string to use to update the GPU particles update shader
  15868. * @returns a string containng the defines string
  15869. */
  15870. getEffectDefines(): string;
  15871. /**
  15872. * Returns the string "PointParticleEmitter"
  15873. * @returns a string containing the class name
  15874. */
  15875. getClassName(): string;
  15876. /**
  15877. * Serializes the particle system to a JSON object.
  15878. * @returns the JSON object
  15879. */
  15880. serialize(): any;
  15881. /**
  15882. * Parse properties from a JSON object
  15883. * @param serializationObject defines the JSON object
  15884. */
  15885. parse(serializationObject: any): void;
  15886. }
  15887. }
  15888. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15889. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15890. import { Effect } from "babylonjs/Materials/effect";
  15891. import { Particle } from "babylonjs/Particles/particle";
  15892. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15893. /**
  15894. * Particle emitter emitting particles from the inside of a sphere.
  15895. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15896. */
  15897. export class SphereParticleEmitter implements IParticleEmitterType {
  15898. /**
  15899. * The radius of the emission sphere.
  15900. */
  15901. radius: number;
  15902. /**
  15903. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15904. */
  15905. radiusRange: number;
  15906. /**
  15907. * How much to randomize the particle direction [0-1].
  15908. */
  15909. directionRandomizer: number;
  15910. /**
  15911. * Creates a new instance SphereParticleEmitter
  15912. * @param radius the radius of the emission sphere (1 by default)
  15913. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15914. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15915. */
  15916. constructor(
  15917. /**
  15918. * The radius of the emission sphere.
  15919. */
  15920. radius?: number,
  15921. /**
  15922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15923. */
  15924. radiusRange?: number,
  15925. /**
  15926. * How much to randomize the particle direction [0-1].
  15927. */
  15928. directionRandomizer?: number);
  15929. /**
  15930. * Called by the particle System when the direction is computed for the created particle.
  15931. * @param worldMatrix is the world matrix of the particle system
  15932. * @param directionToUpdate is the direction vector to update with the result
  15933. * @param particle is the particle we are computed the direction for
  15934. */
  15935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15936. /**
  15937. * Called by the particle System when the position is computed for the created particle.
  15938. * @param worldMatrix is the world matrix of the particle system
  15939. * @param positionToUpdate is the position vector to update with the result
  15940. * @param particle is the particle we are computed the position for
  15941. */
  15942. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15943. /**
  15944. * Clones the current emitter and returns a copy of it
  15945. * @returns the new emitter
  15946. */
  15947. clone(): SphereParticleEmitter;
  15948. /**
  15949. * Called by the GPUParticleSystem to setup the update shader
  15950. * @param effect defines the update shader
  15951. */
  15952. applyToShader(effect: Effect): void;
  15953. /**
  15954. * Returns a string to use to update the GPU particles update shader
  15955. * @returns a string containng the defines string
  15956. */
  15957. getEffectDefines(): string;
  15958. /**
  15959. * Returns the string "SphereParticleEmitter"
  15960. * @returns a string containing the class name
  15961. */
  15962. getClassName(): string;
  15963. /**
  15964. * Serializes the particle system to a JSON object.
  15965. * @returns the JSON object
  15966. */
  15967. serialize(): any;
  15968. /**
  15969. * Parse properties from a JSON object
  15970. * @param serializationObject defines the JSON object
  15971. */
  15972. parse(serializationObject: any): void;
  15973. }
  15974. /**
  15975. * Particle emitter emitting particles from the inside of a sphere.
  15976. * It emits the particles randomly between two vectors.
  15977. */
  15978. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15979. /**
  15980. * The min limit of the emission direction.
  15981. */
  15982. direction1: Vector3;
  15983. /**
  15984. * The max limit of the emission direction.
  15985. */
  15986. direction2: Vector3;
  15987. /**
  15988. * Creates a new instance SphereDirectedParticleEmitter
  15989. * @param radius the radius of the emission sphere (1 by default)
  15990. * @param direction1 the min limit of the emission direction (up vector by default)
  15991. * @param direction2 the max limit of the emission direction (up vector by default)
  15992. */
  15993. constructor(radius?: number,
  15994. /**
  15995. * The min limit of the emission direction.
  15996. */
  15997. direction1?: Vector3,
  15998. /**
  15999. * The max limit of the emission direction.
  16000. */
  16001. direction2?: Vector3);
  16002. /**
  16003. * Called by the particle System when the direction is computed for the created particle.
  16004. * @param worldMatrix is the world matrix of the particle system
  16005. * @param directionToUpdate is the direction vector to update with the result
  16006. * @param particle is the particle we are computed the direction for
  16007. */
  16008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16009. /**
  16010. * Clones the current emitter and returns a copy of it
  16011. * @returns the new emitter
  16012. */
  16013. clone(): SphereDirectedParticleEmitter;
  16014. /**
  16015. * Called by the GPUParticleSystem to setup the update shader
  16016. * @param effect defines the update shader
  16017. */
  16018. applyToShader(effect: Effect): void;
  16019. /**
  16020. * Returns a string to use to update the GPU particles update shader
  16021. * @returns a string containng the defines string
  16022. */
  16023. getEffectDefines(): string;
  16024. /**
  16025. * Returns the string "SphereDirectedParticleEmitter"
  16026. * @returns a string containing the class name
  16027. */
  16028. getClassName(): string;
  16029. /**
  16030. * Serializes the particle system to a JSON object.
  16031. * @returns the JSON object
  16032. */
  16033. serialize(): any;
  16034. /**
  16035. * Parse properties from a JSON object
  16036. * @param serializationObject defines the JSON object
  16037. */
  16038. parse(serializationObject: any): void;
  16039. }
  16040. }
  16041. declare module "babylonjs/Particles/EmitterTypes/index" {
  16042. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16043. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16044. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16045. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16046. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16047. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16048. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16049. }
  16050. declare module "babylonjs/Particles/IParticleSystem" {
  16051. import { Nullable } from "babylonjs/types";
  16052. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16055. import { Texture } from "babylonjs/Materials/Textures/texture";
  16056. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16057. import { Scene } from "babylonjs/scene";
  16058. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16059. import { Animation } from "babylonjs/Animations/animation";
  16060. /**
  16061. * Interface representing a particle system in Babylon.js.
  16062. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16063. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16064. */
  16065. export interface IParticleSystem {
  16066. /**
  16067. * List of animations used by the particle system.
  16068. */
  16069. animations: Animation[];
  16070. /**
  16071. * The id of the Particle system.
  16072. */
  16073. id: string;
  16074. /**
  16075. * The name of the Particle system.
  16076. */
  16077. name: string;
  16078. /**
  16079. * The emitter represents the Mesh or position we are attaching the particle system to.
  16080. */
  16081. emitter: Nullable<AbstractMesh | Vector3>;
  16082. /**
  16083. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16084. */
  16085. isBillboardBased: boolean;
  16086. /**
  16087. * The rendering group used by the Particle system to chose when to render.
  16088. */
  16089. renderingGroupId: number;
  16090. /**
  16091. * The layer mask we are rendering the particles through.
  16092. */
  16093. layerMask: number;
  16094. /**
  16095. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16096. */
  16097. updateSpeed: number;
  16098. /**
  16099. * The amount of time the particle system is running (depends of the overall update speed).
  16100. */
  16101. targetStopDuration: number;
  16102. /**
  16103. * The texture used to render each particle. (this can be a spritesheet)
  16104. */
  16105. particleTexture: Nullable<Texture>;
  16106. /**
  16107. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16108. */
  16109. blendMode: number;
  16110. /**
  16111. * Minimum life time of emitting particles.
  16112. */
  16113. minLifeTime: number;
  16114. /**
  16115. * Maximum life time of emitting particles.
  16116. */
  16117. maxLifeTime: number;
  16118. /**
  16119. * Minimum Size of emitting particles.
  16120. */
  16121. minSize: number;
  16122. /**
  16123. * Maximum Size of emitting particles.
  16124. */
  16125. maxSize: number;
  16126. /**
  16127. * Minimum scale of emitting particles on X axis.
  16128. */
  16129. minScaleX: number;
  16130. /**
  16131. * Maximum scale of emitting particles on X axis.
  16132. */
  16133. maxScaleX: number;
  16134. /**
  16135. * Minimum scale of emitting particles on Y axis.
  16136. */
  16137. minScaleY: number;
  16138. /**
  16139. * Maximum scale of emitting particles on Y axis.
  16140. */
  16141. maxScaleY: number;
  16142. /**
  16143. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16144. */
  16145. color1: Color4;
  16146. /**
  16147. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16148. */
  16149. color2: Color4;
  16150. /**
  16151. * Color the particle will have at the end of its lifetime.
  16152. */
  16153. colorDead: Color4;
  16154. /**
  16155. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16156. */
  16157. emitRate: number;
  16158. /**
  16159. * You can use gravity if you want to give an orientation to your particles.
  16160. */
  16161. gravity: Vector3;
  16162. /**
  16163. * Minimum power of emitting particles.
  16164. */
  16165. minEmitPower: number;
  16166. /**
  16167. * Maximum power of emitting particles.
  16168. */
  16169. maxEmitPower: number;
  16170. /**
  16171. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16172. */
  16173. minAngularSpeed: number;
  16174. /**
  16175. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16176. */
  16177. maxAngularSpeed: number;
  16178. /**
  16179. * Gets or sets the minimal initial rotation in radians.
  16180. */
  16181. minInitialRotation: number;
  16182. /**
  16183. * Gets or sets the maximal initial rotation in radians.
  16184. */
  16185. maxInitialRotation: number;
  16186. /**
  16187. * The particle emitter type defines the emitter used by the particle system.
  16188. * It can be for example box, sphere, or cone...
  16189. */
  16190. particleEmitterType: Nullable<IParticleEmitterType>;
  16191. /**
  16192. * Defines the delay in milliseconds before starting the system (0 by default)
  16193. */
  16194. startDelay: number;
  16195. /**
  16196. * 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
  16197. */
  16198. preWarmCycles: number;
  16199. /**
  16200. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16201. */
  16202. preWarmStepOffset: number;
  16203. /**
  16204. * 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)
  16205. */
  16206. spriteCellChangeSpeed: number;
  16207. /**
  16208. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16209. */
  16210. startSpriteCellID: number;
  16211. /**
  16212. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16213. */
  16214. endSpriteCellID: number;
  16215. /**
  16216. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16217. */
  16218. spriteCellWidth: number;
  16219. /**
  16220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16221. */
  16222. spriteCellHeight: number;
  16223. /**
  16224. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16225. */
  16226. spriteRandomStartCell: boolean;
  16227. /**
  16228. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16229. */
  16230. isAnimationSheetEnabled: boolean;
  16231. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16232. translationPivot: Vector2;
  16233. /**
  16234. * Gets or sets a texture used to add random noise to particle positions
  16235. */
  16236. noiseTexture: Nullable<BaseTexture>;
  16237. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16238. noiseStrength: Vector3;
  16239. /**
  16240. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16241. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16242. */
  16243. billboardMode: number;
  16244. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16245. limitVelocityDamping: number;
  16246. /**
  16247. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16248. */
  16249. beginAnimationOnStart: boolean;
  16250. /**
  16251. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16252. */
  16253. beginAnimationFrom: number;
  16254. /**
  16255. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16256. */
  16257. beginAnimationTo: number;
  16258. /**
  16259. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16260. */
  16261. beginAnimationLoop: boolean;
  16262. /**
  16263. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16264. */
  16265. disposeOnStop: boolean;
  16266. /**
  16267. * Gets the maximum number of particles active at the same time.
  16268. * @returns The max number of active particles.
  16269. */
  16270. getCapacity(): number;
  16271. /**
  16272. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16273. * @returns True if it has been started, otherwise false.
  16274. */
  16275. isStarted(): boolean;
  16276. /**
  16277. * Animates the particle system for this frame.
  16278. */
  16279. animate(): void;
  16280. /**
  16281. * Renders the particle system in its current state.
  16282. * @returns the current number of particles
  16283. */
  16284. render(): number;
  16285. /**
  16286. * Dispose the particle system and frees its associated resources.
  16287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16288. */
  16289. dispose(disposeTexture?: boolean): void;
  16290. /**
  16291. * Clones the particle system.
  16292. * @param name The name of the cloned object
  16293. * @param newEmitter The new emitter to use
  16294. * @returns the cloned particle system
  16295. */
  16296. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16297. /**
  16298. * Serializes the particle system to a JSON object.
  16299. * @returns the JSON object
  16300. */
  16301. serialize(): any;
  16302. /**
  16303. * Rebuild the particle system
  16304. */
  16305. rebuild(): void;
  16306. /**
  16307. * Starts the particle system and begins to emit
  16308. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16309. */
  16310. start(delay?: number): void;
  16311. /**
  16312. * Stops the particle system.
  16313. */
  16314. stop(): void;
  16315. /**
  16316. * Remove all active particles
  16317. */
  16318. reset(): void;
  16319. /**
  16320. * Is this system ready to be used/rendered
  16321. * @return true if the system is ready
  16322. */
  16323. isReady(): boolean;
  16324. /**
  16325. * Adds a new color gradient
  16326. * @param gradient defines the gradient to use (between 0 and 1)
  16327. * @param color1 defines the color to affect to the specified gradient
  16328. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16329. * @returns the current particle system
  16330. */
  16331. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16332. /**
  16333. * Remove a specific color gradient
  16334. * @param gradient defines the gradient to remove
  16335. * @returns the current particle system
  16336. */
  16337. removeColorGradient(gradient: number): IParticleSystem;
  16338. /**
  16339. * Adds a new size gradient
  16340. * @param gradient defines the gradient to use (between 0 and 1)
  16341. * @param factor defines the size factor to affect to the specified gradient
  16342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16343. * @returns the current particle system
  16344. */
  16345. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16346. /**
  16347. * Remove a specific size gradient
  16348. * @param gradient defines the gradient to remove
  16349. * @returns the current particle system
  16350. */
  16351. removeSizeGradient(gradient: number): IParticleSystem;
  16352. /**
  16353. * Gets the current list of color gradients.
  16354. * You must use addColorGradient and removeColorGradient to udpate this list
  16355. * @returns the list of color gradients
  16356. */
  16357. getColorGradients(): Nullable<Array<ColorGradient>>;
  16358. /**
  16359. * Gets the current list of size gradients.
  16360. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16361. * @returns the list of size gradients
  16362. */
  16363. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16364. /**
  16365. * Gets the current list of angular speed gradients.
  16366. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16367. * @returns the list of angular speed gradients
  16368. */
  16369. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16370. /**
  16371. * Adds a new angular speed gradient
  16372. * @param gradient defines the gradient to use (between 0 and 1)
  16373. * @param factor defines the angular speed to affect to the specified gradient
  16374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16375. * @returns the current particle system
  16376. */
  16377. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16378. /**
  16379. * Remove a specific angular speed gradient
  16380. * @param gradient defines the gradient to remove
  16381. * @returns the current particle system
  16382. */
  16383. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16384. /**
  16385. * Gets the current list of velocity gradients.
  16386. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16387. * @returns the list of velocity gradients
  16388. */
  16389. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16390. /**
  16391. * Adds a new velocity gradient
  16392. * @param gradient defines the gradient to use (between 0 and 1)
  16393. * @param factor defines the velocity to affect to the specified gradient
  16394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16395. * @returns the current particle system
  16396. */
  16397. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16398. /**
  16399. * Remove a specific velocity gradient
  16400. * @param gradient defines the gradient to remove
  16401. * @returns the current particle system
  16402. */
  16403. removeVelocityGradient(gradient: number): IParticleSystem;
  16404. /**
  16405. * Gets the current list of limit velocity gradients.
  16406. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16407. * @returns the list of limit velocity gradients
  16408. */
  16409. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16410. /**
  16411. * Adds a new limit velocity gradient
  16412. * @param gradient defines the gradient to use (between 0 and 1)
  16413. * @param factor defines the limit velocity to affect to the specified gradient
  16414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16415. * @returns the current particle system
  16416. */
  16417. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16418. /**
  16419. * Remove a specific limit velocity gradient
  16420. * @param gradient defines the gradient to remove
  16421. * @returns the current particle system
  16422. */
  16423. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16424. /**
  16425. * Adds a new drag gradient
  16426. * @param gradient defines the gradient to use (between 0 and 1)
  16427. * @param factor defines the drag to affect to the specified gradient
  16428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16429. * @returns the current particle system
  16430. */
  16431. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16432. /**
  16433. * Remove a specific drag gradient
  16434. * @param gradient defines the gradient to remove
  16435. * @returns the current particle system
  16436. */
  16437. removeDragGradient(gradient: number): IParticleSystem;
  16438. /**
  16439. * Gets the current list of drag gradients.
  16440. * You must use addDragGradient and removeDragGradient to udpate this list
  16441. * @returns the list of drag gradients
  16442. */
  16443. getDragGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16446. * @param gradient defines the gradient to use (between 0 and 1)
  16447. * @param factor defines the emit rate to affect to the specified gradient
  16448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16449. * @returns the current particle system
  16450. */
  16451. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16452. /**
  16453. * Remove a specific emit rate gradient
  16454. * @param gradient defines the gradient to remove
  16455. * @returns the current particle system
  16456. */
  16457. removeEmitRateGradient(gradient: number): IParticleSystem;
  16458. /**
  16459. * Gets the current list of emit rate gradients.
  16460. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16461. * @returns the list of emit rate gradients
  16462. */
  16463. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16464. /**
  16465. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16466. * @param gradient defines the gradient to use (between 0 and 1)
  16467. * @param factor defines the start size to affect to the specified gradient
  16468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16469. * @returns the current particle system
  16470. */
  16471. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16472. /**
  16473. * Remove a specific start size gradient
  16474. * @param gradient defines the gradient to remove
  16475. * @returns the current particle system
  16476. */
  16477. removeStartSizeGradient(gradient: number): IParticleSystem;
  16478. /**
  16479. * Gets the current list of start size gradients.
  16480. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16481. * @returns the list of start size gradients
  16482. */
  16483. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Adds a new life time gradient
  16486. * @param gradient defines the gradient to use (between 0 and 1)
  16487. * @param factor defines the life time factor to affect to the specified gradient
  16488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16489. * @returns the current particle system
  16490. */
  16491. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16492. /**
  16493. * Remove a specific life time gradient
  16494. * @param gradient defines the gradient to remove
  16495. * @returns the current particle system
  16496. */
  16497. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16498. /**
  16499. * Gets the current list of life time gradients.
  16500. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16501. * @returns the list of life time gradients
  16502. */
  16503. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of color gradients.
  16506. * You must use addColorGradient and removeColorGradient to udpate this list
  16507. * @returns the list of color gradients
  16508. */
  16509. getColorGradients(): Nullable<Array<ColorGradient>>;
  16510. /**
  16511. * Adds a new ramp gradient used to remap particle colors
  16512. * @param gradient defines the gradient to use (between 0 and 1)
  16513. * @param color defines the color to affect to the specified gradient
  16514. * @returns the current particle system
  16515. */
  16516. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16517. /**
  16518. * Gets the current list of ramp gradients.
  16519. * You must use addRampGradient and removeRampGradient to udpate this list
  16520. * @returns the list of ramp gradients
  16521. */
  16522. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16523. /** Gets or sets a boolean indicating that ramp gradients must be used
  16524. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16525. */
  16526. useRampGradients: boolean;
  16527. /**
  16528. * Adds a new color remap gradient
  16529. * @param gradient defines the gradient to use (between 0 and 1)
  16530. * @param min defines the color remap minimal range
  16531. * @param max defines the color remap maximal range
  16532. * @returns the current particle system
  16533. */
  16534. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16535. /**
  16536. * Gets the current list of color remap gradients.
  16537. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16538. * @returns the list of color remap gradients
  16539. */
  16540. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16541. /**
  16542. * Adds a new alpha remap gradient
  16543. * @param gradient defines the gradient to use (between 0 and 1)
  16544. * @param min defines the alpha remap minimal range
  16545. * @param max defines the alpha remap maximal range
  16546. * @returns the current particle system
  16547. */
  16548. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16549. /**
  16550. * Gets the current list of alpha remap gradients.
  16551. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16552. * @returns the list of alpha remap gradients
  16553. */
  16554. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16555. /**
  16556. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16559. * @returns the emitter
  16560. */
  16561. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16562. /**
  16563. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16564. * @param radius The radius of the hemisphere to emit from
  16565. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16566. * @returns the emitter
  16567. */
  16568. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16569. /**
  16570. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16571. * @param radius The radius of the sphere to emit from
  16572. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16573. * @returns the emitter
  16574. */
  16575. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16576. /**
  16577. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16578. * @param radius The radius of the sphere to emit from
  16579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16581. * @returns the emitter
  16582. */
  16583. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16584. /**
  16585. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16586. * @param radius The radius of the emission cylinder
  16587. * @param height The height of the emission cylinder
  16588. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16589. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16590. * @returns the emitter
  16591. */
  16592. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16593. /**
  16594. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16595. * @param radius The radius of the cylinder to emit from
  16596. * @param height The height of the emission cylinder
  16597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16600. * @returns the emitter
  16601. */
  16602. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16603. /**
  16604. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16605. * @param radius The radius of the cone to emit from
  16606. * @param angle The base angle of the cone
  16607. * @returns the emitter
  16608. */
  16609. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16610. /**
  16611. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16614. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16615. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16616. * @returns the emitter
  16617. */
  16618. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16619. /**
  16620. * Get hosting scene
  16621. * @returns the scene
  16622. */
  16623. getScene(): Scene;
  16624. }
  16625. }
  16626. declare module "babylonjs/Meshes/instancedMesh" {
  16627. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16628. import { Vector3 } from "babylonjs/Maths/math";
  16629. import { Camera } from "babylonjs/Cameras/camera";
  16630. import { Node } from "babylonjs/node";
  16631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16632. import { Mesh } from "babylonjs/Meshes/mesh";
  16633. import { Material } from "babylonjs/Materials/material";
  16634. import { Skeleton } from "babylonjs/Bones/skeleton";
  16635. /**
  16636. * Creates an instance based on a source mesh.
  16637. */
  16638. export class InstancedMesh extends AbstractMesh {
  16639. private _sourceMesh;
  16640. private _currentLOD;
  16641. /** @hidden */
  16642. _indexInSourceMeshInstanceArray: number;
  16643. constructor(name: string, source: Mesh);
  16644. /**
  16645. * Returns the string "InstancedMesh".
  16646. */
  16647. getClassName(): string;
  16648. /**
  16649. * If the source mesh receives shadows
  16650. */
  16651. readonly receiveShadows: boolean;
  16652. /**
  16653. * The material of the source mesh
  16654. */
  16655. readonly material: Nullable<Material>;
  16656. /**
  16657. * Visibility of the source mesh
  16658. */
  16659. readonly visibility: number;
  16660. /**
  16661. * Skeleton of the source mesh
  16662. */
  16663. readonly skeleton: Nullable<Skeleton>;
  16664. /**
  16665. * Rendering ground id of the source mesh
  16666. */
  16667. renderingGroupId: number;
  16668. /**
  16669. * Returns the total number of vertices (integer).
  16670. */
  16671. getTotalVertices(): number;
  16672. /**
  16673. * Returns a positive integer : the total number of indices in this mesh geometry.
  16674. * @returns the numner of indices or zero if the mesh has no geometry.
  16675. */
  16676. getTotalIndices(): number;
  16677. /**
  16678. * The source mesh of the instance
  16679. */
  16680. readonly sourceMesh: Mesh;
  16681. /**
  16682. * Is this node ready to be used/rendered
  16683. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16684. * @return {boolean} is it ready
  16685. */
  16686. isReady(completeCheck?: boolean): boolean;
  16687. /**
  16688. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16689. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16690. * @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.
  16691. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16692. */
  16693. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16694. /**
  16695. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16696. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16697. * The `data` are either a numeric array either a Float32Array.
  16698. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16699. * 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).
  16700. * Note that a new underlying VertexBuffer object is created each call.
  16701. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16702. *
  16703. * Possible `kind` values :
  16704. * - VertexBuffer.PositionKind
  16705. * - VertexBuffer.UVKind
  16706. * - VertexBuffer.UV2Kind
  16707. * - VertexBuffer.UV3Kind
  16708. * - VertexBuffer.UV4Kind
  16709. * - VertexBuffer.UV5Kind
  16710. * - VertexBuffer.UV6Kind
  16711. * - VertexBuffer.ColorKind
  16712. * - VertexBuffer.MatricesIndicesKind
  16713. * - VertexBuffer.MatricesIndicesExtraKind
  16714. * - VertexBuffer.MatricesWeightsKind
  16715. * - VertexBuffer.MatricesWeightsExtraKind
  16716. *
  16717. * Returns the Mesh.
  16718. */
  16719. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16720. /**
  16721. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16722. * If the mesh has no geometry, it is simply returned as it is.
  16723. * The `data` are either a numeric array either a Float32Array.
  16724. * No new underlying VertexBuffer object is created.
  16725. * 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.
  16726. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16727. *
  16728. * Possible `kind` values :
  16729. * - VertexBuffer.PositionKind
  16730. * - VertexBuffer.UVKind
  16731. * - VertexBuffer.UV2Kind
  16732. * - VertexBuffer.UV3Kind
  16733. * - VertexBuffer.UV4Kind
  16734. * - VertexBuffer.UV5Kind
  16735. * - VertexBuffer.UV6Kind
  16736. * - VertexBuffer.ColorKind
  16737. * - VertexBuffer.MatricesIndicesKind
  16738. * - VertexBuffer.MatricesIndicesExtraKind
  16739. * - VertexBuffer.MatricesWeightsKind
  16740. * - VertexBuffer.MatricesWeightsExtraKind
  16741. *
  16742. * Returns the Mesh.
  16743. */
  16744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16745. /**
  16746. * Sets the mesh indices.
  16747. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16748. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16749. * This method creates a new index buffer each call.
  16750. * Returns the Mesh.
  16751. */
  16752. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16753. /**
  16754. * Boolean : True if the mesh owns the requested kind of data.
  16755. */
  16756. isVerticesDataPresent(kind: string): boolean;
  16757. /**
  16758. * Returns an array of indices (IndicesArray).
  16759. */
  16760. getIndices(): Nullable<IndicesArray>;
  16761. readonly _positions: Nullable<Vector3[]>;
  16762. /**
  16763. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16764. * This means the mesh underlying bounding box and sphere are recomputed.
  16765. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16766. * @returns the current mesh
  16767. */
  16768. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16769. /** @hidden */
  16770. _preActivate(): InstancedMesh;
  16771. /** @hidden */
  16772. _activate(renderId: number): InstancedMesh;
  16773. /**
  16774. * Returns the current associated LOD AbstractMesh.
  16775. */
  16776. getLOD(camera: Camera): AbstractMesh;
  16777. /** @hidden */
  16778. _syncSubMeshes(): InstancedMesh;
  16779. /** @hidden */
  16780. _generatePointsArray(): boolean;
  16781. /**
  16782. * Creates a new InstancedMesh from the current mesh.
  16783. * - name (string) : the cloned mesh name
  16784. * - newParent (optional Node) : the optional Node to parent the clone to.
  16785. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16786. *
  16787. * Returns the clone.
  16788. */
  16789. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16790. /**
  16791. * Disposes the InstancedMesh.
  16792. * Returns nothing.
  16793. */
  16794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16795. }
  16796. }
  16797. declare module "babylonjs/Materials/shaderMaterial" {
  16798. import { Scene } from "babylonjs/scene";
  16799. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16801. import { Mesh } from "babylonjs/Meshes/mesh";
  16802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16803. import { Texture } from "babylonjs/Materials/Textures/texture";
  16804. import { Material } from "babylonjs/Materials/material";
  16805. /**
  16806. * Defines the options associated with the creation of a shader material.
  16807. */
  16808. export interface IShaderMaterialOptions {
  16809. /**
  16810. * Does the material work in alpha blend mode
  16811. */
  16812. needAlphaBlending: boolean;
  16813. /**
  16814. * Does the material work in alpha test mode
  16815. */
  16816. needAlphaTesting: boolean;
  16817. /**
  16818. * The list of attribute names used in the shader
  16819. */
  16820. attributes: string[];
  16821. /**
  16822. * The list of unifrom names used in the shader
  16823. */
  16824. uniforms: string[];
  16825. /**
  16826. * The list of UBO names used in the shader
  16827. */
  16828. uniformBuffers: string[];
  16829. /**
  16830. * The list of sampler names used in the shader
  16831. */
  16832. samplers: string[];
  16833. /**
  16834. * The list of defines used in the shader
  16835. */
  16836. defines: string[];
  16837. }
  16838. /**
  16839. * 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.
  16840. *
  16841. * This returned material effects how the mesh will look based on the code in the shaders.
  16842. *
  16843. * @see http://doc.babylonjs.com/how_to/shader_material
  16844. */
  16845. export class ShaderMaterial extends Material {
  16846. private _shaderPath;
  16847. private _options;
  16848. private _textures;
  16849. private _textureArrays;
  16850. private _floats;
  16851. private _ints;
  16852. private _floatsArrays;
  16853. private _colors3;
  16854. private _colors3Arrays;
  16855. private _colors4;
  16856. private _vectors2;
  16857. private _vectors3;
  16858. private _vectors4;
  16859. private _matrices;
  16860. private _matrices3x3;
  16861. private _matrices2x2;
  16862. private _vectors2Arrays;
  16863. private _vectors3Arrays;
  16864. private _cachedWorldViewMatrix;
  16865. private _renderId;
  16866. /**
  16867. * Instantiate a new shader material.
  16868. * 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.
  16869. * This returned material effects how the mesh will look based on the code in the shaders.
  16870. * @see http://doc.babylonjs.com/how_to/shader_material
  16871. * @param name Define the name of the material in the scene
  16872. * @param scene Define the scene the material belongs to
  16873. * @param shaderPath Defines the route to the shader code in one of three ways:
  16874. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16875. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16876. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16877. * @param options Define the options used to create the shader
  16878. */
  16879. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16880. /**
  16881. * Gets the options used to compile the shader.
  16882. * They can be modified to trigger a new compilation
  16883. */
  16884. readonly options: IShaderMaterialOptions;
  16885. /**
  16886. * Gets the current class name of the material e.g. "ShaderMaterial"
  16887. * Mainly use in serialization.
  16888. * @returns the class name
  16889. */
  16890. getClassName(): string;
  16891. /**
  16892. * Specifies if the material will require alpha blending
  16893. * @returns a boolean specifying if alpha blending is needed
  16894. */
  16895. needAlphaBlending(): boolean;
  16896. /**
  16897. * Specifies if this material should be rendered in alpha test mode
  16898. * @returns a boolean specifying if an alpha test is needed.
  16899. */
  16900. needAlphaTesting(): boolean;
  16901. private _checkUniform;
  16902. /**
  16903. * Set a texture in the shader.
  16904. * @param name Define the name of the uniform samplers as defined in the shader
  16905. * @param texture Define the texture to bind to this sampler
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setTexture(name: string, texture: Texture): ShaderMaterial;
  16909. /**
  16910. * Set a texture array in the shader.
  16911. * @param name Define the name of the uniform sampler array as defined in the shader
  16912. * @param textures Define the list of textures to bind to this sampler
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16916. /**
  16917. * Set a float in the shader.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setFloat(name: string, value: number): ShaderMaterial;
  16923. /**
  16924. * Set a int in the shader.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setInt(name: string, value: number): ShaderMaterial;
  16930. /**
  16931. * Set an array of floats in the shader.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setFloats(name: string, value: number[]): ShaderMaterial;
  16937. /**
  16938. * Set a vec3 in the shader from a Color3.
  16939. * @param name Define the name of the uniform as defined in the shader
  16940. * @param value Define the value to give to the uniform
  16941. * @return the material itself allowing "fluent" like uniform updates
  16942. */
  16943. setColor3(name: string, value: Color3): ShaderMaterial;
  16944. /**
  16945. * Set a vec3 array in the shader from a Color3 array.
  16946. * @param name Define the name of the uniform as defined in the shader
  16947. * @param value Define the value to give to the uniform
  16948. * @return the material itself allowing "fluent" like uniform updates
  16949. */
  16950. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16951. /**
  16952. * Set a vec4 in the shader from a Color4.
  16953. * @param name Define the name of the uniform as defined in the shader
  16954. * @param value Define the value to give to the uniform
  16955. * @return the material itself allowing "fluent" like uniform updates
  16956. */
  16957. setColor4(name: string, value: Color4): ShaderMaterial;
  16958. /**
  16959. * Set a vec2 in the shader from a Vector2.
  16960. * @param name Define the name of the uniform as defined in the shader
  16961. * @param value Define the value to give to the uniform
  16962. * @return the material itself allowing "fluent" like uniform updates
  16963. */
  16964. setVector2(name: string, value: Vector2): ShaderMaterial;
  16965. /**
  16966. * Set a vec3 in the shader from a Vector3.
  16967. * @param name Define the name of the uniform as defined in the shader
  16968. * @param value Define the value to give to the uniform
  16969. * @return the material itself allowing "fluent" like uniform updates
  16970. */
  16971. setVector3(name: string, value: Vector3): ShaderMaterial;
  16972. /**
  16973. * Set a vec4 in the shader from a Vector4.
  16974. * @param name Define the name of the uniform as defined in the shader
  16975. * @param value Define the value to give to the uniform
  16976. * @return the material itself allowing "fluent" like uniform updates
  16977. */
  16978. setVector4(name: string, value: Vector4): ShaderMaterial;
  16979. /**
  16980. * Set a mat4 in the shader from a Matrix.
  16981. * @param name Define the name of the uniform as defined in the shader
  16982. * @param value Define the value to give to the uniform
  16983. * @return the material itself allowing "fluent" like uniform updates
  16984. */
  16985. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16986. /**
  16987. * Set a mat3 in the shader from a Float32Array.
  16988. * @param name Define the name of the uniform as defined in the shader
  16989. * @param value Define the value to give to the uniform
  16990. * @return the material itself allowing "fluent" like uniform updates
  16991. */
  16992. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16993. /**
  16994. * Set a mat2 in the shader from a Float32Array.
  16995. * @param name Define the name of the uniform as defined in the shader
  16996. * @param value Define the value to give to the uniform
  16997. * @return the material itself allowing "fluent" like uniform updates
  16998. */
  16999. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17000. /**
  17001. * Set a vec2 array in the shader from a number array.
  17002. * @param name Define the name of the uniform as defined in the shader
  17003. * @param value Define the value to give to the uniform
  17004. * @return the material itself allowing "fluent" like uniform updates
  17005. */
  17006. setArray2(name: string, value: number[]): ShaderMaterial;
  17007. /**
  17008. * Set a vec3 array in the shader from a number array.
  17009. * @param name Define the name of the uniform as defined in the shader
  17010. * @param value Define the value to give to the uniform
  17011. * @return the material itself allowing "fluent" like uniform updates
  17012. */
  17013. setArray3(name: string, value: number[]): ShaderMaterial;
  17014. private _checkCache;
  17015. /**
  17016. * Checks if the material is ready to render the requested mesh
  17017. * @param mesh Define the mesh to render
  17018. * @param useInstances Define whether or not the material is used with instances
  17019. * @returns true if ready, otherwise false
  17020. */
  17021. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17022. /**
  17023. * Binds the world matrix to the material
  17024. * @param world defines the world transformation matrix
  17025. */
  17026. bindOnlyWorldMatrix(world: Matrix): void;
  17027. /**
  17028. * Binds the material to the mesh
  17029. * @param world defines the world transformation matrix
  17030. * @param mesh defines the mesh to bind the material to
  17031. */
  17032. bind(world: Matrix, mesh?: Mesh): void;
  17033. /**
  17034. * Gets the active textures from the material
  17035. * @returns an array of textures
  17036. */
  17037. getActiveTextures(): BaseTexture[];
  17038. /**
  17039. * Specifies if the material uses a texture
  17040. * @param texture defines the texture to check against the material
  17041. * @returns a boolean specifying if the material uses the texture
  17042. */
  17043. hasTexture(texture: BaseTexture): boolean;
  17044. /**
  17045. * Makes a duplicate of the material, and gives it a new name
  17046. * @param name defines the new name for the duplicated material
  17047. * @returns the cloned material
  17048. */
  17049. clone(name: string): ShaderMaterial;
  17050. /**
  17051. * Disposes the material
  17052. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17053. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17054. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17055. */
  17056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17057. /**
  17058. * Serializes this material in a JSON representation
  17059. * @returns the serialized material object
  17060. */
  17061. serialize(): any;
  17062. /**
  17063. * Creates a shader material from parsed shader material data
  17064. * @param source defines the JSON represnetation of the material
  17065. * @param scene defines the hosting scene
  17066. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17067. * @returns a new material
  17068. */
  17069. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17070. }
  17071. }
  17072. declare module "babylonjs/Shaders/color.fragment" {
  17073. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17074. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17075. /** @hidden */
  17076. export var colorPixelShader: {
  17077. name: string;
  17078. shader: string;
  17079. };
  17080. }
  17081. declare module "babylonjs/Shaders/color.vertex" {
  17082. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17083. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17084. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17085. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17086. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17088. /** @hidden */
  17089. export var colorVertexShader: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Meshes/linesMesh" {
  17095. import { Nullable } from "babylonjs/types";
  17096. import { Scene } from "babylonjs/scene";
  17097. import { Color3 } from "babylonjs/Maths/math";
  17098. import { Node } from "babylonjs/node";
  17099. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17100. import { Mesh } from "babylonjs/Meshes/mesh";
  17101. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17102. import { Effect } from "babylonjs/Materials/effect";
  17103. import { Material } from "babylonjs/Materials/material";
  17104. import "babylonjs/Shaders/color.fragment";
  17105. import "babylonjs/Shaders/color.vertex";
  17106. /**
  17107. * Line mesh
  17108. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17109. */
  17110. export class LinesMesh extends Mesh {
  17111. /**
  17112. * If vertex color should be applied to the mesh
  17113. */
  17114. useVertexColor?: boolean | undefined;
  17115. /**
  17116. * If vertex alpha should be applied to the mesh
  17117. */
  17118. useVertexAlpha?: boolean | undefined;
  17119. /**
  17120. * Color of the line (Default: White)
  17121. */
  17122. color: Color3;
  17123. /**
  17124. * Alpha of the line (Default: 1)
  17125. */
  17126. alpha: number;
  17127. /**
  17128. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17129. * This margin is expressed in world space coordinates, so its value may vary.
  17130. * Default value is 0.1
  17131. */
  17132. intersectionThreshold: number;
  17133. private _colorShader;
  17134. /**
  17135. * Creates a new LinesMesh
  17136. * @param name defines the name
  17137. * @param scene defines the hosting scene
  17138. * @param parent defines the parent mesh if any
  17139. * @param source defines the optional source LinesMesh used to clone data from
  17140. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17141. * When false, achieved by calling a clone(), also passing False.
  17142. * This will make creation of children, recursive.
  17143. * @param useVertexColor defines if this LinesMesh supports vertex color
  17144. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17145. */
  17146. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17147. /**
  17148. * If vertex color should be applied to the mesh
  17149. */
  17150. useVertexColor?: boolean | undefined,
  17151. /**
  17152. * If vertex alpha should be applied to the mesh
  17153. */
  17154. useVertexAlpha?: boolean | undefined);
  17155. private _addClipPlaneDefine;
  17156. private _removeClipPlaneDefine;
  17157. isReady(): boolean;
  17158. /**
  17159. * Returns the string "LineMesh"
  17160. */
  17161. getClassName(): string;
  17162. /**
  17163. * @hidden
  17164. */
  17165. /**
  17166. * @hidden
  17167. */
  17168. material: Material;
  17169. /**
  17170. * @hidden
  17171. */
  17172. readonly checkCollisions: boolean;
  17173. /** @hidden */
  17174. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17175. /** @hidden */
  17176. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17177. /**
  17178. * Disposes of the line mesh
  17179. * @param doNotRecurse If children should be disposed
  17180. */
  17181. dispose(doNotRecurse?: boolean): void;
  17182. /**
  17183. * Returns a new LineMesh object cloned from the current one.
  17184. */
  17185. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17186. /**
  17187. * Creates a new InstancedLinesMesh object from the mesh model.
  17188. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17189. * @param name defines the name of the new instance
  17190. * @returns a new InstancedLinesMesh
  17191. */
  17192. createInstance(name: string): InstancedLinesMesh;
  17193. }
  17194. /**
  17195. * Creates an instance based on a source LinesMesh
  17196. */
  17197. export class InstancedLinesMesh extends InstancedMesh {
  17198. /**
  17199. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17200. * This margin is expressed in world space coordinates, so its value may vary.
  17201. * Initilized with the intersectionThreshold value of the source LinesMesh
  17202. */
  17203. intersectionThreshold: number;
  17204. constructor(name: string, source: LinesMesh);
  17205. /**
  17206. * Returns the string "InstancedLinesMesh".
  17207. */
  17208. getClassName(): string;
  17209. }
  17210. }
  17211. declare module "babylonjs/Shaders/line.fragment" {
  17212. /** @hidden */
  17213. export var linePixelShader: {
  17214. name: string;
  17215. shader: string;
  17216. };
  17217. }
  17218. declare module "babylonjs/Shaders/line.vertex" {
  17219. /** @hidden */
  17220. export var lineVertexShader: {
  17221. name: string;
  17222. shader: string;
  17223. };
  17224. }
  17225. declare module "babylonjs/Rendering/edgesRenderer" {
  17226. import { Nullable } from "babylonjs/types";
  17227. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17229. import { Vector3 } from "babylonjs/Maths/math";
  17230. import { IDisposable } from "babylonjs/scene";
  17231. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17232. import "babylonjs/Shaders/line.fragment";
  17233. import "babylonjs/Shaders/line.vertex";
  17234. module "babylonjs/Meshes/abstractMesh" {
  17235. interface AbstractMesh {
  17236. /**
  17237. * Disables the mesh edge rendering mode
  17238. * @returns the currentAbstractMesh
  17239. */
  17240. disableEdgesRendering(): AbstractMesh;
  17241. /**
  17242. * Enables the edge rendering mode on the mesh.
  17243. * This mode makes the mesh edges visible
  17244. * @param epsilon defines the maximal distance between two angles to detect a face
  17245. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17246. * @returns the currentAbstractMesh
  17247. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17248. */
  17249. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17250. /**
  17251. * Gets the edgesRenderer associated with the mesh
  17252. */
  17253. edgesRenderer: Nullable<EdgesRenderer>;
  17254. }
  17255. }
  17256. module "babylonjs/Meshes/linesMesh" {
  17257. interface LinesMesh {
  17258. /**
  17259. * Enables the edge rendering mode on the mesh.
  17260. * This mode makes the mesh edges visible
  17261. * @param epsilon defines the maximal distance between two angles to detect a face
  17262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17263. * @returns the currentAbstractMesh
  17264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17265. */
  17266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17267. }
  17268. }
  17269. module "babylonjs/Meshes/linesMesh" {
  17270. interface InstancedLinesMesh {
  17271. /**
  17272. * Enables the edge rendering mode on the mesh.
  17273. * This mode makes the mesh edges visible
  17274. * @param epsilon defines the maximal distance between two angles to detect a face
  17275. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17276. * @returns the current InstancedLinesMesh
  17277. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17278. */
  17279. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17280. }
  17281. }
  17282. /**
  17283. * Defines the minimum contract an Edges renderer should follow.
  17284. */
  17285. export interface IEdgesRenderer extends IDisposable {
  17286. /**
  17287. * Gets or sets a boolean indicating if the edgesRenderer is active
  17288. */
  17289. isEnabled: boolean;
  17290. /**
  17291. * Renders the edges of the attached mesh,
  17292. */
  17293. render(): void;
  17294. /**
  17295. * Checks wether or not the edges renderer is ready to render.
  17296. * @return true if ready, otherwise false.
  17297. */
  17298. isReady(): boolean;
  17299. }
  17300. /**
  17301. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17302. */
  17303. export class EdgesRenderer implements IEdgesRenderer {
  17304. /**
  17305. * Define the size of the edges with an orthographic camera
  17306. */
  17307. edgesWidthScalerForOrthographic: number;
  17308. /**
  17309. * Define the size of the edges with a perspective camera
  17310. */
  17311. edgesWidthScalerForPerspective: number;
  17312. protected _source: AbstractMesh;
  17313. protected _linesPositions: number[];
  17314. protected _linesNormals: number[];
  17315. protected _linesIndices: number[];
  17316. protected _epsilon: number;
  17317. protected _indicesCount: number;
  17318. protected _lineShader: ShaderMaterial;
  17319. protected _ib: WebGLBuffer;
  17320. protected _buffers: {
  17321. [key: string]: Nullable<VertexBuffer>;
  17322. };
  17323. protected _checkVerticesInsteadOfIndices: boolean;
  17324. private _meshRebuildObserver;
  17325. private _meshDisposeObserver;
  17326. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17327. isEnabled: boolean;
  17328. /**
  17329. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17330. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17331. * @param source Mesh used to create edges
  17332. * @param epsilon sum of angles in adjacency to check for edge
  17333. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17334. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17335. */
  17336. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17337. protected _prepareRessources(): void;
  17338. /** @hidden */
  17339. _rebuild(): void;
  17340. /**
  17341. * Releases the required resources for the edges renderer
  17342. */
  17343. dispose(): void;
  17344. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17345. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17346. /**
  17347. * Checks if the pair of p0 and p1 is en edge
  17348. * @param faceIndex
  17349. * @param edge
  17350. * @param faceNormals
  17351. * @param p0
  17352. * @param p1
  17353. * @private
  17354. */
  17355. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17356. /**
  17357. * push line into the position, normal and index buffer
  17358. * @protected
  17359. */
  17360. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17361. /**
  17362. * Generates lines edges from adjacencjes
  17363. * @private
  17364. */
  17365. _generateEdgesLines(): void;
  17366. /**
  17367. * Checks wether or not the edges renderer is ready to render.
  17368. * @return true if ready, otherwise false.
  17369. */
  17370. isReady(): boolean;
  17371. /**
  17372. * Renders the edges of the attached mesh,
  17373. */
  17374. render(): void;
  17375. }
  17376. /**
  17377. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17378. */
  17379. export class LineEdgesRenderer extends EdgesRenderer {
  17380. /**
  17381. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17382. * @param source LineMesh used to generate edges
  17383. * @param epsilon not important (specified angle for edge detection)
  17384. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17385. */
  17386. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17387. /**
  17388. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17389. */
  17390. _generateEdgesLines(): void;
  17391. }
  17392. }
  17393. declare module "babylonjs/Rendering/renderingGroup" {
  17394. import { SmartArray } from "babylonjs/Misc/smartArray";
  17395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17397. import { Nullable } from "babylonjs/types";
  17398. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17399. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17400. import { Material } from "babylonjs/Materials/material";
  17401. import { Scene } from "babylonjs/scene";
  17402. /**
  17403. * This represents the object necessary to create a rendering group.
  17404. * This is exclusively used and created by the rendering manager.
  17405. * To modify the behavior, you use the available helpers in your scene or meshes.
  17406. * @hidden
  17407. */
  17408. export class RenderingGroup {
  17409. index: number;
  17410. private _scene;
  17411. private _opaqueSubMeshes;
  17412. private _transparentSubMeshes;
  17413. private _alphaTestSubMeshes;
  17414. private _depthOnlySubMeshes;
  17415. private _particleSystems;
  17416. private _spriteManagers;
  17417. private _opaqueSortCompareFn;
  17418. private _alphaTestSortCompareFn;
  17419. private _transparentSortCompareFn;
  17420. private _renderOpaque;
  17421. private _renderAlphaTest;
  17422. private _renderTransparent;
  17423. private _edgesRenderers;
  17424. onBeforeTransparentRendering: () => void;
  17425. /**
  17426. * Set the opaque sort comparison function.
  17427. * If null the sub meshes will be render in the order they were created
  17428. */
  17429. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17430. /**
  17431. * Set the alpha test sort comparison function.
  17432. * If null the sub meshes will be render in the order they were created
  17433. */
  17434. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17435. /**
  17436. * Set the transparent sort comparison function.
  17437. * If null the sub meshes will be render in the order they were created
  17438. */
  17439. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17440. /**
  17441. * Creates a new rendering group.
  17442. * @param index The rendering group index
  17443. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17444. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17445. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17446. */
  17447. 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>);
  17448. /**
  17449. * Render all the sub meshes contained in the group.
  17450. * @param customRenderFunction Used to override the default render behaviour of the group.
  17451. * @returns true if rendered some submeshes.
  17452. */
  17453. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17454. /**
  17455. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17456. * @param subMeshes The submeshes to render
  17457. */
  17458. private renderOpaqueSorted;
  17459. /**
  17460. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17461. * @param subMeshes The submeshes to render
  17462. */
  17463. private renderAlphaTestSorted;
  17464. /**
  17465. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17466. * @param subMeshes The submeshes to render
  17467. */
  17468. private renderTransparentSorted;
  17469. /**
  17470. * Renders the submeshes in a specified order.
  17471. * @param subMeshes The submeshes to sort before render
  17472. * @param sortCompareFn The comparison function use to sort
  17473. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17474. * @param transparent Specifies to activate blending if true
  17475. */
  17476. private static renderSorted;
  17477. /**
  17478. * Renders the submeshes in the order they were dispatched (no sort applied).
  17479. * @param subMeshes The submeshes to render
  17480. */
  17481. private static renderUnsorted;
  17482. /**
  17483. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17484. * are rendered back to front if in the same alpha index.
  17485. *
  17486. * @param a The first submesh
  17487. * @param b The second submesh
  17488. * @returns The result of the comparison
  17489. */
  17490. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17491. /**
  17492. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17493. * are rendered back to front.
  17494. *
  17495. * @param a The first submesh
  17496. * @param b The second submesh
  17497. * @returns The result of the comparison
  17498. */
  17499. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17500. /**
  17501. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17502. * are rendered front to back (prevent overdraw).
  17503. *
  17504. * @param a The first submesh
  17505. * @param b The second submesh
  17506. * @returns The result of the comparison
  17507. */
  17508. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17509. /**
  17510. * Resets the different lists of submeshes to prepare a new frame.
  17511. */
  17512. prepare(): void;
  17513. dispose(): void;
  17514. /**
  17515. * Inserts the submesh in its correct queue depending on its material.
  17516. * @param subMesh The submesh to dispatch
  17517. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17518. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17519. */
  17520. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17521. dispatchSprites(spriteManager: ISpriteManager): void;
  17522. dispatchParticles(particleSystem: IParticleSystem): void;
  17523. private _renderParticles;
  17524. private _renderSprites;
  17525. }
  17526. }
  17527. declare module "babylonjs/Rendering/renderingManager" {
  17528. import { Nullable } from "babylonjs/types";
  17529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17530. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17531. import { SmartArray } from "babylonjs/Misc/smartArray";
  17532. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17533. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17534. import { Material } from "babylonjs/Materials/material";
  17535. import { Scene } from "babylonjs/scene";
  17536. import { Camera } from "babylonjs/Cameras/camera";
  17537. /**
  17538. * Interface describing the different options available in the rendering manager
  17539. * regarding Auto Clear between groups.
  17540. */
  17541. export interface IRenderingManagerAutoClearSetup {
  17542. /**
  17543. * Defines whether or not autoclear is enable.
  17544. */
  17545. autoClear: boolean;
  17546. /**
  17547. * Defines whether or not to autoclear the depth buffer.
  17548. */
  17549. depth: boolean;
  17550. /**
  17551. * Defines whether or not to autoclear the stencil buffer.
  17552. */
  17553. stencil: boolean;
  17554. }
  17555. /**
  17556. * This class is used by the onRenderingGroupObservable
  17557. */
  17558. export class RenderingGroupInfo {
  17559. /**
  17560. * The Scene that being rendered
  17561. */
  17562. scene: Scene;
  17563. /**
  17564. * The camera currently used for the rendering pass
  17565. */
  17566. camera: Nullable<Camera>;
  17567. /**
  17568. * The ID of the renderingGroup being processed
  17569. */
  17570. renderingGroupId: number;
  17571. }
  17572. /**
  17573. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17574. * It is enable to manage the different groups as well as the different necessary sort functions.
  17575. * This should not be used directly aside of the few static configurations
  17576. */
  17577. export class RenderingManager {
  17578. /**
  17579. * The max id used for rendering groups (not included)
  17580. */
  17581. static MAX_RENDERINGGROUPS: number;
  17582. /**
  17583. * The min id used for rendering groups (included)
  17584. */
  17585. static MIN_RENDERINGGROUPS: number;
  17586. /**
  17587. * Used to globally prevent autoclearing scenes.
  17588. */
  17589. static AUTOCLEAR: boolean;
  17590. /**
  17591. * @hidden
  17592. */
  17593. _useSceneAutoClearSetup: boolean;
  17594. private _scene;
  17595. private _renderingGroups;
  17596. private _depthStencilBufferAlreadyCleaned;
  17597. private _autoClearDepthStencil;
  17598. private _customOpaqueSortCompareFn;
  17599. private _customAlphaTestSortCompareFn;
  17600. private _customTransparentSortCompareFn;
  17601. private _renderingGroupInfo;
  17602. /**
  17603. * Instantiates a new rendering group for a particular scene
  17604. * @param scene Defines the scene the groups belongs to
  17605. */
  17606. constructor(scene: Scene);
  17607. private _clearDepthStencilBuffer;
  17608. /**
  17609. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17610. * @hidden
  17611. */
  17612. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17613. /**
  17614. * Resets the different information of the group to prepare a new frame
  17615. * @hidden
  17616. */
  17617. reset(): void;
  17618. /**
  17619. * Dispose and release the group and its associated resources.
  17620. * @hidden
  17621. */
  17622. dispose(): void;
  17623. /**
  17624. * Clear the info related to rendering groups preventing retention points during dispose.
  17625. */
  17626. freeRenderingGroups(): void;
  17627. private _prepareRenderingGroup;
  17628. /**
  17629. * Add a sprite manager to the rendering manager in order to render it this frame.
  17630. * @param spriteManager Define the sprite manager to render
  17631. */
  17632. dispatchSprites(spriteManager: ISpriteManager): void;
  17633. /**
  17634. * Add a particle system to the rendering manager in order to render it this frame.
  17635. * @param particleSystem Define the particle system to render
  17636. */
  17637. dispatchParticles(particleSystem: IParticleSystem): void;
  17638. /**
  17639. * Add a submesh to the manager in order to render it this frame
  17640. * @param subMesh The submesh to dispatch
  17641. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17642. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17643. */
  17644. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17645. /**
  17646. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17647. * This allowed control for front to back rendering or reversly depending of the special needs.
  17648. *
  17649. * @param renderingGroupId The rendering group id corresponding to its index
  17650. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17651. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17652. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17653. */
  17654. 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;
  17655. /**
  17656. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17657. *
  17658. * @param renderingGroupId The rendering group id corresponding to its index
  17659. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17660. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17661. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17662. */
  17663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17664. /**
  17665. * Gets the current auto clear configuration for one rendering group of the rendering
  17666. * manager.
  17667. * @param index the rendering group index to get the information for
  17668. * @returns The auto clear setup for the requested rendering group
  17669. */
  17670. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17671. }
  17672. }
  17673. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17674. import { Observable } from "babylonjs/Misc/observable";
  17675. import { SmartArray } from "babylonjs/Misc/smartArray";
  17676. import { Nullable } from "babylonjs/types";
  17677. import { Camera } from "babylonjs/Cameras/camera";
  17678. import { Scene } from "babylonjs/scene";
  17679. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17680. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17684. import { Texture } from "babylonjs/Materials/Textures/texture";
  17685. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17686. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17687. import { Engine } from "babylonjs/Engines/engine";
  17688. /**
  17689. * This Helps creating a texture that will be created from a camera in your scene.
  17690. * It is basically a dynamic texture that could be used to create special effects for instance.
  17691. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17692. */
  17693. export class RenderTargetTexture extends Texture {
  17694. isCube: boolean;
  17695. /**
  17696. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17697. */
  17698. static readonly REFRESHRATE_RENDER_ONCE: number;
  17699. /**
  17700. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17701. */
  17702. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17703. /**
  17704. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17705. * the central point of your effect and can save a lot of performances.
  17706. */
  17707. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17708. /**
  17709. * Use this predicate to dynamically define the list of mesh you want to render.
  17710. * If set, the renderList property will be overwritten.
  17711. */
  17712. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17713. private _renderList;
  17714. /**
  17715. * Use this list to define the list of mesh you want to render.
  17716. */
  17717. renderList: Nullable<Array<AbstractMesh>>;
  17718. private _hookArray;
  17719. /**
  17720. * Define if particles should be rendered in your texture.
  17721. */
  17722. renderParticles: boolean;
  17723. /**
  17724. * Define if sprites should be rendered in your texture.
  17725. */
  17726. renderSprites: boolean;
  17727. /**
  17728. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17729. */
  17730. coordinatesMode: number;
  17731. /**
  17732. * Define the camera used to render the texture.
  17733. */
  17734. activeCamera: Nullable<Camera>;
  17735. /**
  17736. * Override the render function of the texture with your own one.
  17737. */
  17738. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17739. /**
  17740. * Define if camera post processes should be use while rendering the texture.
  17741. */
  17742. useCameraPostProcesses: boolean;
  17743. /**
  17744. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17745. */
  17746. ignoreCameraViewport: boolean;
  17747. private _postProcessManager;
  17748. private _postProcesses;
  17749. private _resizeObserver;
  17750. /**
  17751. * An event triggered when the texture is unbind.
  17752. */
  17753. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17754. /**
  17755. * An event triggered when the texture is unbind.
  17756. */
  17757. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17758. private _onAfterUnbindObserver;
  17759. /**
  17760. * Set a after unbind callback in the texture.
  17761. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17762. */
  17763. onAfterUnbind: () => void;
  17764. /**
  17765. * An event triggered before rendering the texture
  17766. */
  17767. onBeforeRenderObservable: Observable<number>;
  17768. private _onBeforeRenderObserver;
  17769. /**
  17770. * Set a before render callback in the texture.
  17771. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17772. */
  17773. onBeforeRender: (faceIndex: number) => void;
  17774. /**
  17775. * An event triggered after rendering the texture
  17776. */
  17777. onAfterRenderObservable: Observable<number>;
  17778. private _onAfterRenderObserver;
  17779. /**
  17780. * Set a after render callback in the texture.
  17781. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17782. */
  17783. onAfterRender: (faceIndex: number) => void;
  17784. /**
  17785. * An event triggered after the texture clear
  17786. */
  17787. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17788. private _onClearObserver;
  17789. /**
  17790. * Set a clear callback in the texture.
  17791. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17792. */
  17793. onClear: (Engine: Engine) => void;
  17794. /**
  17795. * Define the clear color of the Render Target if it should be different from the scene.
  17796. */
  17797. clearColor: Color4;
  17798. protected _size: number | {
  17799. width: number;
  17800. height: number;
  17801. };
  17802. protected _initialSizeParameter: number | {
  17803. width: number;
  17804. height: number;
  17805. } | {
  17806. ratio: number;
  17807. };
  17808. protected _sizeRatio: Nullable<number>;
  17809. /** @hidden */
  17810. _generateMipMaps: boolean;
  17811. protected _renderingManager: RenderingManager;
  17812. /** @hidden */
  17813. _waitingRenderList: string[];
  17814. protected _doNotChangeAspectRatio: boolean;
  17815. protected _currentRefreshId: number;
  17816. protected _refreshRate: number;
  17817. protected _textureMatrix: Matrix;
  17818. protected _samples: number;
  17819. protected _renderTargetOptions: RenderTargetCreationOptions;
  17820. /**
  17821. * Gets render target creation options that were used.
  17822. */
  17823. readonly renderTargetOptions: RenderTargetCreationOptions;
  17824. protected _engine: Engine;
  17825. protected _onRatioRescale(): void;
  17826. /**
  17827. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17828. * It must define where the camera used to render the texture is set
  17829. */
  17830. boundingBoxPosition: Vector3;
  17831. private _boundingBoxSize;
  17832. /**
  17833. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17834. * When defined, the cubemap will switch to local mode
  17835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17836. * @example https://www.babylonjs-playground.com/#RNASML
  17837. */
  17838. boundingBoxSize: Vector3;
  17839. /**
  17840. * In case the RTT has been created with a depth texture, get the associated
  17841. * depth texture.
  17842. * Otherwise, return null.
  17843. */
  17844. depthStencilTexture: Nullable<InternalTexture>;
  17845. /**
  17846. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17847. * or used a shadow, depth texture...
  17848. * @param name The friendly name of the texture
  17849. * @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)
  17850. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17851. * @param generateMipMaps True if mip maps need to be generated after render.
  17852. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17853. * @param type The type of the buffer in the RTT (int, half float, float...)
  17854. * @param isCube True if a cube texture needs to be created
  17855. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17856. * @param generateDepthBuffer True to generate a depth buffer
  17857. * @param generateStencilBuffer True to generate a stencil buffer
  17858. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17859. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17860. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17861. */
  17862. constructor(name: string, size: number | {
  17863. width: number;
  17864. height: number;
  17865. } | {
  17866. ratio: number;
  17867. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17868. /**
  17869. * Creates a depth stencil texture.
  17870. * This is only available in WebGL 2 or with the depth texture extension available.
  17871. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17872. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17873. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17874. */
  17875. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17876. private _processSizeParameter;
  17877. /**
  17878. * Define the number of samples to use in case of MSAA.
  17879. * It defaults to one meaning no MSAA has been enabled.
  17880. */
  17881. samples: number;
  17882. /**
  17883. * Resets the refresh counter of the texture and start bak from scratch.
  17884. * Could be useful to regenerate the texture if it is setup to render only once.
  17885. */
  17886. resetRefreshCounter(): void;
  17887. /**
  17888. * Define the refresh rate of the texture or the rendering frequency.
  17889. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17890. */
  17891. refreshRate: number;
  17892. /**
  17893. * Adds a post process to the render target rendering passes.
  17894. * @param postProcess define the post process to add
  17895. */
  17896. addPostProcess(postProcess: PostProcess): void;
  17897. /**
  17898. * Clear all the post processes attached to the render target
  17899. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17900. */
  17901. clearPostProcesses(dispose?: boolean): void;
  17902. /**
  17903. * Remove one of the post process from the list of attached post processes to the texture
  17904. * @param postProcess define the post process to remove from the list
  17905. */
  17906. removePostProcess(postProcess: PostProcess): void;
  17907. /** @hidden */
  17908. _shouldRender(): boolean;
  17909. /**
  17910. * Gets the actual render size of the texture.
  17911. * @returns the width of the render size
  17912. */
  17913. getRenderSize(): number;
  17914. /**
  17915. * Gets the actual render width of the texture.
  17916. * @returns the width of the render size
  17917. */
  17918. getRenderWidth(): number;
  17919. /**
  17920. * Gets the actual render height of the texture.
  17921. * @returns the height of the render size
  17922. */
  17923. getRenderHeight(): number;
  17924. /**
  17925. * Get if the texture can be rescaled or not.
  17926. */
  17927. readonly canRescale: boolean;
  17928. /**
  17929. * Resize the texture using a ratio.
  17930. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17931. */
  17932. scale(ratio: number): void;
  17933. /**
  17934. * Get the texture reflection matrix used to rotate/transform the reflection.
  17935. * @returns the reflection matrix
  17936. */
  17937. getReflectionTextureMatrix(): Matrix;
  17938. /**
  17939. * Resize the texture to a new desired size.
  17940. * Be carrefull as it will recreate all the data in the new texture.
  17941. * @param size Define the new size. It can be:
  17942. * - a number for squared texture,
  17943. * - an object containing { width: number, height: number }
  17944. * - or an object containing a ratio { ratio: number }
  17945. */
  17946. resize(size: number | {
  17947. width: number;
  17948. height: number;
  17949. } | {
  17950. ratio: number;
  17951. }): void;
  17952. /**
  17953. * Renders all the objects from the render list into the texture.
  17954. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17955. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17956. */
  17957. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17958. private _bestReflectionRenderTargetDimension;
  17959. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17960. private renderToTarget;
  17961. /**
  17962. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17963. * This allowed control for front to back rendering or reversly depending of the special needs.
  17964. *
  17965. * @param renderingGroupId The rendering group id corresponding to its index
  17966. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17967. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17968. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17969. */
  17970. 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;
  17971. /**
  17972. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17973. *
  17974. * @param renderingGroupId The rendering group id corresponding to its index
  17975. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17976. */
  17977. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17978. /**
  17979. * Clones the texture.
  17980. * @returns the cloned texture
  17981. */
  17982. clone(): RenderTargetTexture;
  17983. /**
  17984. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17985. * @returns The JSON representation of the texture
  17986. */
  17987. serialize(): any;
  17988. /**
  17989. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17990. */
  17991. disposeFramebufferObjects(): void;
  17992. /**
  17993. * Dispose the texture and release its associated resources.
  17994. */
  17995. dispose(): void;
  17996. /** @hidden */
  17997. _rebuild(): void;
  17998. /**
  17999. * Clear the info related to rendering groups preventing retention point in material dispose.
  18000. */
  18001. freeRenderingGroups(): void;
  18002. }
  18003. }
  18004. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18005. import { Scene } from "babylonjs/scene";
  18006. import { Plane } from "babylonjs/Maths/math";
  18007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18008. /**
  18009. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18010. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18011. * You can then easily use it as a reflectionTexture on a flat surface.
  18012. * In case the surface is not a plane, please consider relying on reflection probes.
  18013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18014. */
  18015. export class MirrorTexture extends RenderTargetTexture {
  18016. private scene;
  18017. /**
  18018. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18019. * 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.
  18020. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18021. */
  18022. mirrorPlane: Plane;
  18023. /**
  18024. * Define the blur ratio used to blur the reflection if needed.
  18025. */
  18026. blurRatio: number;
  18027. /**
  18028. * Define the adaptive blur kernel used to blur the reflection if needed.
  18029. * This will autocompute the closest best match for the `blurKernel`
  18030. */
  18031. adaptiveBlurKernel: number;
  18032. /**
  18033. * Define the blur kernel used to blur the reflection if needed.
  18034. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18035. */
  18036. blurKernel: number;
  18037. /**
  18038. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18039. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18040. */
  18041. blurKernelX: number;
  18042. /**
  18043. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18044. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18045. */
  18046. blurKernelY: number;
  18047. private _autoComputeBlurKernel;
  18048. protected _onRatioRescale(): void;
  18049. private _updateGammaSpace;
  18050. private _imageProcessingConfigChangeObserver;
  18051. private _transformMatrix;
  18052. private _mirrorMatrix;
  18053. private _savedViewMatrix;
  18054. private _blurX;
  18055. private _blurY;
  18056. private _adaptiveBlurKernel;
  18057. private _blurKernelX;
  18058. private _blurKernelY;
  18059. private _blurRatio;
  18060. /**
  18061. * Instantiates a Mirror Texture.
  18062. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18063. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18064. * You can then easily use it as a reflectionTexture on a flat surface.
  18065. * In case the surface is not a plane, please consider relying on reflection probes.
  18066. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18067. * @param name
  18068. * @param size
  18069. * @param scene
  18070. * @param generateMipMaps
  18071. * @param type
  18072. * @param samplingMode
  18073. * @param generateDepthBuffer
  18074. */
  18075. constructor(name: string, size: number | {
  18076. width: number;
  18077. height: number;
  18078. } | {
  18079. ratio: number;
  18080. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18081. private _preparePostProcesses;
  18082. /**
  18083. * Clone the mirror texture.
  18084. * @returns the cloned texture
  18085. */
  18086. clone(): MirrorTexture;
  18087. /**
  18088. * Serialize the texture to a JSON representation you could use in Parse later on
  18089. * @returns the serialized JSON representation
  18090. */
  18091. serialize(): any;
  18092. /**
  18093. * Dispose the texture and release its associated resources.
  18094. */
  18095. dispose(): void;
  18096. }
  18097. }
  18098. declare module "babylonjs/Materials/Textures/texture" {
  18099. import { Observable } from "babylonjs/Misc/observable";
  18100. import { Nullable } from "babylonjs/types";
  18101. import { Scene } from "babylonjs/scene";
  18102. import { Matrix } from "babylonjs/Maths/math";
  18103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18104. /**
  18105. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18106. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18107. */
  18108. export class Texture extends BaseTexture {
  18109. /** @hidden */
  18110. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18111. /** @hidden */
  18112. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18113. /** @hidden */
  18114. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18115. /** nearest is mag = nearest and min = nearest and mip = linear */
  18116. static readonly NEAREST_SAMPLINGMODE: number;
  18117. /** nearest is mag = nearest and min = nearest and mip = linear */
  18118. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18119. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18120. static readonly BILINEAR_SAMPLINGMODE: number;
  18121. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18122. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18123. /** Trilinear is mag = linear and min = linear and mip = linear */
  18124. static readonly TRILINEAR_SAMPLINGMODE: number;
  18125. /** Trilinear is mag = linear and min = linear and mip = linear */
  18126. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18127. /** mag = nearest and min = nearest and mip = nearest */
  18128. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18129. /** mag = nearest and min = linear and mip = nearest */
  18130. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18131. /** mag = nearest and min = linear and mip = linear */
  18132. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18133. /** mag = nearest and min = linear and mip = none */
  18134. static readonly NEAREST_LINEAR: number;
  18135. /** mag = nearest and min = nearest and mip = none */
  18136. static readonly NEAREST_NEAREST: number;
  18137. /** mag = linear and min = nearest and mip = nearest */
  18138. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18139. /** mag = linear and min = nearest and mip = linear */
  18140. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18141. /** mag = linear and min = linear and mip = none */
  18142. static readonly LINEAR_LINEAR: number;
  18143. /** mag = linear and min = nearest and mip = none */
  18144. static readonly LINEAR_NEAREST: number;
  18145. /** Explicit coordinates mode */
  18146. static readonly EXPLICIT_MODE: number;
  18147. /** Spherical coordinates mode */
  18148. static readonly SPHERICAL_MODE: number;
  18149. /** Planar coordinates mode */
  18150. static readonly PLANAR_MODE: number;
  18151. /** Cubic coordinates mode */
  18152. static readonly CUBIC_MODE: number;
  18153. /** Projection coordinates mode */
  18154. static readonly PROJECTION_MODE: number;
  18155. /** Inverse Cubic coordinates mode */
  18156. static readonly SKYBOX_MODE: number;
  18157. /** Inverse Cubic coordinates mode */
  18158. static readonly INVCUBIC_MODE: number;
  18159. /** Equirectangular coordinates mode */
  18160. static readonly EQUIRECTANGULAR_MODE: number;
  18161. /** Equirectangular Fixed coordinates mode */
  18162. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18163. /** Equirectangular Fixed Mirrored coordinates mode */
  18164. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18165. /** Texture is not repeating outside of 0..1 UVs */
  18166. static readonly CLAMP_ADDRESSMODE: number;
  18167. /** Texture is repeating outside of 0..1 UVs */
  18168. static readonly WRAP_ADDRESSMODE: number;
  18169. /** Texture is repeating and mirrored */
  18170. static readonly MIRROR_ADDRESSMODE: number;
  18171. /**
  18172. * 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
  18173. */
  18174. static UseSerializedUrlIfAny: boolean;
  18175. /**
  18176. * Define the url of the texture.
  18177. */
  18178. url: Nullable<string>;
  18179. /**
  18180. * Define an offset on the texture to offset the u coordinates of the UVs
  18181. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18182. */
  18183. uOffset: number;
  18184. /**
  18185. * Define an offset on the texture to offset the v coordinates of the UVs
  18186. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18187. */
  18188. vOffset: number;
  18189. /**
  18190. * Define an offset on the texture to scale the u coordinates of the UVs
  18191. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18192. */
  18193. uScale: number;
  18194. /**
  18195. * Define an offset on the texture to scale the v coordinates of the UVs
  18196. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18197. */
  18198. vScale: number;
  18199. /**
  18200. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18201. * @see http://doc.babylonjs.com/how_to/more_materials
  18202. */
  18203. uAng: number;
  18204. /**
  18205. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18206. * @see http://doc.babylonjs.com/how_to/more_materials
  18207. */
  18208. vAng: number;
  18209. /**
  18210. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18211. * @see http://doc.babylonjs.com/how_to/more_materials
  18212. */
  18213. wAng: number;
  18214. /**
  18215. * Defines the center of rotation (U)
  18216. */
  18217. uRotationCenter: number;
  18218. /**
  18219. * Defines the center of rotation (V)
  18220. */
  18221. vRotationCenter: number;
  18222. /**
  18223. * Defines the center of rotation (W)
  18224. */
  18225. wRotationCenter: number;
  18226. /**
  18227. * Are mip maps generated for this texture or not.
  18228. */
  18229. readonly noMipmap: boolean;
  18230. private _noMipmap;
  18231. /** @hidden */
  18232. _invertY: boolean;
  18233. private _rowGenerationMatrix;
  18234. private _cachedTextureMatrix;
  18235. private _projectionModeMatrix;
  18236. private _t0;
  18237. private _t1;
  18238. private _t2;
  18239. private _cachedUOffset;
  18240. private _cachedVOffset;
  18241. private _cachedUScale;
  18242. private _cachedVScale;
  18243. private _cachedUAng;
  18244. private _cachedVAng;
  18245. private _cachedWAng;
  18246. private _cachedProjectionMatrixId;
  18247. private _cachedCoordinatesMode;
  18248. /** @hidden */
  18249. protected _initialSamplingMode: number;
  18250. /** @hidden */
  18251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18252. private _deleteBuffer;
  18253. protected _format: Nullable<number>;
  18254. private _delayedOnLoad;
  18255. private _delayedOnError;
  18256. /**
  18257. * Observable triggered once the texture has been loaded.
  18258. */
  18259. onLoadObservable: Observable<Texture>;
  18260. protected _isBlocking: boolean;
  18261. /**
  18262. * Is the texture preventing material to render while loading.
  18263. * If false, a default texture will be used instead of the loading one during the preparation step.
  18264. */
  18265. isBlocking: boolean;
  18266. /**
  18267. * Get the current sampling mode associated with the texture.
  18268. */
  18269. readonly samplingMode: number;
  18270. /**
  18271. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18272. */
  18273. readonly invertY: boolean;
  18274. /**
  18275. * Instantiates a new texture.
  18276. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18277. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18278. * @param url define the url of the picture to load as a texture
  18279. * @param scene define the scene the texture will belong to
  18280. * @param noMipmap define if the texture will require mip maps or not
  18281. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18282. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18283. * @param onLoad define a callback triggered when the texture has been loaded
  18284. * @param onError define a callback triggered when an error occurred during the loading session
  18285. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18286. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18287. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18288. */
  18289. 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);
  18290. /**
  18291. * Update the url (and optional buffer) of this texture if url was null during construction.
  18292. * @param url the url of the texture
  18293. * @param buffer the buffer of the texture (defaults to null)
  18294. * @param onLoad callback called when the texture is loaded (defaults to null)
  18295. */
  18296. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18297. /**
  18298. * Finish the loading sequence of a texture flagged as delayed load.
  18299. * @hidden
  18300. */
  18301. delayLoad(): void;
  18302. private _prepareRowForTextureGeneration;
  18303. /**
  18304. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18305. * @returns the transform matrix of the texture.
  18306. */
  18307. getTextureMatrix(): Matrix;
  18308. /**
  18309. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18310. * @returns The reflection texture transform
  18311. */
  18312. getReflectionTextureMatrix(): Matrix;
  18313. /**
  18314. * Clones the texture.
  18315. * @returns the cloned texture
  18316. */
  18317. clone(): Texture;
  18318. /**
  18319. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18320. * @returns The JSON representation of the texture
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Get the current class name of the texture useful for serialization or dynamic coding.
  18325. * @returns "Texture"
  18326. */
  18327. getClassName(): string;
  18328. /**
  18329. * Dispose the texture and release its associated resources.
  18330. */
  18331. dispose(): void;
  18332. /**
  18333. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18334. * @param parsedTexture Define the JSON representation of the texture
  18335. * @param scene Define the scene the parsed texture should be instantiated in
  18336. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18337. * @returns The parsed texture if successful
  18338. */
  18339. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18340. /**
  18341. * Creates a texture from its base 64 representation.
  18342. * @param data Define the base64 payload without the data: prefix
  18343. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18344. * @param scene Define the scene the texture should belong to
  18345. * @param noMipmap Forces the texture to not create mip map information if true
  18346. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18347. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18348. * @param onLoad define a callback triggered when the texture has been loaded
  18349. * @param onError define a callback triggered when an error occurred during the loading session
  18350. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18351. * @returns the created texture
  18352. */
  18353. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18354. /**
  18355. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18356. * @param data Define the base64 payload without the data: prefix
  18357. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18358. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18359. * @param scene Define the scene the texture should belong to
  18360. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18361. * @param noMipmap Forces the texture to not create mip map information if true
  18362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18364. * @param onLoad define a callback triggered when the texture has been loaded
  18365. * @param onError define a callback triggered when an error occurred during the loading session
  18366. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18367. * @returns the created texture
  18368. */
  18369. 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;
  18370. }
  18371. }
  18372. declare module "babylonjs/Materials/Textures/rawTexture" {
  18373. import { Scene } from "babylonjs/scene";
  18374. import { Texture } from "babylonjs/Materials/Textures/texture";
  18375. /**
  18376. * Raw texture can help creating a texture directly from an array of data.
  18377. * This can be super useful if you either get the data from an uncompressed source or
  18378. * if you wish to create your texture pixel by pixel.
  18379. */
  18380. export class RawTexture extends Texture {
  18381. /**
  18382. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18383. */
  18384. format: number;
  18385. private _engine;
  18386. /**
  18387. * Instantiates a new RawTexture.
  18388. * Raw texture can help creating a texture directly from an array of data.
  18389. * This can be super useful if you either get the data from an uncompressed source or
  18390. * if you wish to create your texture pixel by pixel.
  18391. * @param data define the array of data to use to create the texture
  18392. * @param width define the width of the texture
  18393. * @param height define the height of the texture
  18394. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18395. * @param scene define the scene the texture belongs to
  18396. * @param generateMipMaps define whether mip maps should be generated or not
  18397. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18398. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18399. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18400. */
  18401. constructor(data: ArrayBufferView, width: number, height: number,
  18402. /**
  18403. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18404. */
  18405. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18406. /**
  18407. * Updates the texture underlying data.
  18408. * @param data Define the new data of the texture
  18409. */
  18410. update(data: ArrayBufferView): void;
  18411. /**
  18412. * Creates a luminance texture from some data.
  18413. * @param data Define the texture data
  18414. * @param width Define the width of the texture
  18415. * @param height Define the height of the texture
  18416. * @param scene Define the scene the texture belongs to
  18417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18420. * @returns the luminance texture
  18421. */
  18422. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18423. /**
  18424. * Creates a luminance alpha texture from some data.
  18425. * @param data Define the texture data
  18426. * @param width Define the width of the texture
  18427. * @param height Define the height of the texture
  18428. * @param scene Define the scene the texture belongs to
  18429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18432. * @returns the luminance alpha texture
  18433. */
  18434. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18435. /**
  18436. * Creates an alpha texture from some data.
  18437. * @param data Define the texture data
  18438. * @param width Define the width of the texture
  18439. * @param height Define the height of the texture
  18440. * @param scene Define the scene the texture belongs to
  18441. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18442. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18443. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18444. * @returns the alpha texture
  18445. */
  18446. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18447. /**
  18448. * Creates a RGB texture from some data.
  18449. * @param data Define the texture data
  18450. * @param width Define the width of the texture
  18451. * @param height Define the height of the texture
  18452. * @param scene Define the scene the texture belongs to
  18453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18456. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18457. * @returns the RGB alpha texture
  18458. */
  18459. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18460. /**
  18461. * Creates a RGBA texture from some data.
  18462. * @param data Define the texture data
  18463. * @param width Define the width of the texture
  18464. * @param height Define the height of the texture
  18465. * @param scene Define the scene the texture belongs to
  18466. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18467. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18468. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18469. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18470. * @returns the RGBA texture
  18471. */
  18472. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18473. /**
  18474. * Creates a R texture from some data.
  18475. * @param data Define the texture data
  18476. * @param width Define the width of the texture
  18477. * @param height Define the height of the texture
  18478. * @param scene Define the scene the texture belongs to
  18479. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18480. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18481. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18482. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18483. * @returns the R texture
  18484. */
  18485. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18486. }
  18487. }
  18488. declare module "babylonjs/Animations/runtimeAnimation" {
  18489. import { Animation } from "babylonjs/Animations/animation";
  18490. import { Animatable } from "babylonjs/Animations/animatable";
  18491. import { Scene } from "babylonjs/scene";
  18492. /**
  18493. * Defines a runtime animation
  18494. */
  18495. export class RuntimeAnimation {
  18496. private _events;
  18497. /**
  18498. * The current frame of the runtime animation
  18499. */
  18500. private _currentFrame;
  18501. /**
  18502. * The animation used by the runtime animation
  18503. */
  18504. private _animation;
  18505. /**
  18506. * The target of the runtime animation
  18507. */
  18508. private _target;
  18509. /**
  18510. * The initiating animatable
  18511. */
  18512. private _host;
  18513. /**
  18514. * The original value of the runtime animation
  18515. */
  18516. private _originalValue;
  18517. /**
  18518. * The original blend value of the runtime animation
  18519. */
  18520. private _originalBlendValue;
  18521. /**
  18522. * The offsets cache of the runtime animation
  18523. */
  18524. private _offsetsCache;
  18525. /**
  18526. * The high limits cache of the runtime animation
  18527. */
  18528. private _highLimitsCache;
  18529. /**
  18530. * Specifies if the runtime animation has been stopped
  18531. */
  18532. private _stopped;
  18533. /**
  18534. * The blending factor of the runtime animation
  18535. */
  18536. private _blendingFactor;
  18537. /**
  18538. * The BabylonJS scene
  18539. */
  18540. private _scene;
  18541. /**
  18542. * The current value of the runtime animation
  18543. */
  18544. private _currentValue;
  18545. /** @hidden */
  18546. _workValue: any;
  18547. /**
  18548. * The active target of the runtime animation
  18549. */
  18550. private _activeTarget;
  18551. /**
  18552. * The target path of the runtime animation
  18553. */
  18554. private _targetPath;
  18555. /**
  18556. * The weight of the runtime animation
  18557. */
  18558. private _weight;
  18559. /**
  18560. * The ratio offset of the runtime animation
  18561. */
  18562. private _ratioOffset;
  18563. /**
  18564. * The previous delay of the runtime animation
  18565. */
  18566. private _previousDelay;
  18567. /**
  18568. * The previous ratio of the runtime animation
  18569. */
  18570. private _previousRatio;
  18571. /**
  18572. * Gets the current frame of the runtime animation
  18573. */
  18574. readonly currentFrame: number;
  18575. /**
  18576. * Gets the weight of the runtime animation
  18577. */
  18578. readonly weight: number;
  18579. /**
  18580. * Gets the current value of the runtime animation
  18581. */
  18582. readonly currentValue: any;
  18583. /**
  18584. * Gets the target path of the runtime animation
  18585. */
  18586. readonly targetPath: string;
  18587. /**
  18588. * Gets the actual target of the runtime animation
  18589. */
  18590. readonly target: any;
  18591. /**
  18592. * Create a new RuntimeAnimation object
  18593. * @param target defines the target of the animation
  18594. * @param animation defines the source animation object
  18595. * @param scene defines the hosting scene
  18596. * @param host defines the initiating Animatable
  18597. */
  18598. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18599. /**
  18600. * Gets the animation from the runtime animation
  18601. */
  18602. readonly animation: Animation;
  18603. /**
  18604. * Resets the runtime animation to the beginning
  18605. * @param restoreOriginal defines whether to restore the target property to the original value
  18606. */
  18607. reset(restoreOriginal?: boolean): void;
  18608. /**
  18609. * Specifies if the runtime animation is stopped
  18610. * @returns Boolean specifying if the runtime animation is stopped
  18611. */
  18612. isStopped(): boolean;
  18613. /**
  18614. * Disposes of the runtime animation
  18615. */
  18616. dispose(): void;
  18617. /**
  18618. * Interpolates the animation from the current frame
  18619. * @param currentFrame The frame to interpolate the animation to
  18620. * @param repeatCount The number of times that the animation should loop
  18621. * @param loopMode The type of looping mode to use
  18622. * @param offsetValue Animation offset value
  18623. * @param highLimitValue The high limit value
  18624. * @returns The interpolated value
  18625. */
  18626. private _interpolate;
  18627. /**
  18628. * Apply the interpolated value to the target
  18629. * @param currentValue defines the value computed by the animation
  18630. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18631. */
  18632. setValue(currentValue: any, weight?: number): void;
  18633. private _setValue;
  18634. /**
  18635. * Gets the loop pmode of the runtime animation
  18636. * @returns Loop Mode
  18637. */
  18638. private _getCorrectLoopMode;
  18639. /**
  18640. * Move the current animation to a given frame
  18641. * @param frame defines the frame to move to
  18642. */
  18643. goToFrame(frame: number): void;
  18644. /**
  18645. * @hidden Internal use only
  18646. */
  18647. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18648. /**
  18649. * Execute the current animation
  18650. * @param delay defines the delay to add to the current frame
  18651. * @param from defines the lower bound of the animation range
  18652. * @param to defines the upper bound of the animation range
  18653. * @param loop defines if the current animation must loop
  18654. * @param speedRatio defines the current speed ratio
  18655. * @param weight defines the weight of the animation (default is -1 so no weight)
  18656. * @param onLoop optional callback called when animation loops
  18657. * @returns a boolean indicating if the animation is running
  18658. */
  18659. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18660. }
  18661. }
  18662. declare module "babylonjs/Animations/animatable" {
  18663. import { Animation } from "babylonjs/Animations/animation";
  18664. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18665. import { Nullable } from "babylonjs/types";
  18666. import { Observable } from "babylonjs/Misc/observable";
  18667. import { Scene } from "babylonjs/scene";
  18668. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18669. import { Node } from "babylonjs/node";
  18670. /**
  18671. * Class used to store an actual running animation
  18672. */
  18673. export class Animatable {
  18674. /** defines the target object */
  18675. target: any;
  18676. /** defines the starting frame number (default is 0) */
  18677. fromFrame: number;
  18678. /** defines the ending frame number (default is 100) */
  18679. toFrame: number;
  18680. /** defines if the animation must loop (default is false) */
  18681. loopAnimation: boolean;
  18682. /** defines a callback to call when animation ends if it is not looping */
  18683. onAnimationEnd?: (() => void) | null | undefined;
  18684. /** defines a callback to call when animation loops */
  18685. onAnimationLoop?: (() => void) | null | undefined;
  18686. private _localDelayOffset;
  18687. private _pausedDelay;
  18688. private _runtimeAnimations;
  18689. private _paused;
  18690. private _scene;
  18691. private _speedRatio;
  18692. private _weight;
  18693. private _syncRoot;
  18694. /**
  18695. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18696. * This will only apply for non looping animation (default is true)
  18697. */
  18698. disposeOnEnd: boolean;
  18699. /**
  18700. * Gets a boolean indicating if the animation has started
  18701. */
  18702. animationStarted: boolean;
  18703. /**
  18704. * Observer raised when the animation ends
  18705. */
  18706. onAnimationEndObservable: Observable<Animatable>;
  18707. /**
  18708. * Observer raised when the animation loops
  18709. */
  18710. onAnimationLoopObservable: Observable<Animatable>;
  18711. /**
  18712. * Gets the root Animatable used to synchronize and normalize animations
  18713. */
  18714. readonly syncRoot: Animatable;
  18715. /**
  18716. * Gets the current frame of the first RuntimeAnimation
  18717. * Used to synchronize Animatables
  18718. */
  18719. readonly masterFrame: number;
  18720. /**
  18721. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18722. */
  18723. weight: number;
  18724. /**
  18725. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18726. */
  18727. speedRatio: number;
  18728. /**
  18729. * Creates a new Animatable
  18730. * @param scene defines the hosting scene
  18731. * @param target defines the target object
  18732. * @param fromFrame defines the starting frame number (default is 0)
  18733. * @param toFrame defines the ending frame number (default is 100)
  18734. * @param loopAnimation defines if the animation must loop (default is false)
  18735. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18736. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18737. * @param animations defines a group of animation to add to the new Animatable
  18738. * @param onAnimationLoop defines a callback to call when animation loops
  18739. */
  18740. constructor(scene: Scene,
  18741. /** defines the target object */
  18742. target: any,
  18743. /** defines the starting frame number (default is 0) */
  18744. fromFrame?: number,
  18745. /** defines the ending frame number (default is 100) */
  18746. toFrame?: number,
  18747. /** defines if the animation must loop (default is false) */
  18748. loopAnimation?: boolean, speedRatio?: number,
  18749. /** defines a callback to call when animation ends if it is not looping */
  18750. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18751. /** defines a callback to call when animation loops */
  18752. onAnimationLoop?: (() => void) | null | undefined);
  18753. /**
  18754. * Synchronize and normalize current Animatable with a source Animatable
  18755. * This is useful when using animation weights and when animations are not of the same length
  18756. * @param root defines the root Animatable to synchronize with
  18757. * @returns the current Animatable
  18758. */
  18759. syncWith(root: Animatable): Animatable;
  18760. /**
  18761. * Gets the list of runtime animations
  18762. * @returns an array of RuntimeAnimation
  18763. */
  18764. getAnimations(): RuntimeAnimation[];
  18765. /**
  18766. * Adds more animations to the current animatable
  18767. * @param target defines the target of the animations
  18768. * @param animations defines the new animations to add
  18769. */
  18770. appendAnimations(target: any, animations: Animation[]): void;
  18771. /**
  18772. * Gets the source animation for a specific property
  18773. * @param property defines the propertyu to look for
  18774. * @returns null or the source animation for the given property
  18775. */
  18776. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18777. /**
  18778. * Gets the runtime animation for a specific property
  18779. * @param property defines the propertyu to look for
  18780. * @returns null or the runtime animation for the given property
  18781. */
  18782. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18783. /**
  18784. * Resets the animatable to its original state
  18785. */
  18786. reset(): void;
  18787. /**
  18788. * Allows the animatable to blend with current running animations
  18789. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18790. * @param blendingSpeed defines the blending speed to use
  18791. */
  18792. enableBlending(blendingSpeed: number): void;
  18793. /**
  18794. * Disable animation blending
  18795. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18796. */
  18797. disableBlending(): void;
  18798. /**
  18799. * Jump directly to a given frame
  18800. * @param frame defines the frame to jump to
  18801. */
  18802. goToFrame(frame: number): void;
  18803. /**
  18804. * Pause the animation
  18805. */
  18806. pause(): void;
  18807. /**
  18808. * Restart the animation
  18809. */
  18810. restart(): void;
  18811. private _raiseOnAnimationEnd;
  18812. /**
  18813. * Stop and delete the current animation
  18814. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18815. * @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)
  18816. */
  18817. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18818. /**
  18819. * Wait asynchronously for the animation to end
  18820. * @returns a promise which will be fullfilled when the animation ends
  18821. */
  18822. waitAsync(): Promise<Animatable>;
  18823. /** @hidden */
  18824. _animate(delay: number): boolean;
  18825. }
  18826. module "babylonjs/scene" {
  18827. interface Scene {
  18828. /** @hidden */
  18829. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18830. /** @hidden */
  18831. _processLateAnimationBindingsForMatrices(holder: {
  18832. totalWeight: number;
  18833. animations: RuntimeAnimation[];
  18834. originalValue: Matrix;
  18835. }): any;
  18836. /** @hidden */
  18837. _processLateAnimationBindingsForQuaternions(holder: {
  18838. totalWeight: number;
  18839. animations: RuntimeAnimation[];
  18840. originalValue: Quaternion;
  18841. }, refQuaternion: Quaternion): Quaternion;
  18842. /** @hidden */
  18843. _processLateAnimationBindings(): void;
  18844. /**
  18845. * Will start the animation sequence of a given target
  18846. * @param target defines the target
  18847. * @param from defines from which frame should animation start
  18848. * @param to defines until which frame should animation run.
  18849. * @param weight defines the weight to apply to the animation (1.0 by default)
  18850. * @param loop defines if the animation loops
  18851. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18852. * @param onAnimationEnd defines the function to be executed when the animation ends
  18853. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18854. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18855. * @param onAnimationLoop defines the callback to call when an animation loops
  18856. * @returns the animatable object created for this animation
  18857. */
  18858. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18859. /**
  18860. * Will start the animation sequence of a given target
  18861. * @param target defines the target
  18862. * @param from defines from which frame should animation start
  18863. * @param to defines until which frame should animation run.
  18864. * @param loop defines if the animation loops
  18865. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18866. * @param onAnimationEnd defines the function to be executed when the animation ends
  18867. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18868. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18869. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18870. * @param onAnimationLoop defines the callback to call when an animation loops
  18871. * @returns the animatable object created for this animation
  18872. */
  18873. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18874. /**
  18875. * Will start the animation sequence of a given target and its hierarchy
  18876. * @param target defines the target
  18877. * @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.
  18878. * @param from defines from which frame should animation start
  18879. * @param to defines until which frame should animation run.
  18880. * @param loop defines if the animation loops
  18881. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18882. * @param onAnimationEnd defines the function to be executed when the animation ends
  18883. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18884. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18885. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18886. * @param onAnimationLoop defines the callback to call when an animation loops
  18887. * @returns the list of created animatables
  18888. */
  18889. 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[];
  18890. /**
  18891. * Begin a new animation on a given node
  18892. * @param target defines the target where the animation will take place
  18893. * @param animations defines the list of animations to start
  18894. * @param from defines the initial value
  18895. * @param to defines the final value
  18896. * @param loop defines if you want animation to loop (off by default)
  18897. * @param speedRatio defines the speed ratio to apply to all animations
  18898. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18899. * @param onAnimationLoop defines the callback to call when an animation loops
  18900. * @returns the list of created animatables
  18901. */
  18902. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18903. /**
  18904. * Begin a new animation on a given node and its hierarchy
  18905. * @param target defines the root node where the animation will take place
  18906. * @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.
  18907. * @param animations defines the list of animations to start
  18908. * @param from defines the initial value
  18909. * @param to defines the final value
  18910. * @param loop defines if you want animation to loop (off by default)
  18911. * @param speedRatio defines the speed ratio to apply to all animations
  18912. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18913. * @param onAnimationLoop defines the callback to call when an animation loops
  18914. * @returns the list of animatables created for all nodes
  18915. */
  18916. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18917. /**
  18918. * Gets the animatable associated with a specific target
  18919. * @param target defines the target of the animatable
  18920. * @returns the required animatable if found
  18921. */
  18922. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18923. /**
  18924. * Gets all animatables associated with a given target
  18925. * @param target defines the target to look animatables for
  18926. * @returns an array of Animatables
  18927. */
  18928. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18929. /**
  18930. * Will stop the animation of the given target
  18931. * @param target - the target
  18932. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18933. * @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)
  18934. */
  18935. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18936. /**
  18937. * Stops and removes all animations that have been applied to the scene
  18938. */
  18939. stopAllAnimations(): void;
  18940. }
  18941. }
  18942. module "babylonjs/Bones/bone" {
  18943. interface Bone {
  18944. /**
  18945. * Copy an animation range from another bone
  18946. * @param source defines the source bone
  18947. * @param rangeName defines the range name to copy
  18948. * @param frameOffset defines the frame offset
  18949. * @param rescaleAsRequired defines if rescaling must be applied if required
  18950. * @param skelDimensionsRatio defines the scaling ratio
  18951. * @returns true if operation was successful
  18952. */
  18953. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18954. }
  18955. }
  18956. }
  18957. declare module "babylonjs/Bones/skeleton" {
  18958. import { Bone } from "babylonjs/Bones/bone";
  18959. import { IAnimatable } from "babylonjs/Misc/tools";
  18960. import { Observable } from "babylonjs/Misc/observable";
  18961. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18962. import { Scene } from "babylonjs/scene";
  18963. import { Nullable } from "babylonjs/types";
  18964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18965. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18966. import { Animatable } from "babylonjs/Animations/animatable";
  18967. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18968. import { Animation } from "babylonjs/Animations/animation";
  18969. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18970. /**
  18971. * Class used to handle skinning animations
  18972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18973. */
  18974. export class Skeleton implements IAnimatable {
  18975. /** defines the skeleton name */
  18976. name: string;
  18977. /** defines the skeleton Id */
  18978. id: string;
  18979. /**
  18980. * Defines the list of child bones
  18981. */
  18982. bones: Bone[];
  18983. /**
  18984. * Defines an estimate of the dimension of the skeleton at rest
  18985. */
  18986. dimensionsAtRest: Vector3;
  18987. /**
  18988. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18989. */
  18990. needInitialSkinMatrix: boolean;
  18991. /**
  18992. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18993. */
  18994. overrideMesh: Nullable<AbstractMesh>;
  18995. /**
  18996. * Gets the list of animations attached to this skeleton
  18997. */
  18998. animations: Array<Animation>;
  18999. private _scene;
  19000. private _isDirty;
  19001. private _transformMatrices;
  19002. private _transformMatrixTexture;
  19003. private _meshesWithPoseMatrix;
  19004. private _animatables;
  19005. private _identity;
  19006. private _synchronizedWithMesh;
  19007. private _ranges;
  19008. private _lastAbsoluteTransformsUpdateId;
  19009. private _canUseTextureForBones;
  19010. /** @hidden */
  19011. _numBonesWithLinkedTransformNode: number;
  19012. /**
  19013. * Specifies if the skeleton should be serialized
  19014. */
  19015. doNotSerialize: boolean;
  19016. private _useTextureToStoreBoneMatrices;
  19017. /**
  19018. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19019. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19020. */
  19021. useTextureToStoreBoneMatrices: boolean;
  19022. private _animationPropertiesOverride;
  19023. /**
  19024. * Gets or sets the animation properties override
  19025. */
  19026. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19027. /**
  19028. * An observable triggered before computing the skeleton's matrices
  19029. */
  19030. onBeforeComputeObservable: Observable<Skeleton>;
  19031. /**
  19032. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19033. */
  19034. readonly isUsingTextureForMatrices: boolean;
  19035. /**
  19036. * Creates a new skeleton
  19037. * @param name defines the skeleton name
  19038. * @param id defines the skeleton Id
  19039. * @param scene defines the hosting scene
  19040. */
  19041. constructor(
  19042. /** defines the skeleton name */
  19043. name: string,
  19044. /** defines the skeleton Id */
  19045. id: string, scene: Scene);
  19046. /**
  19047. * Gets the current object class name.
  19048. * @return the class name
  19049. */
  19050. getClassName(): string;
  19051. /**
  19052. * Returns an array containing the root bones
  19053. * @returns an array containing the root bones
  19054. */
  19055. getChildren(): Array<Bone>;
  19056. /**
  19057. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19058. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19059. * @returns a Float32Array containing matrices data
  19060. */
  19061. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19062. /**
  19063. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19064. * @returns a raw texture containing the data
  19065. */
  19066. getTransformMatrixTexture(): Nullable<RawTexture>;
  19067. /**
  19068. * Gets the current hosting scene
  19069. * @returns a scene object
  19070. */
  19071. getScene(): Scene;
  19072. /**
  19073. * Gets a string representing the current skeleton data
  19074. * @param fullDetails defines a boolean indicating if we want a verbose version
  19075. * @returns a string representing the current skeleton data
  19076. */
  19077. toString(fullDetails?: boolean): string;
  19078. /**
  19079. * Get bone's index searching by name
  19080. * @param name defines bone's name to search for
  19081. * @return the indice of the bone. Returns -1 if not found
  19082. */
  19083. getBoneIndexByName(name: string): number;
  19084. /**
  19085. * Creater a new animation range
  19086. * @param name defines the name of the range
  19087. * @param from defines the start key
  19088. * @param to defines the end key
  19089. */
  19090. createAnimationRange(name: string, from: number, to: number): void;
  19091. /**
  19092. * Delete a specific animation range
  19093. * @param name defines the name of the range
  19094. * @param deleteFrames defines if frames must be removed as well
  19095. */
  19096. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19097. /**
  19098. * Gets a specific animation range
  19099. * @param name defines the name of the range to look for
  19100. * @returns the requested animation range or null if not found
  19101. */
  19102. getAnimationRange(name: string): Nullable<AnimationRange>;
  19103. /**
  19104. * Gets the list of all animation ranges defined on this skeleton
  19105. * @returns an array
  19106. */
  19107. getAnimationRanges(): Nullable<AnimationRange>[];
  19108. /**
  19109. * Copy animation range from a source skeleton.
  19110. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19111. * @param source defines the source skeleton
  19112. * @param name defines the name of the range to copy
  19113. * @param rescaleAsRequired defines if rescaling must be applied if required
  19114. * @returns true if operation was successful
  19115. */
  19116. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19117. /**
  19118. * Forces the skeleton to go to rest pose
  19119. */
  19120. returnToRest(): void;
  19121. private _getHighestAnimationFrame;
  19122. /**
  19123. * Begin a specific animation range
  19124. * @param name defines the name of the range to start
  19125. * @param loop defines if looping must be turned on (false by default)
  19126. * @param speedRatio defines the speed ratio to apply (1 by default)
  19127. * @param onAnimationEnd defines a callback which will be called when animation will end
  19128. * @returns a new animatable
  19129. */
  19130. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19131. /** @hidden */
  19132. _markAsDirty(): void;
  19133. /** @hidden */
  19134. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19135. /** @hidden */
  19136. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19137. private _computeTransformMatrices;
  19138. /**
  19139. * Build all resources required to render a skeleton
  19140. */
  19141. prepare(): void;
  19142. /**
  19143. * Gets the list of animatables currently running for this skeleton
  19144. * @returns an array of animatables
  19145. */
  19146. getAnimatables(): IAnimatable[];
  19147. /**
  19148. * Clone the current skeleton
  19149. * @param name defines the name of the new skeleton
  19150. * @param id defines the id of the enw skeleton
  19151. * @returns the new skeleton
  19152. */
  19153. clone(name: string, id: string): Skeleton;
  19154. /**
  19155. * Enable animation blending for this skeleton
  19156. * @param blendingSpeed defines the blending speed to apply
  19157. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19158. */
  19159. enableBlending(blendingSpeed?: number): void;
  19160. /**
  19161. * Releases all resources associated with the current skeleton
  19162. */
  19163. dispose(): void;
  19164. /**
  19165. * Serialize the skeleton in a JSON object
  19166. * @returns a JSON object
  19167. */
  19168. serialize(): any;
  19169. /**
  19170. * Creates a new skeleton from serialized data
  19171. * @param parsedSkeleton defines the serialized data
  19172. * @param scene defines the hosting scene
  19173. * @returns a new skeleton
  19174. */
  19175. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19176. /**
  19177. * Compute all node absolute transforms
  19178. * @param forceUpdate defines if computation must be done even if cache is up to date
  19179. */
  19180. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19181. /**
  19182. * Gets the root pose matrix
  19183. * @returns a matrix
  19184. */
  19185. getPoseMatrix(): Nullable<Matrix>;
  19186. /**
  19187. * Sorts bones per internal index
  19188. */
  19189. sortBones(): void;
  19190. private _sortBones;
  19191. }
  19192. }
  19193. declare module "babylonjs/Morph/morphTarget" {
  19194. import { IAnimatable } from "babylonjs/Misc/tools";
  19195. import { Observable } from "babylonjs/Misc/observable";
  19196. import { Nullable, FloatArray } from "babylonjs/types";
  19197. import { Scene } from "babylonjs/scene";
  19198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19199. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19200. /**
  19201. * Defines a target to use with MorphTargetManager
  19202. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19203. */
  19204. export class MorphTarget implements IAnimatable {
  19205. /** defines the name of the target */
  19206. name: string;
  19207. /**
  19208. * Gets or sets the list of animations
  19209. */
  19210. animations: import("babylonjs/Animations/animation").Animation[];
  19211. private _scene;
  19212. private _positions;
  19213. private _normals;
  19214. private _tangents;
  19215. private _influence;
  19216. /**
  19217. * Observable raised when the influence changes
  19218. */
  19219. onInfluenceChanged: Observable<boolean>;
  19220. /** @hidden */
  19221. _onDataLayoutChanged: Observable<void>;
  19222. /**
  19223. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19224. */
  19225. influence: number;
  19226. /**
  19227. * Gets or sets the id of the morph Target
  19228. */
  19229. id: string;
  19230. private _animationPropertiesOverride;
  19231. /**
  19232. * Gets or sets the animation properties override
  19233. */
  19234. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19235. /**
  19236. * Creates a new MorphTarget
  19237. * @param name defines the name of the target
  19238. * @param influence defines the influence to use
  19239. * @param scene defines the scene the morphtarget belongs to
  19240. */
  19241. constructor(
  19242. /** defines the name of the target */
  19243. name: string, influence?: number, scene?: Nullable<Scene>);
  19244. /**
  19245. * Gets a boolean defining if the target contains position data
  19246. */
  19247. readonly hasPositions: boolean;
  19248. /**
  19249. * Gets a boolean defining if the target contains normal data
  19250. */
  19251. readonly hasNormals: boolean;
  19252. /**
  19253. * Gets a boolean defining if the target contains tangent data
  19254. */
  19255. readonly hasTangents: boolean;
  19256. /**
  19257. * Affects position data to this target
  19258. * @param data defines the position data to use
  19259. */
  19260. setPositions(data: Nullable<FloatArray>): void;
  19261. /**
  19262. * Gets the position data stored in this target
  19263. * @returns a FloatArray containing the position data (or null if not present)
  19264. */
  19265. getPositions(): Nullable<FloatArray>;
  19266. /**
  19267. * Affects normal data to this target
  19268. * @param data defines the normal data to use
  19269. */
  19270. setNormals(data: Nullable<FloatArray>): void;
  19271. /**
  19272. * Gets the normal data stored in this target
  19273. * @returns a FloatArray containing the normal data (or null if not present)
  19274. */
  19275. getNormals(): Nullable<FloatArray>;
  19276. /**
  19277. * Affects tangent data to this target
  19278. * @param data defines the tangent data to use
  19279. */
  19280. setTangents(data: Nullable<FloatArray>): void;
  19281. /**
  19282. * Gets the tangent data stored in this target
  19283. * @returns a FloatArray containing the tangent data (or null if not present)
  19284. */
  19285. getTangents(): Nullable<FloatArray>;
  19286. /**
  19287. * Serializes the current target into a Serialization object
  19288. * @returns the serialized object
  19289. */
  19290. serialize(): any;
  19291. /**
  19292. * Returns the string "MorphTarget"
  19293. * @returns "MorphTarget"
  19294. */
  19295. getClassName(): string;
  19296. /**
  19297. * Creates a new target from serialized data
  19298. * @param serializationObject defines the serialized data to use
  19299. * @returns a new MorphTarget
  19300. */
  19301. static Parse(serializationObject: any): MorphTarget;
  19302. /**
  19303. * Creates a MorphTarget from mesh data
  19304. * @param mesh defines the source mesh
  19305. * @param name defines the name to use for the new target
  19306. * @param influence defines the influence to attach to the target
  19307. * @returns a new MorphTarget
  19308. */
  19309. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19310. }
  19311. }
  19312. declare module "babylonjs/Morph/morphTargetManager" {
  19313. import { Nullable } from "babylonjs/types";
  19314. import { Scene } from "babylonjs/scene";
  19315. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19316. /**
  19317. * This class is used to deform meshes using morphing between different targets
  19318. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19319. */
  19320. export class MorphTargetManager {
  19321. private _targets;
  19322. private _targetInfluenceChangedObservers;
  19323. private _targetDataLayoutChangedObservers;
  19324. private _activeTargets;
  19325. private _scene;
  19326. private _influences;
  19327. private _supportsNormals;
  19328. private _supportsTangents;
  19329. private _vertexCount;
  19330. private _uniqueId;
  19331. private _tempInfluences;
  19332. /**
  19333. * Creates a new MorphTargetManager
  19334. * @param scene defines the current scene
  19335. */
  19336. constructor(scene?: Nullable<Scene>);
  19337. /**
  19338. * Gets the unique ID of this manager
  19339. */
  19340. readonly uniqueId: number;
  19341. /**
  19342. * Gets the number of vertices handled by this manager
  19343. */
  19344. readonly vertexCount: number;
  19345. /**
  19346. * Gets a boolean indicating if this manager supports morphing of normals
  19347. */
  19348. readonly supportsNormals: boolean;
  19349. /**
  19350. * Gets a boolean indicating if this manager supports morphing of tangents
  19351. */
  19352. readonly supportsTangents: boolean;
  19353. /**
  19354. * Gets the number of targets stored in this manager
  19355. */
  19356. readonly numTargets: number;
  19357. /**
  19358. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19359. */
  19360. readonly numInfluencers: number;
  19361. /**
  19362. * Gets the list of influences (one per target)
  19363. */
  19364. readonly influences: Float32Array;
  19365. /**
  19366. * Gets the active target at specified index. An active target is a target with an influence > 0
  19367. * @param index defines the index to check
  19368. * @returns the requested target
  19369. */
  19370. getActiveTarget(index: number): MorphTarget;
  19371. /**
  19372. * Gets the target at specified index
  19373. * @param index defines the index to check
  19374. * @returns the requested target
  19375. */
  19376. getTarget(index: number): MorphTarget;
  19377. /**
  19378. * Add a new target to this manager
  19379. * @param target defines the target to add
  19380. */
  19381. addTarget(target: MorphTarget): void;
  19382. /**
  19383. * Removes a target from the manager
  19384. * @param target defines the target to remove
  19385. */
  19386. removeTarget(target: MorphTarget): void;
  19387. /**
  19388. * Serializes the current manager into a Serialization object
  19389. * @returns the serialized object
  19390. */
  19391. serialize(): any;
  19392. private _syncActiveTargets;
  19393. /**
  19394. * Syncrhonize the targets with all the meshes using this morph target manager
  19395. */
  19396. synchronize(): void;
  19397. /**
  19398. * Creates a new MorphTargetManager from serialized data
  19399. * @param serializationObject defines the serialized data
  19400. * @param scene defines the hosting scene
  19401. * @returns the new MorphTargetManager
  19402. */
  19403. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19404. }
  19405. }
  19406. declare module "babylonjs/Meshes/groundMesh" {
  19407. import { Scene } from "babylonjs/scene";
  19408. import { Vector3 } from "babylonjs/Maths/math";
  19409. import { Mesh } from "babylonjs/Meshes/mesh";
  19410. /**
  19411. * Mesh representing the gorund
  19412. */
  19413. export class GroundMesh extends Mesh {
  19414. /** If octree should be generated */
  19415. generateOctree: boolean;
  19416. private _heightQuads;
  19417. /** @hidden */
  19418. _subdivisionsX: number;
  19419. /** @hidden */
  19420. _subdivisionsY: number;
  19421. /** @hidden */
  19422. _width: number;
  19423. /** @hidden */
  19424. _height: number;
  19425. /** @hidden */
  19426. _minX: number;
  19427. /** @hidden */
  19428. _maxX: number;
  19429. /** @hidden */
  19430. _minZ: number;
  19431. /** @hidden */
  19432. _maxZ: number;
  19433. constructor(name: string, scene: Scene);
  19434. /**
  19435. * "GroundMesh"
  19436. * @returns "GroundMesh"
  19437. */
  19438. getClassName(): string;
  19439. /**
  19440. * The minimum of x and y subdivisions
  19441. */
  19442. readonly subdivisions: number;
  19443. /**
  19444. * X subdivisions
  19445. */
  19446. readonly subdivisionsX: number;
  19447. /**
  19448. * Y subdivisions
  19449. */
  19450. readonly subdivisionsY: number;
  19451. /**
  19452. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19453. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19454. * @param chunksCount the number of subdivisions for x and y
  19455. * @param octreeBlocksSize (Default: 32)
  19456. */
  19457. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19458. /**
  19459. * Returns a height (y) value in the Worl system :
  19460. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19461. * @param x x coordinate
  19462. * @param z z coordinate
  19463. * @returns the ground y position if (x, z) are outside the ground surface.
  19464. */
  19465. getHeightAtCoordinates(x: number, z: number): number;
  19466. /**
  19467. * Returns a normalized vector (Vector3) orthogonal to the ground
  19468. * at the ground coordinates (x, z) expressed in the World system.
  19469. * @param x x coordinate
  19470. * @param z z coordinate
  19471. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19472. */
  19473. getNormalAtCoordinates(x: number, z: number): Vector3;
  19474. /**
  19475. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19476. * at the ground coordinates (x, z) expressed in the World system.
  19477. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19478. * @param x x coordinate
  19479. * @param z z coordinate
  19480. * @param ref vector to store the result
  19481. * @returns the GroundMesh.
  19482. */
  19483. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19484. /**
  19485. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19486. * if the ground has been updated.
  19487. * This can be used in the render loop.
  19488. * @returns the GroundMesh.
  19489. */
  19490. updateCoordinateHeights(): GroundMesh;
  19491. private _getFacetAt;
  19492. private _initHeightQuads;
  19493. private _computeHeightQuads;
  19494. /**
  19495. * Serializes this ground mesh
  19496. * @param serializationObject object to write serialization to
  19497. */
  19498. serialize(serializationObject: any): void;
  19499. /**
  19500. * Parses a serialized ground mesh
  19501. * @param parsedMesh the serialized mesh
  19502. * @param scene the scene to create the ground mesh in
  19503. * @returns the created ground mesh
  19504. */
  19505. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19506. }
  19507. }
  19508. declare module "babylonjs/Physics/physicsJoint" {
  19509. import { Vector3 } from "babylonjs/Maths/math";
  19510. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19511. /**
  19512. * Interface for Physics-Joint data
  19513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19514. */
  19515. export interface PhysicsJointData {
  19516. /**
  19517. * The main pivot of the joint
  19518. */
  19519. mainPivot?: Vector3;
  19520. /**
  19521. * The connected pivot of the joint
  19522. */
  19523. connectedPivot?: Vector3;
  19524. /**
  19525. * The main axis of the joint
  19526. */
  19527. mainAxis?: Vector3;
  19528. /**
  19529. * The connected axis of the joint
  19530. */
  19531. connectedAxis?: Vector3;
  19532. /**
  19533. * The collision of the joint
  19534. */
  19535. collision?: boolean;
  19536. /**
  19537. * Native Oimo/Cannon/Energy data
  19538. */
  19539. nativeParams?: any;
  19540. }
  19541. /**
  19542. * This is a holder class for the physics joint created by the physics plugin
  19543. * It holds a set of functions to control the underlying joint
  19544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19545. */
  19546. export class PhysicsJoint {
  19547. /**
  19548. * The type of the physics joint
  19549. */
  19550. type: number;
  19551. /**
  19552. * The data for the physics joint
  19553. */
  19554. jointData: PhysicsJointData;
  19555. private _physicsJoint;
  19556. protected _physicsPlugin: IPhysicsEnginePlugin;
  19557. /**
  19558. * Initializes the physics joint
  19559. * @param type The type of the physics joint
  19560. * @param jointData The data for the physics joint
  19561. */
  19562. constructor(
  19563. /**
  19564. * The type of the physics joint
  19565. */
  19566. type: number,
  19567. /**
  19568. * The data for the physics joint
  19569. */
  19570. jointData: PhysicsJointData);
  19571. /**
  19572. * Gets the physics joint
  19573. */
  19574. /**
  19575. * Sets the physics joint
  19576. */
  19577. physicsJoint: any;
  19578. /**
  19579. * Sets the physics plugin
  19580. */
  19581. physicsPlugin: IPhysicsEnginePlugin;
  19582. /**
  19583. * Execute a function that is physics-plugin specific.
  19584. * @param {Function} func the function that will be executed.
  19585. * It accepts two parameters: the physics world and the physics joint
  19586. */
  19587. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19588. /**
  19589. * Distance-Joint type
  19590. */
  19591. static DistanceJoint: number;
  19592. /**
  19593. * Hinge-Joint type
  19594. */
  19595. static HingeJoint: number;
  19596. /**
  19597. * Ball-and-Socket joint type
  19598. */
  19599. static BallAndSocketJoint: number;
  19600. /**
  19601. * Wheel-Joint type
  19602. */
  19603. static WheelJoint: number;
  19604. /**
  19605. * Slider-Joint type
  19606. */
  19607. static SliderJoint: number;
  19608. /**
  19609. * Prismatic-Joint type
  19610. */
  19611. static PrismaticJoint: number;
  19612. /**
  19613. * Universal-Joint type
  19614. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19615. */
  19616. static UniversalJoint: number;
  19617. /**
  19618. * Hinge-Joint 2 type
  19619. */
  19620. static Hinge2Joint: number;
  19621. /**
  19622. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19623. */
  19624. static PointToPointJoint: number;
  19625. /**
  19626. * Spring-Joint type
  19627. */
  19628. static SpringJoint: number;
  19629. /**
  19630. * Lock-Joint type
  19631. */
  19632. static LockJoint: number;
  19633. }
  19634. /**
  19635. * A class representing a physics distance joint
  19636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19637. */
  19638. export class DistanceJoint extends PhysicsJoint {
  19639. /**
  19640. *
  19641. * @param jointData The data for the Distance-Joint
  19642. */
  19643. constructor(jointData: DistanceJointData);
  19644. /**
  19645. * Update the predefined distance.
  19646. * @param maxDistance The maximum preferred distance
  19647. * @param minDistance The minimum preferred distance
  19648. */
  19649. updateDistance(maxDistance: number, minDistance?: number): void;
  19650. }
  19651. /**
  19652. * Represents a Motor-Enabled Joint
  19653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19654. */
  19655. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19656. /**
  19657. * Initializes the Motor-Enabled Joint
  19658. * @param type The type of the joint
  19659. * @param jointData The physica joint data for the joint
  19660. */
  19661. constructor(type: number, jointData: PhysicsJointData);
  19662. /**
  19663. * Set the motor values.
  19664. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19665. * @param force the force to apply
  19666. * @param maxForce max force for this motor.
  19667. */
  19668. setMotor(force?: number, maxForce?: number): void;
  19669. /**
  19670. * Set the motor's limits.
  19671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19672. * @param upperLimit The upper limit of the motor
  19673. * @param lowerLimit The lower limit of the motor
  19674. */
  19675. setLimit(upperLimit: number, lowerLimit?: number): void;
  19676. }
  19677. /**
  19678. * This class represents a single physics Hinge-Joint
  19679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19680. */
  19681. export class HingeJoint extends MotorEnabledJoint {
  19682. /**
  19683. * Initializes the Hinge-Joint
  19684. * @param jointData The joint data for the Hinge-Joint
  19685. */
  19686. constructor(jointData: PhysicsJointData);
  19687. /**
  19688. * Set the motor values.
  19689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19690. * @param {number} force the force to apply
  19691. * @param {number} maxForce max force for this motor.
  19692. */
  19693. setMotor(force?: number, maxForce?: number): void;
  19694. /**
  19695. * Set the motor's limits.
  19696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19697. * @param upperLimit The upper limit of the motor
  19698. * @param lowerLimit The lower limit of the motor
  19699. */
  19700. setLimit(upperLimit: number, lowerLimit?: number): void;
  19701. }
  19702. /**
  19703. * This class represents a dual hinge physics joint (same as wheel joint)
  19704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19705. */
  19706. export class Hinge2Joint extends MotorEnabledJoint {
  19707. /**
  19708. * Initializes the Hinge2-Joint
  19709. * @param jointData The joint data for the Hinge2-Joint
  19710. */
  19711. constructor(jointData: PhysicsJointData);
  19712. /**
  19713. * Set the motor values.
  19714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19715. * @param {number} targetSpeed the speed the motor is to reach
  19716. * @param {number} maxForce max force for this motor.
  19717. * @param {motorIndex} the motor's index, 0 or 1.
  19718. */
  19719. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19720. /**
  19721. * Set the motor limits.
  19722. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19723. * @param {number} upperLimit the upper limit
  19724. * @param {number} lowerLimit lower limit
  19725. * @param {motorIndex} the motor's index, 0 or 1.
  19726. */
  19727. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19728. }
  19729. /**
  19730. * Interface for a motor enabled joint
  19731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19732. */
  19733. export interface IMotorEnabledJoint {
  19734. /**
  19735. * Physics joint
  19736. */
  19737. physicsJoint: any;
  19738. /**
  19739. * Sets the motor of the motor-enabled joint
  19740. * @param force The force of the motor
  19741. * @param maxForce The maximum force of the motor
  19742. * @param motorIndex The index of the motor
  19743. */
  19744. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19745. /**
  19746. * Sets the limit of the motor
  19747. * @param upperLimit The upper limit of the motor
  19748. * @param lowerLimit The lower limit of the motor
  19749. * @param motorIndex The index of the motor
  19750. */
  19751. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19752. }
  19753. /**
  19754. * Joint data for a Distance-Joint
  19755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19756. */
  19757. export interface DistanceJointData extends PhysicsJointData {
  19758. /**
  19759. * Max distance the 2 joint objects can be apart
  19760. */
  19761. maxDistance: number;
  19762. }
  19763. /**
  19764. * Joint data from a spring joint
  19765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19766. */
  19767. export interface SpringJointData extends PhysicsJointData {
  19768. /**
  19769. * Length of the spring
  19770. */
  19771. length: number;
  19772. /**
  19773. * Stiffness of the spring
  19774. */
  19775. stiffness: number;
  19776. /**
  19777. * Damping of the spring
  19778. */
  19779. damping: number;
  19780. /** this callback will be called when applying the force to the impostors. */
  19781. forceApplicationCallback: () => void;
  19782. }
  19783. }
  19784. declare module "babylonjs/Physics/IPhysicsEngine" {
  19785. import { Nullable } from "babylonjs/types";
  19786. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19788. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19789. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19790. /**
  19791. * Interface used to describe a physics joint
  19792. */
  19793. export interface PhysicsImpostorJoint {
  19794. /** Defines the main impostor to which the joint is linked */
  19795. mainImpostor: PhysicsImpostor;
  19796. /** Defines the impostor that is connected to the main impostor using this joint */
  19797. connectedImpostor: PhysicsImpostor;
  19798. /** Defines the joint itself */
  19799. joint: PhysicsJoint;
  19800. }
  19801. /** @hidden */
  19802. export interface IPhysicsEnginePlugin {
  19803. world: any;
  19804. name: string;
  19805. setGravity(gravity: Vector3): void;
  19806. setTimeStep(timeStep: number): void;
  19807. getTimeStep(): number;
  19808. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19809. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19810. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19811. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19812. removePhysicsBody(impostor: PhysicsImpostor): void;
  19813. generateJoint(joint: PhysicsImpostorJoint): void;
  19814. removeJoint(joint: PhysicsImpostorJoint): void;
  19815. isSupported(): boolean;
  19816. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19817. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19818. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19819. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19820. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19821. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19822. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19823. getBodyMass(impostor: PhysicsImpostor): number;
  19824. getBodyFriction(impostor: PhysicsImpostor): number;
  19825. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19826. getBodyRestitution(impostor: PhysicsImpostor): number;
  19827. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19828. sleepBody(impostor: PhysicsImpostor): void;
  19829. wakeUpBody(impostor: PhysicsImpostor): void;
  19830. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19831. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19832. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19833. getRadius(impostor: PhysicsImpostor): number;
  19834. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19835. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19836. dispose(): void;
  19837. }
  19838. /**
  19839. * Interface used to define a physics engine
  19840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19841. */
  19842. export interface IPhysicsEngine {
  19843. /**
  19844. * Gets the gravity vector used by the simulation
  19845. */
  19846. gravity: Vector3;
  19847. /**
  19848. * Sets the gravity vector used by the simulation
  19849. * @param gravity defines the gravity vector to use
  19850. */
  19851. setGravity(gravity: Vector3): void;
  19852. /**
  19853. * Set the time step of the physics engine.
  19854. * Default is 1/60.
  19855. * To slow it down, enter 1/600 for example.
  19856. * To speed it up, 1/30
  19857. * @param newTimeStep the new timestep to apply to this world.
  19858. */
  19859. setTimeStep(newTimeStep: number): void;
  19860. /**
  19861. * Get the time step of the physics engine.
  19862. * @returns the current time step
  19863. */
  19864. getTimeStep(): number;
  19865. /**
  19866. * Release all resources
  19867. */
  19868. dispose(): void;
  19869. /**
  19870. * Gets the name of the current physics plugin
  19871. * @returns the name of the plugin
  19872. */
  19873. getPhysicsPluginName(): string;
  19874. /**
  19875. * Adding a new impostor for the impostor tracking.
  19876. * This will be done by the impostor itself.
  19877. * @param impostor the impostor to add
  19878. */
  19879. addImpostor(impostor: PhysicsImpostor): void;
  19880. /**
  19881. * Remove an impostor from the engine.
  19882. * This impostor and its mesh will not longer be updated by the physics engine.
  19883. * @param impostor the impostor to remove
  19884. */
  19885. removeImpostor(impostor: PhysicsImpostor): void;
  19886. /**
  19887. * Add a joint to the physics engine
  19888. * @param mainImpostor defines the main impostor to which the joint is added.
  19889. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19890. * @param joint defines the joint that will connect both impostors.
  19891. */
  19892. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19893. /**
  19894. * Removes a joint from the simulation
  19895. * @param mainImpostor defines the impostor used with the joint
  19896. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19897. * @param joint defines the joint to remove
  19898. */
  19899. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19900. /**
  19901. * Gets the current plugin used to run the simulation
  19902. * @returns current plugin
  19903. */
  19904. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19905. /**
  19906. * Gets the list of physic impostors
  19907. * @returns an array of PhysicsImpostor
  19908. */
  19909. getImpostors(): Array<PhysicsImpostor>;
  19910. /**
  19911. * Gets the impostor for a physics enabled object
  19912. * @param object defines the object impersonated by the impostor
  19913. * @returns the PhysicsImpostor or null if not found
  19914. */
  19915. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19916. /**
  19917. * Gets the impostor for a physics body object
  19918. * @param body defines physics body used by the impostor
  19919. * @returns the PhysicsImpostor or null if not found
  19920. */
  19921. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19922. /**
  19923. * Called by the scene. No need to call it.
  19924. * @param delta defines the timespam between frames
  19925. */
  19926. _step(delta: number): void;
  19927. }
  19928. }
  19929. declare module "babylonjs/Physics/physicsImpostor" {
  19930. import { Nullable, IndicesArray } from "babylonjs/types";
  19931. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19932. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19934. import { Scene } from "babylonjs/scene";
  19935. import { Bone } from "babylonjs/Bones/bone";
  19936. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19937. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19938. /**
  19939. * The interface for the physics imposter parameters
  19940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19941. */
  19942. export interface PhysicsImpostorParameters {
  19943. /**
  19944. * The mass of the physics imposter
  19945. */
  19946. mass: number;
  19947. /**
  19948. * The friction of the physics imposter
  19949. */
  19950. friction?: number;
  19951. /**
  19952. * The coefficient of restitution of the physics imposter
  19953. */
  19954. restitution?: number;
  19955. /**
  19956. * The native options of the physics imposter
  19957. */
  19958. nativeOptions?: any;
  19959. /**
  19960. * Specifies if the parent should be ignored
  19961. */
  19962. ignoreParent?: boolean;
  19963. /**
  19964. * Specifies if bi-directional transformations should be disabled
  19965. */
  19966. disableBidirectionalTransformation?: boolean;
  19967. }
  19968. /**
  19969. * Interface for a physics-enabled object
  19970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19971. */
  19972. export interface IPhysicsEnabledObject {
  19973. /**
  19974. * The position of the physics-enabled object
  19975. */
  19976. position: Vector3;
  19977. /**
  19978. * The rotation of the physics-enabled object
  19979. */
  19980. rotationQuaternion: Nullable<Quaternion>;
  19981. /**
  19982. * The scale of the physics-enabled object
  19983. */
  19984. scaling: Vector3;
  19985. /**
  19986. * The rotation of the physics-enabled object
  19987. */
  19988. rotation?: Vector3;
  19989. /**
  19990. * The parent of the physics-enabled object
  19991. */
  19992. parent?: any;
  19993. /**
  19994. * The bounding info of the physics-enabled object
  19995. * @returns The bounding info of the physics-enabled object
  19996. */
  19997. getBoundingInfo(): BoundingInfo;
  19998. /**
  19999. * Computes the world matrix
  20000. * @param force Specifies if the world matrix should be computed by force
  20001. * @returns A world matrix
  20002. */
  20003. computeWorldMatrix(force: boolean): Matrix;
  20004. /**
  20005. * Gets the world matrix
  20006. * @returns A world matrix
  20007. */
  20008. getWorldMatrix?(): Matrix;
  20009. /**
  20010. * Gets the child meshes
  20011. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20012. * @returns An array of abstract meshes
  20013. */
  20014. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20015. /**
  20016. * Gets the vertex data
  20017. * @param kind The type of vertex data
  20018. * @returns A nullable array of numbers, or a float32 array
  20019. */
  20020. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20021. /**
  20022. * Gets the indices from the mesh
  20023. * @returns A nullable array of index arrays
  20024. */
  20025. getIndices?(): Nullable<IndicesArray>;
  20026. /**
  20027. * Gets the scene from the mesh
  20028. * @returns the indices array or null
  20029. */
  20030. getScene?(): Scene;
  20031. /**
  20032. * Gets the absolute position from the mesh
  20033. * @returns the absolute position
  20034. */
  20035. getAbsolutePosition(): Vector3;
  20036. /**
  20037. * Gets the absolute pivot point from the mesh
  20038. * @returns the absolute pivot point
  20039. */
  20040. getAbsolutePivotPoint(): Vector3;
  20041. /**
  20042. * Rotates the mesh
  20043. * @param axis The axis of rotation
  20044. * @param amount The amount of rotation
  20045. * @param space The space of the rotation
  20046. * @returns The rotation transform node
  20047. */
  20048. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20049. /**
  20050. * Translates the mesh
  20051. * @param axis The axis of translation
  20052. * @param distance The distance of translation
  20053. * @param space The space of the translation
  20054. * @returns The transform node
  20055. */
  20056. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20057. /**
  20058. * Sets the absolute position of the mesh
  20059. * @param absolutePosition The absolute position of the mesh
  20060. * @returns The transform node
  20061. */
  20062. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20063. /**
  20064. * Gets the class name of the mesh
  20065. * @returns The class name
  20066. */
  20067. getClassName(): string;
  20068. }
  20069. /**
  20070. * Represents a physics imposter
  20071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20072. */
  20073. export class PhysicsImpostor {
  20074. /**
  20075. * The physics-enabled object used as the physics imposter
  20076. */
  20077. object: IPhysicsEnabledObject;
  20078. /**
  20079. * The type of the physics imposter
  20080. */
  20081. type: number;
  20082. private _options;
  20083. private _scene?;
  20084. /**
  20085. * The default object size of the imposter
  20086. */
  20087. static DEFAULT_OBJECT_SIZE: Vector3;
  20088. /**
  20089. * The identity quaternion of the imposter
  20090. */
  20091. static IDENTITY_QUATERNION: Quaternion;
  20092. /** @hidden */
  20093. _pluginData: any;
  20094. private _physicsEngine;
  20095. private _physicsBody;
  20096. private _bodyUpdateRequired;
  20097. private _onBeforePhysicsStepCallbacks;
  20098. private _onAfterPhysicsStepCallbacks;
  20099. /** @hidden */
  20100. _onPhysicsCollideCallbacks: Array<{
  20101. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20102. otherImpostors: Array<PhysicsImpostor>;
  20103. }>;
  20104. private _deltaPosition;
  20105. private _deltaRotation;
  20106. private _deltaRotationConjugated;
  20107. private _parent;
  20108. private _isDisposed;
  20109. private static _tmpVecs;
  20110. private static _tmpQuat;
  20111. /**
  20112. * Specifies if the physics imposter is disposed
  20113. */
  20114. readonly isDisposed: boolean;
  20115. /**
  20116. * Gets the mass of the physics imposter
  20117. */
  20118. mass: number;
  20119. /**
  20120. * Gets the coefficient of friction
  20121. */
  20122. /**
  20123. * Sets the coefficient of friction
  20124. */
  20125. friction: number;
  20126. /**
  20127. * Gets the coefficient of restitution
  20128. */
  20129. /**
  20130. * Sets the coefficient of restitution
  20131. */
  20132. restitution: number;
  20133. /**
  20134. * The unique id of the physics imposter
  20135. * set by the physics engine when adding this impostor to the array
  20136. */
  20137. uniqueId: number;
  20138. private _joints;
  20139. /**
  20140. * Initializes the physics imposter
  20141. * @param object The physics-enabled object used as the physics imposter
  20142. * @param type The type of the physics imposter
  20143. * @param _options The options for the physics imposter
  20144. * @param _scene The Babylon scene
  20145. */
  20146. constructor(
  20147. /**
  20148. * The physics-enabled object used as the physics imposter
  20149. */
  20150. object: IPhysicsEnabledObject,
  20151. /**
  20152. * The type of the physics imposter
  20153. */
  20154. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20155. /**
  20156. * This function will completly initialize this impostor.
  20157. * It will create a new body - but only if this mesh has no parent.
  20158. * If it has, this impostor will not be used other than to define the impostor
  20159. * of the child mesh.
  20160. * @hidden
  20161. */
  20162. _init(): void;
  20163. private _getPhysicsParent;
  20164. /**
  20165. * Should a new body be generated.
  20166. * @returns boolean specifying if body initialization is required
  20167. */
  20168. isBodyInitRequired(): boolean;
  20169. /**
  20170. * Sets the updated scaling
  20171. * @param updated Specifies if the scaling is updated
  20172. */
  20173. setScalingUpdated(): void;
  20174. /**
  20175. * Force a regeneration of this or the parent's impostor's body.
  20176. * Use under cautious - This will remove all joints already implemented.
  20177. */
  20178. forceUpdate(): void;
  20179. /**
  20180. * Gets the body that holds this impostor. Either its own, or its parent.
  20181. */
  20182. /**
  20183. * Set the physics body. Used mainly by the physics engine/plugin
  20184. */
  20185. physicsBody: any;
  20186. /**
  20187. * Get the parent of the physics imposter
  20188. * @returns Physics imposter or null
  20189. */
  20190. /**
  20191. * Sets the parent of the physics imposter
  20192. */
  20193. parent: Nullable<PhysicsImpostor>;
  20194. /**
  20195. * Resets the update flags
  20196. */
  20197. resetUpdateFlags(): void;
  20198. /**
  20199. * Gets the object extend size
  20200. * @returns the object extend size
  20201. */
  20202. getObjectExtendSize(): Vector3;
  20203. /**
  20204. * Gets the object center
  20205. * @returns The object center
  20206. */
  20207. getObjectCenter(): Vector3;
  20208. /**
  20209. * Get a specific parametes from the options parameter
  20210. * @param paramName The object parameter name
  20211. * @returns The object parameter
  20212. */
  20213. getParam(paramName: string): any;
  20214. /**
  20215. * Sets a specific parameter in the options given to the physics plugin
  20216. * @param paramName The parameter name
  20217. * @param value The value of the parameter
  20218. */
  20219. setParam(paramName: string, value: number): void;
  20220. /**
  20221. * Specifically change the body's mass option. Won't recreate the physics body object
  20222. * @param mass The mass of the physics imposter
  20223. */
  20224. setMass(mass: number): void;
  20225. /**
  20226. * Gets the linear velocity
  20227. * @returns linear velocity or null
  20228. */
  20229. getLinearVelocity(): Nullable<Vector3>;
  20230. /**
  20231. * Sets the linear velocity
  20232. * @param velocity linear velocity or null
  20233. */
  20234. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20235. /**
  20236. * Gets the angular velocity
  20237. * @returns angular velocity or null
  20238. */
  20239. getAngularVelocity(): Nullable<Vector3>;
  20240. /**
  20241. * Sets the angular velocity
  20242. * @param velocity The velocity or null
  20243. */
  20244. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20245. /**
  20246. * Execute a function with the physics plugin native code
  20247. * Provide a function the will have two variables - the world object and the physics body object
  20248. * @param func The function to execute with the physics plugin native code
  20249. */
  20250. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20251. /**
  20252. * Register a function that will be executed before the physics world is stepping forward
  20253. * @param func The function to execute before the physics world is stepped forward
  20254. */
  20255. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20256. /**
  20257. * Unregister a function that will be executed before the physics world is stepping forward
  20258. * @param func The function to execute before the physics world is stepped forward
  20259. */
  20260. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20261. /**
  20262. * Register a function that will be executed after the physics step
  20263. * @param func The function to execute after physics step
  20264. */
  20265. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20266. /**
  20267. * Unregisters a function that will be executed after the physics step
  20268. * @param func The function to execute after physics step
  20269. */
  20270. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20271. /**
  20272. * register a function that will be executed when this impostor collides against a different body
  20273. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20274. * @param func Callback that is executed on collision
  20275. */
  20276. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20277. /**
  20278. * Unregisters the physics imposter on contact
  20279. * @param collideAgainst The physics object to collide against
  20280. * @param func Callback to execute on collision
  20281. */
  20282. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20283. private _tmpQuat;
  20284. private _tmpQuat2;
  20285. /**
  20286. * Get the parent rotation
  20287. * @returns The parent rotation
  20288. */
  20289. getParentsRotation(): Quaternion;
  20290. /**
  20291. * this function is executed by the physics engine.
  20292. */
  20293. beforeStep: () => void;
  20294. /**
  20295. * this function is executed by the physics engine
  20296. */
  20297. afterStep: () => void;
  20298. /**
  20299. * Legacy collision detection event support
  20300. */
  20301. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20302. /**
  20303. * event and body object due to cannon's event-based architecture.
  20304. */
  20305. onCollide: (e: {
  20306. body: any;
  20307. }) => void;
  20308. /**
  20309. * Apply a force
  20310. * @param force The force to apply
  20311. * @param contactPoint The contact point for the force
  20312. * @returns The physics imposter
  20313. */
  20314. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20315. /**
  20316. * Apply an impulse
  20317. * @param force The impulse force
  20318. * @param contactPoint The contact point for the impulse force
  20319. * @returns The physics imposter
  20320. */
  20321. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20322. /**
  20323. * A help function to create a joint
  20324. * @param otherImpostor A physics imposter used to create a joint
  20325. * @param jointType The type of joint
  20326. * @param jointData The data for the joint
  20327. * @returns The physics imposter
  20328. */
  20329. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20330. /**
  20331. * Add a joint to this impostor with a different impostor
  20332. * @param otherImpostor A physics imposter used to add a joint
  20333. * @param joint The joint to add
  20334. * @returns The physics imposter
  20335. */
  20336. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20337. /**
  20338. * Will keep this body still, in a sleep mode.
  20339. * @returns the physics imposter
  20340. */
  20341. sleep(): PhysicsImpostor;
  20342. /**
  20343. * Wake the body up.
  20344. * @returns The physics imposter
  20345. */
  20346. wakeUp(): PhysicsImpostor;
  20347. /**
  20348. * Clones the physics imposter
  20349. * @param newObject The physics imposter clones to this physics-enabled object
  20350. * @returns A nullable physics imposter
  20351. */
  20352. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20353. /**
  20354. * Disposes the physics imposter
  20355. */
  20356. dispose(): void;
  20357. /**
  20358. * Sets the delta position
  20359. * @param position The delta position amount
  20360. */
  20361. setDeltaPosition(position: Vector3): void;
  20362. /**
  20363. * Sets the delta rotation
  20364. * @param rotation The delta rotation amount
  20365. */
  20366. setDeltaRotation(rotation: Quaternion): void;
  20367. /**
  20368. * Gets the box size of the physics imposter and stores the result in the input parameter
  20369. * @param result Stores the box size
  20370. * @returns The physics imposter
  20371. */
  20372. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20373. /**
  20374. * Gets the radius of the physics imposter
  20375. * @returns Radius of the physics imposter
  20376. */
  20377. getRadius(): number;
  20378. /**
  20379. * Sync a bone with this impostor
  20380. * @param bone The bone to sync to the impostor.
  20381. * @param boneMesh The mesh that the bone is influencing.
  20382. * @param jointPivot The pivot of the joint / bone in local space.
  20383. * @param distToJoint Optional distance from the impostor to the joint.
  20384. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20385. */
  20386. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20387. /**
  20388. * Sync impostor to a bone
  20389. * @param bone The bone that the impostor will be synced to.
  20390. * @param boneMesh The mesh that the bone is influencing.
  20391. * @param jointPivot The pivot of the joint / bone in local space.
  20392. * @param distToJoint Optional distance from the impostor to the joint.
  20393. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20394. * @param boneAxis Optional vector3 axis the bone is aligned with
  20395. */
  20396. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20397. /**
  20398. * No-Imposter type
  20399. */
  20400. static NoImpostor: number;
  20401. /**
  20402. * Sphere-Imposter type
  20403. */
  20404. static SphereImpostor: number;
  20405. /**
  20406. * Box-Imposter type
  20407. */
  20408. static BoxImpostor: number;
  20409. /**
  20410. * Plane-Imposter type
  20411. */
  20412. static PlaneImpostor: number;
  20413. /**
  20414. * Mesh-imposter type
  20415. */
  20416. static MeshImpostor: number;
  20417. /**
  20418. * Cylinder-Imposter type
  20419. */
  20420. static CylinderImpostor: number;
  20421. /**
  20422. * Particle-Imposter type
  20423. */
  20424. static ParticleImpostor: number;
  20425. /**
  20426. * Heightmap-Imposter type
  20427. */
  20428. static HeightmapImpostor: number;
  20429. }
  20430. }
  20431. declare module "babylonjs/Meshes/mesh" {
  20432. import { Observable } from "babylonjs/Misc/observable";
  20433. import { IAnimatable } from "babylonjs/Misc/tools";
  20434. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20435. import { Camera } from "babylonjs/Cameras/camera";
  20436. import { Scene } from "babylonjs/scene";
  20437. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20438. import { Engine } from "babylonjs/Engines/engine";
  20439. import { Node } from "babylonjs/node";
  20440. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20441. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20442. import { Buffer } from "babylonjs/Meshes/buffer";
  20443. import { Geometry } from "babylonjs/Meshes/geometry";
  20444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20446. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20447. import { Effect } from "babylonjs/Materials/effect";
  20448. import { Material } from "babylonjs/Materials/material";
  20449. import { Skeleton } from "babylonjs/Bones/skeleton";
  20450. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20451. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20452. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20453. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20454. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20455. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20456. /**
  20457. * Class used to represent a specific level of detail of a mesh
  20458. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20459. */
  20460. export class MeshLODLevel {
  20461. /** Defines the distance where this level should star being displayed */
  20462. distance: number;
  20463. /** Defines the mesh to use to render this level */
  20464. mesh: Nullable<Mesh>;
  20465. /**
  20466. * Creates a new LOD level
  20467. * @param distance defines the distance where this level should star being displayed
  20468. * @param mesh defines the mesh to use to render this level
  20469. */
  20470. constructor(
  20471. /** Defines the distance where this level should star being displayed */
  20472. distance: number,
  20473. /** Defines the mesh to use to render this level */
  20474. mesh: Nullable<Mesh>);
  20475. }
  20476. /**
  20477. * @hidden
  20478. **/
  20479. export class _CreationDataStorage {
  20480. closePath?: boolean;
  20481. closeArray?: boolean;
  20482. idx: number[];
  20483. dashSize: number;
  20484. gapSize: number;
  20485. path3D: Path3D;
  20486. pathArray: Vector3[][];
  20487. arc: number;
  20488. radius: number;
  20489. cap: number;
  20490. tessellation: number;
  20491. }
  20492. /**
  20493. * @hidden
  20494. **/
  20495. class _InstanceDataStorage {
  20496. visibleInstances: any;
  20497. renderIdForInstances: number[];
  20498. batchCache: _InstancesBatch;
  20499. instancesBufferSize: number;
  20500. instancesBuffer: Nullable<Buffer>;
  20501. instancesData: Float32Array;
  20502. overridenInstanceCount: number;
  20503. }
  20504. /**
  20505. * @hidden
  20506. **/
  20507. export class _InstancesBatch {
  20508. mustReturn: boolean;
  20509. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20510. renderSelf: boolean[];
  20511. }
  20512. /**
  20513. * Class used to represent renderable models
  20514. */
  20515. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20516. /**
  20517. * Mesh side orientation : usually the external or front surface
  20518. */
  20519. static readonly FRONTSIDE: number;
  20520. /**
  20521. * Mesh side orientation : usually the internal or back surface
  20522. */
  20523. static readonly BACKSIDE: number;
  20524. /**
  20525. * Mesh side orientation : both internal and external or front and back surfaces
  20526. */
  20527. static readonly DOUBLESIDE: number;
  20528. /**
  20529. * Mesh side orientation : by default, `FRONTSIDE`
  20530. */
  20531. static readonly DEFAULTSIDE: number;
  20532. /**
  20533. * Mesh cap setting : no cap
  20534. */
  20535. static readonly NO_CAP: number;
  20536. /**
  20537. * Mesh cap setting : one cap at the beginning of the mesh
  20538. */
  20539. static readonly CAP_START: number;
  20540. /**
  20541. * Mesh cap setting : one cap at the end of the mesh
  20542. */
  20543. static readonly CAP_END: number;
  20544. /**
  20545. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20546. */
  20547. static readonly CAP_ALL: number;
  20548. /**
  20549. * Gets the default side orientation.
  20550. * @param orientation the orientation to value to attempt to get
  20551. * @returns the default orientation
  20552. * @hidden
  20553. */
  20554. static _GetDefaultSideOrientation(orientation?: number): number;
  20555. private _onBeforeRenderObservable;
  20556. private _onBeforeBindObservable;
  20557. private _onAfterRenderObservable;
  20558. private _onBeforeDrawObservable;
  20559. /**
  20560. * An event triggered before rendering the mesh
  20561. */
  20562. readonly onBeforeRenderObservable: Observable<Mesh>;
  20563. /**
  20564. * An event triggered before binding the mesh
  20565. */
  20566. readonly onBeforeBindObservable: Observable<Mesh>;
  20567. /**
  20568. * An event triggered after rendering the mesh
  20569. */
  20570. readonly onAfterRenderObservable: Observable<Mesh>;
  20571. /**
  20572. * An event triggered before drawing the mesh
  20573. */
  20574. readonly onBeforeDrawObservable: Observable<Mesh>;
  20575. private _onBeforeDrawObserver;
  20576. /**
  20577. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20578. */
  20579. onBeforeDraw: () => void;
  20580. /**
  20581. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20582. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20583. */
  20584. delayLoadState: number;
  20585. /**
  20586. * Gets the list of instances created from this mesh
  20587. * it is not supposed to be modified manually.
  20588. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20590. */
  20591. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20592. /**
  20593. * Gets the file containing delay loading data for this mesh
  20594. */
  20595. delayLoadingFile: string;
  20596. /** @hidden */
  20597. _binaryInfo: any;
  20598. private _LODLevels;
  20599. /**
  20600. * User defined function used to change how LOD level selection is done
  20601. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20602. */
  20603. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20604. private _morphTargetManager;
  20605. /**
  20606. * Gets or sets the morph target manager
  20607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20608. */
  20609. morphTargetManager: Nullable<MorphTargetManager>;
  20610. /** @hidden */
  20611. _creationDataStorage: Nullable<_CreationDataStorage>;
  20612. /** @hidden */
  20613. _geometry: Nullable<Geometry>;
  20614. /** @hidden */
  20615. _delayInfo: Array<string>;
  20616. /** @hidden */
  20617. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20618. /** @hidden */
  20619. _instanceDataStorage: _InstanceDataStorage;
  20620. private _effectiveMaterial;
  20621. /** @hidden */
  20622. _shouldGenerateFlatShading: boolean;
  20623. private _preActivateId;
  20624. /** @hidden */
  20625. _originalBuilderSideOrientation: number;
  20626. /**
  20627. * Use this property to change the original side orientation defined at construction time
  20628. */
  20629. overrideMaterialSideOrientation: Nullable<number>;
  20630. private _areNormalsFrozen;
  20631. private _sourcePositions;
  20632. private _sourceNormals;
  20633. private _source;
  20634. private meshMap;
  20635. /**
  20636. * Gets the source mesh (the one used to clone this one from)
  20637. */
  20638. readonly source: Nullable<Mesh>;
  20639. /**
  20640. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20641. */
  20642. isUnIndexed: boolean;
  20643. /**
  20644. * @constructor
  20645. * @param name The value used by scene.getMeshByName() to do a lookup.
  20646. * @param scene The scene to add this mesh to.
  20647. * @param parent The parent of this mesh, if it has one
  20648. * @param source An optional Mesh from which geometry is shared, cloned.
  20649. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20650. * When false, achieved by calling a clone(), also passing False.
  20651. * This will make creation of children, recursive.
  20652. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20653. */
  20654. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20655. /**
  20656. * Gets the class name
  20657. * @returns the string "Mesh".
  20658. */
  20659. getClassName(): string;
  20660. /** @hidden */
  20661. readonly _isMesh: boolean;
  20662. /**
  20663. * Returns a description of this mesh
  20664. * @param fullDetails define if full details about this mesh must be used
  20665. * @returns a descriptive string representing this mesh
  20666. */
  20667. toString(fullDetails?: boolean): string;
  20668. /** @hidden */
  20669. _unBindEffect(): void;
  20670. /**
  20671. * Gets a boolean indicating if this mesh has LOD
  20672. */
  20673. readonly hasLODLevels: boolean;
  20674. /**
  20675. * Gets the list of MeshLODLevel associated with the current mesh
  20676. * @returns an array of MeshLODLevel
  20677. */
  20678. getLODLevels(): MeshLODLevel[];
  20679. private _sortLODLevels;
  20680. /**
  20681. * Add a mesh as LOD level triggered at the given distance.
  20682. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20683. * @param distance The distance from the center of the object to show this level
  20684. * @param mesh The mesh to be added as LOD level (can be null)
  20685. * @return This mesh (for chaining)
  20686. */
  20687. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20688. /**
  20689. * Returns the LOD level mesh at the passed distance or null if not found.
  20690. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20691. * @param distance The distance from the center of the object to show this level
  20692. * @returns a Mesh or `null`
  20693. */
  20694. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20695. /**
  20696. * Remove a mesh from the LOD array
  20697. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20698. * @param mesh defines the mesh to be removed
  20699. * @return This mesh (for chaining)
  20700. */
  20701. removeLODLevel(mesh: Mesh): Mesh;
  20702. /**
  20703. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20705. * @param camera defines the camera to use to compute distance
  20706. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20707. * @return This mesh (for chaining)
  20708. */
  20709. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20710. /**
  20711. * Gets the mesh internal Geometry object
  20712. */
  20713. readonly geometry: Nullable<Geometry>;
  20714. /**
  20715. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20716. * @returns the total number of vertices
  20717. */
  20718. getTotalVertices(): number;
  20719. /**
  20720. * Returns the content of an associated vertex buffer
  20721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20722. * - VertexBuffer.PositionKind
  20723. * - VertexBuffer.UVKind
  20724. * - VertexBuffer.UV2Kind
  20725. * - VertexBuffer.UV3Kind
  20726. * - VertexBuffer.UV4Kind
  20727. * - VertexBuffer.UV5Kind
  20728. * - VertexBuffer.UV6Kind
  20729. * - VertexBuffer.ColorKind
  20730. * - VertexBuffer.MatricesIndicesKind
  20731. * - VertexBuffer.MatricesIndicesExtraKind
  20732. * - VertexBuffer.MatricesWeightsKind
  20733. * - VertexBuffer.MatricesWeightsExtraKind
  20734. * @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
  20735. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20736. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20737. */
  20738. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20739. /**
  20740. * Returns the mesh VertexBuffer object from the requested `kind`
  20741. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20742. * - VertexBuffer.PositionKind
  20743. * - VertexBuffer.UVKind
  20744. * - VertexBuffer.UV2Kind
  20745. * - VertexBuffer.UV3Kind
  20746. * - VertexBuffer.UV4Kind
  20747. * - VertexBuffer.UV5Kind
  20748. * - VertexBuffer.UV6Kind
  20749. * - VertexBuffer.ColorKind
  20750. * - VertexBuffer.MatricesIndicesKind
  20751. * - VertexBuffer.MatricesIndicesExtraKind
  20752. * - VertexBuffer.MatricesWeightsKind
  20753. * - VertexBuffer.MatricesWeightsExtraKind
  20754. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20755. */
  20756. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20757. /**
  20758. * Tests if a specific vertex buffer is associated with this mesh
  20759. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20760. * - VertexBuffer.PositionKind
  20761. * - VertexBuffer.UVKind
  20762. * - VertexBuffer.UV2Kind
  20763. * - VertexBuffer.UV3Kind
  20764. * - VertexBuffer.UV4Kind
  20765. * - VertexBuffer.UV5Kind
  20766. * - VertexBuffer.UV6Kind
  20767. * - VertexBuffer.ColorKind
  20768. * - VertexBuffer.MatricesIndicesKind
  20769. * - VertexBuffer.MatricesIndicesExtraKind
  20770. * - VertexBuffer.MatricesWeightsKind
  20771. * - VertexBuffer.MatricesWeightsExtraKind
  20772. * @returns a boolean
  20773. */
  20774. isVerticesDataPresent(kind: string): boolean;
  20775. /**
  20776. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20777. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20778. * - VertexBuffer.PositionKind
  20779. * - VertexBuffer.UVKind
  20780. * - VertexBuffer.UV2Kind
  20781. * - VertexBuffer.UV3Kind
  20782. * - VertexBuffer.UV4Kind
  20783. * - VertexBuffer.UV5Kind
  20784. * - VertexBuffer.UV6Kind
  20785. * - VertexBuffer.ColorKind
  20786. * - VertexBuffer.MatricesIndicesKind
  20787. * - VertexBuffer.MatricesIndicesExtraKind
  20788. * - VertexBuffer.MatricesWeightsKind
  20789. * - VertexBuffer.MatricesWeightsExtraKind
  20790. * @returns a boolean
  20791. */
  20792. isVertexBufferUpdatable(kind: string): boolean;
  20793. /**
  20794. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20795. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20796. * - VertexBuffer.PositionKind
  20797. * - VertexBuffer.UVKind
  20798. * - VertexBuffer.UV2Kind
  20799. * - VertexBuffer.UV3Kind
  20800. * - VertexBuffer.UV4Kind
  20801. * - VertexBuffer.UV5Kind
  20802. * - VertexBuffer.UV6Kind
  20803. * - VertexBuffer.ColorKind
  20804. * - VertexBuffer.MatricesIndicesKind
  20805. * - VertexBuffer.MatricesIndicesExtraKind
  20806. * - VertexBuffer.MatricesWeightsKind
  20807. * - VertexBuffer.MatricesWeightsExtraKind
  20808. * @returns an array of strings
  20809. */
  20810. getVerticesDataKinds(): string[];
  20811. /**
  20812. * Returns a positive integer : the total number of indices in this mesh geometry.
  20813. * @returns the numner of indices or zero if the mesh has no geometry.
  20814. */
  20815. getTotalIndices(): number;
  20816. /**
  20817. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20818. * @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.
  20819. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20820. * @returns the indices array or an empty array if the mesh has no geometry
  20821. */
  20822. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20823. readonly isBlocked: boolean;
  20824. /**
  20825. * Determine if the current mesh is ready to be rendered
  20826. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20827. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20828. * @returns true if all associated assets are ready (material, textures, shaders)
  20829. */
  20830. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20831. /**
  20832. * 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.
  20833. */
  20834. readonly areNormalsFrozen: boolean;
  20835. /**
  20836. * 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.
  20837. * @returns the current mesh
  20838. */
  20839. freezeNormals(): Mesh;
  20840. /**
  20841. * 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
  20842. * @returns the current mesh
  20843. */
  20844. unfreezeNormals(): Mesh;
  20845. /**
  20846. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20847. */
  20848. overridenInstanceCount: number;
  20849. /** @hidden */
  20850. _preActivate(): Mesh;
  20851. /** @hidden */
  20852. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20853. /** @hidden */
  20854. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20855. /**
  20856. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20857. * This means the mesh underlying bounding box and sphere are recomputed.
  20858. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20859. * @returns the current mesh
  20860. */
  20861. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20862. /** @hidden */
  20863. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20864. /**
  20865. * This function will subdivide the mesh into multiple submeshes
  20866. * @param count defines the expected number of submeshes
  20867. */
  20868. subdivide(count: number): void;
  20869. /**
  20870. * Copy a FloatArray into a specific associated vertex buffer
  20871. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20872. * - VertexBuffer.PositionKind
  20873. * - VertexBuffer.UVKind
  20874. * - VertexBuffer.UV2Kind
  20875. * - VertexBuffer.UV3Kind
  20876. * - VertexBuffer.UV4Kind
  20877. * - VertexBuffer.UV5Kind
  20878. * - VertexBuffer.UV6Kind
  20879. * - VertexBuffer.ColorKind
  20880. * - VertexBuffer.MatricesIndicesKind
  20881. * - VertexBuffer.MatricesIndicesExtraKind
  20882. * - VertexBuffer.MatricesWeightsKind
  20883. * - VertexBuffer.MatricesWeightsExtraKind
  20884. * @param data defines the data source
  20885. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20886. * @param stride defines the data stride size (can be null)
  20887. * @returns the current mesh
  20888. */
  20889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20890. /**
  20891. * Flags an associated vertex buffer as updatable
  20892. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20893. * - VertexBuffer.PositionKind
  20894. * - VertexBuffer.UVKind
  20895. * - VertexBuffer.UV2Kind
  20896. * - VertexBuffer.UV3Kind
  20897. * - VertexBuffer.UV4Kind
  20898. * - VertexBuffer.UV5Kind
  20899. * - VertexBuffer.UV6Kind
  20900. * - VertexBuffer.ColorKind
  20901. * - VertexBuffer.MatricesIndicesKind
  20902. * - VertexBuffer.MatricesIndicesExtraKind
  20903. * - VertexBuffer.MatricesWeightsKind
  20904. * - VertexBuffer.MatricesWeightsExtraKind
  20905. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20906. */
  20907. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20908. /**
  20909. * Sets the mesh global Vertex Buffer
  20910. * @param buffer defines the buffer to use
  20911. * @returns the current mesh
  20912. */
  20913. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20914. /**
  20915. * Update a specific associated vertex buffer
  20916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20917. * - VertexBuffer.PositionKind
  20918. * - VertexBuffer.UVKind
  20919. * - VertexBuffer.UV2Kind
  20920. * - VertexBuffer.UV3Kind
  20921. * - VertexBuffer.UV4Kind
  20922. * - VertexBuffer.UV5Kind
  20923. * - VertexBuffer.UV6Kind
  20924. * - VertexBuffer.ColorKind
  20925. * - VertexBuffer.MatricesIndicesKind
  20926. * - VertexBuffer.MatricesIndicesExtraKind
  20927. * - VertexBuffer.MatricesWeightsKind
  20928. * - VertexBuffer.MatricesWeightsExtraKind
  20929. * @param data defines the data source
  20930. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20931. * @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)
  20932. * @returns the current mesh
  20933. */
  20934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20935. /**
  20936. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20937. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20938. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20939. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20940. * @returns the current mesh
  20941. */
  20942. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20943. /**
  20944. * Creates a un-shared specific occurence of the geometry for the mesh.
  20945. * @returns the current mesh
  20946. */
  20947. makeGeometryUnique(): Mesh;
  20948. /**
  20949. * Set the index buffer of this mesh
  20950. * @param indices defines the source data
  20951. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20952. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20953. * @returns the current mesh
  20954. */
  20955. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20956. /**
  20957. * Update the current index buffer
  20958. * @param indices defines the source data
  20959. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20960. * @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)
  20961. * @returns the current mesh
  20962. */
  20963. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20964. /**
  20965. * Invert the geometry to move from a right handed system to a left handed one.
  20966. * @returns the current mesh
  20967. */
  20968. toLeftHanded(): Mesh;
  20969. /** @hidden */
  20970. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20971. /** @hidden */
  20972. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20973. /**
  20974. * Registers for this mesh a javascript function called just before the rendering process
  20975. * @param func defines the function to call before rendering this mesh
  20976. * @returns the current mesh
  20977. */
  20978. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20979. /**
  20980. * Disposes a previously registered javascript function called before the rendering
  20981. * @param func defines the function to remove
  20982. * @returns the current mesh
  20983. */
  20984. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20985. /**
  20986. * Registers for this mesh a javascript function called just after the rendering is complete
  20987. * @param func defines the function to call after rendering this mesh
  20988. * @returns the current mesh
  20989. */
  20990. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20991. /**
  20992. * Disposes a previously registered javascript function called after the rendering.
  20993. * @param func defines the function to remove
  20994. * @returns the current mesh
  20995. */
  20996. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20997. /** @hidden */
  20998. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20999. /** @hidden */
  21000. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21001. /** @hidden */
  21002. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21003. /**
  21004. * 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
  21005. * @param subMesh defines the subMesh to render
  21006. * @param enableAlphaMode defines if alpha mode can be changed
  21007. * @returns the current mesh
  21008. */
  21009. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21010. private _onBeforeDraw;
  21011. /**
  21012. * Renormalize the mesh and patch it up if there are no weights
  21013. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21014. * However in the case of zero weights then we set just a single influence to 1.
  21015. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21016. */
  21017. cleanMatrixWeights(): void;
  21018. private normalizeSkinFourWeights;
  21019. private normalizeSkinWeightsAndExtra;
  21020. /**
  21021. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21022. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21023. * the user know there was an issue with importing the mesh
  21024. * @returns a validation object with skinned, valid and report string
  21025. */
  21026. validateSkinning(): {
  21027. skinned: boolean;
  21028. valid: boolean;
  21029. report: string;
  21030. };
  21031. /** @hidden */
  21032. _checkDelayState(): Mesh;
  21033. private _queueLoad;
  21034. /**
  21035. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21036. * A mesh is in the frustum if its bounding box intersects the frustum
  21037. * @param frustumPlanes defines the frustum to test
  21038. * @returns true if the mesh is in the frustum planes
  21039. */
  21040. isInFrustum(frustumPlanes: Plane[]): boolean;
  21041. /**
  21042. * Sets the mesh material by the material or multiMaterial `id` property
  21043. * @param id is a string identifying the material or the multiMaterial
  21044. * @returns the current mesh
  21045. */
  21046. setMaterialByID(id: string): Mesh;
  21047. /**
  21048. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21049. * @returns an array of IAnimatable
  21050. */
  21051. getAnimatables(): IAnimatable[];
  21052. /**
  21053. * Modifies the mesh geometry according to the passed transformation matrix.
  21054. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21055. * The mesh normals are modified using the same transformation.
  21056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21057. * @param transform defines the transform matrix to use
  21058. * @see http://doc.babylonjs.com/resources/baking_transformations
  21059. * @returns the current mesh
  21060. */
  21061. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21062. /**
  21063. * Modifies the mesh geometry according to its own current World Matrix.
  21064. * The mesh World Matrix is then reset.
  21065. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21066. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21067. * @see http://doc.babylonjs.com/resources/baking_transformations
  21068. * @returns the current mesh
  21069. */
  21070. bakeCurrentTransformIntoVertices(): Mesh;
  21071. /** @hidden */
  21072. readonly _positions: Nullable<Vector3[]>;
  21073. /** @hidden */
  21074. _resetPointsArrayCache(): Mesh;
  21075. /** @hidden */
  21076. _generatePointsArray(): boolean;
  21077. /**
  21078. * Returns a new Mesh object generated from the current mesh properties.
  21079. * This method must not get confused with createInstance()
  21080. * @param name is a string, the name given to the new mesh
  21081. * @param newParent can be any Node object (default `null`)
  21082. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21083. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21084. * @returns a new mesh
  21085. */
  21086. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21087. /**
  21088. * Releases resources associated with this mesh.
  21089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21091. */
  21092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21093. /**
  21094. * Modifies the mesh geometry according to a displacement map.
  21095. * 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.
  21096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21097. * @param url is a string, the URL from the image file is to be downloaded.
  21098. * @param minHeight is the lower limit of the displacement.
  21099. * @param maxHeight is the upper limit of the displacement.
  21100. * @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.
  21101. * @param uvOffset is an optional vector2 used to offset UV.
  21102. * @param uvScale is an optional vector2 used to scale UV.
  21103. * @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.
  21104. * @returns the Mesh.
  21105. */
  21106. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21107. /**
  21108. * Modifies the mesh geometry according to a displacementMap buffer.
  21109. * 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.
  21110. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21111. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21112. * @param heightMapWidth is the width of the buffer image.
  21113. * @param heightMapHeight is the height of the buffer image.
  21114. * @param minHeight is the lower limit of the displacement.
  21115. * @param maxHeight is the upper limit of the displacement.
  21116. * @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.
  21117. * @param uvOffset is an optional vector2 used to offset UV.
  21118. * @param uvScale is an optional vector2 used to scale UV.
  21119. * @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.
  21120. * @returns the Mesh.
  21121. */
  21122. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21123. /**
  21124. * Modify the mesh to get a flat shading rendering.
  21125. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21126. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21127. * @returns current mesh
  21128. */
  21129. convertToFlatShadedMesh(): Mesh;
  21130. /**
  21131. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21132. * In other words, more vertices, no more indices and a single bigger VBO.
  21133. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21134. * @returns current mesh
  21135. */
  21136. convertToUnIndexedMesh(): Mesh;
  21137. /**
  21138. * Inverses facet orientations.
  21139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21140. * @param flipNormals will also inverts the normals
  21141. * @returns current mesh
  21142. */
  21143. flipFaces(flipNormals?: boolean): Mesh;
  21144. /** @hidden */
  21145. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21146. /** @hidden */
  21147. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21148. /**
  21149. * Creates a new InstancedMesh object from the mesh model.
  21150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21151. * @param name defines the name of the new instance
  21152. * @returns a new InstancedMesh
  21153. */
  21154. createInstance(name: string): InstancedMesh;
  21155. /**
  21156. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21157. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21158. * @returns the current mesh
  21159. */
  21160. synchronizeInstances(): Mesh;
  21161. /**
  21162. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21163. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21164. * This should be used together with the simplification to avoid disappearing triangles.
  21165. * @param successCallback an optional success callback to be called after the optimization finished.
  21166. * @returns the current mesh
  21167. */
  21168. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21169. /**
  21170. * Serialize current mesh
  21171. * @param serializationObject defines the object which will receive the serialization data
  21172. */
  21173. serialize(serializationObject: any): void;
  21174. /** @hidden */
  21175. _syncGeometryWithMorphTargetManager(): void;
  21176. /** @hidden */
  21177. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21178. /**
  21179. * Returns a new Mesh object parsed from the source provided.
  21180. * @param parsedMesh is the source
  21181. * @param scene defines the hosting scene
  21182. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21183. * @returns a new Mesh
  21184. */
  21185. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21186. /**
  21187. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21188. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21189. * @param name defines the name of the mesh to create
  21190. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21191. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21192. * @param closePath creates a seam between the first and the last points of each path of the path array
  21193. * @param offset is taken in account only if the `pathArray` is containing a single path
  21194. * @param scene defines the hosting scene
  21195. * @param updatable defines if the mesh must be flagged as updatable
  21196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21197. * @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)
  21198. * @returns a new Mesh
  21199. */
  21200. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21201. /**
  21202. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21203. * @param name defines the name of the mesh to create
  21204. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21205. * @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
  21206. * @param scene defines the hosting scene
  21207. * @param updatable defines if the mesh must be flagged as updatable
  21208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21209. * @returns a new Mesh
  21210. */
  21211. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21212. /**
  21213. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21214. * @param name defines the name of the mesh to create
  21215. * @param size sets the size (float) of each box side (default 1)
  21216. * @param scene defines the hosting scene
  21217. * @param updatable defines if the mesh must be flagged as updatable
  21218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21219. * @returns a new Mesh
  21220. */
  21221. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21222. /**
  21223. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21224. * @param name defines the name of the mesh to create
  21225. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21226. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21227. * @param scene defines the hosting scene
  21228. * @param updatable defines if the mesh must be flagged as updatable
  21229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21230. * @returns a new Mesh
  21231. */
  21232. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21233. /**
  21234. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21235. * @param name defines the name of the mesh to create
  21236. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21237. * @param diameterTop set the top cap diameter (floats, default 1)
  21238. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21239. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21240. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21241. * @param scene defines the hosting scene
  21242. * @param updatable defines if the mesh must be flagged as updatable
  21243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21244. * @returns a new Mesh
  21245. */
  21246. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21247. /**
  21248. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21249. * @param name defines the name of the mesh to create
  21250. * @param diameter sets the diameter size (float) of the torus (default 1)
  21251. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21252. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21253. * @param scene defines the hosting scene
  21254. * @param updatable defines if the mesh must be flagged as updatable
  21255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21256. * @returns a new Mesh
  21257. */
  21258. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21259. /**
  21260. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21261. * @param name defines the name of the mesh to create
  21262. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21263. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21264. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21265. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21266. * @param p the number of windings on X axis (positive integers, default 2)
  21267. * @param q the number of windings on Y axis (positive integers, default 3)
  21268. * @param scene defines the hosting scene
  21269. * @param updatable defines if the mesh must be flagged as updatable
  21270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21271. * @returns a new Mesh
  21272. */
  21273. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21274. /**
  21275. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21276. * @param name defines the name of the mesh to create
  21277. * @param points is an array successive Vector3
  21278. * @param scene defines the hosting scene
  21279. * @param updatable defines if the mesh must be flagged as updatable
  21280. * @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).
  21281. * @returns a new Mesh
  21282. */
  21283. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21284. /**
  21285. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @param points is an array successive Vector3
  21288. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21289. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21290. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21291. * @param scene defines the hosting scene
  21292. * @param updatable defines if the mesh must be flagged as updatable
  21293. * @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)
  21294. * @returns a new Mesh
  21295. */
  21296. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21297. /**
  21298. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21299. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21300. * 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.
  21301. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21302. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21303. * Remember you can only change the shape positions, not their number when updating a polygon.
  21304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21305. * @param name defines the name of the mesh to create
  21306. * @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
  21307. * @param scene defines the hosting scene
  21308. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21309. * @param updatable defines if the mesh must be flagged as updatable
  21310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21311. * @param earcutInjection can be used to inject your own earcut reference
  21312. * @returns a new Mesh
  21313. */
  21314. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21315. /**
  21316. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21317. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21318. * @param name defines the name of the mesh to create
  21319. * @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
  21320. * @param depth defines the height of extrusion
  21321. * @param scene defines the hosting scene
  21322. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21323. * @param updatable defines if the mesh must be flagged as updatable
  21324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21325. * @param earcutInjection can be used to inject your own earcut reference
  21326. * @returns a new Mesh
  21327. */
  21328. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21329. /**
  21330. * Creates an extruded shape mesh.
  21331. * 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
  21332. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21333. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21334. * @param name defines the name of the mesh to create
  21335. * @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
  21336. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21337. * @param scale is the value to scale the shape
  21338. * @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
  21339. * @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
  21340. * @param scene defines the hosting scene
  21341. * @param updatable defines if the mesh must be flagged as updatable
  21342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21343. * @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)
  21344. * @returns a new Mesh
  21345. */
  21346. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21347. /**
  21348. * Creates an custom extruded shape mesh.
  21349. * The custom extrusion is a parametric shape.
  21350. * It has no predefined shape. Its final shape will depend on the input parameters.
  21351. * Please consider using the same method from the MeshBuilder class instead
  21352. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21353. * @param name defines the name of the mesh to create
  21354. * @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
  21355. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21356. * @param scaleFunction is a custom Javascript function called on each path point
  21357. * @param rotationFunction is a custom Javascript function called on each path point
  21358. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21359. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21360. * @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
  21361. * @param scene defines the hosting scene
  21362. * @param updatable defines if the mesh must be flagged as updatable
  21363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21364. * @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)
  21365. * @returns a new Mesh
  21366. */
  21367. 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;
  21368. /**
  21369. * Creates lathe mesh.
  21370. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21371. * Please consider using the same method from the MeshBuilder class instead
  21372. * @param name defines the name of the mesh to create
  21373. * @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
  21374. * @param radius is the radius value of the lathe
  21375. * @param tessellation is the side number of the lathe.
  21376. * @param scene defines the hosting scene
  21377. * @param updatable defines if the mesh must be flagged as updatable
  21378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21379. * @returns a new Mesh
  21380. */
  21381. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21382. /**
  21383. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21384. * @param name defines the name of the mesh to create
  21385. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21386. * @param scene defines the hosting scene
  21387. * @param updatable defines if the mesh must be flagged as updatable
  21388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21389. * @returns a new Mesh
  21390. */
  21391. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21392. /**
  21393. * Creates a ground mesh.
  21394. * Please consider using the same method from the MeshBuilder class instead
  21395. * @param name defines the name of the mesh to create
  21396. * @param width set the width of the ground
  21397. * @param height set the height of the ground
  21398. * @param subdivisions sets the number of subdivisions per side
  21399. * @param scene defines the hosting scene
  21400. * @param updatable defines if the mesh must be flagged as updatable
  21401. * @returns a new Mesh
  21402. */
  21403. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21404. /**
  21405. * Creates a tiled ground mesh.
  21406. * Please consider using the same method from the MeshBuilder class instead
  21407. * @param name defines the name of the mesh to create
  21408. * @param xmin set the ground minimum X coordinate
  21409. * @param zmin set the ground minimum Y coordinate
  21410. * @param xmax set the ground maximum X coordinate
  21411. * @param zmax set the ground maximum Z coordinate
  21412. * @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
  21413. * @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
  21414. * @param scene defines the hosting scene
  21415. * @param updatable defines if the mesh must be flagged as updatable
  21416. * @returns a new Mesh
  21417. */
  21418. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21419. w: number;
  21420. h: number;
  21421. }, precision: {
  21422. w: number;
  21423. h: number;
  21424. }, scene: Scene, updatable?: boolean): Mesh;
  21425. /**
  21426. * Creates a ground mesh from a height map.
  21427. * Please consider using the same method from the MeshBuilder class instead
  21428. * @see http://doc.babylonjs.com/babylon101/height_map
  21429. * @param name defines the name of the mesh to create
  21430. * @param url sets the URL of the height map image resource
  21431. * @param width set the ground width size
  21432. * @param height set the ground height size
  21433. * @param subdivisions sets the number of subdivision per side
  21434. * @param minHeight is the minimum altitude on the ground
  21435. * @param maxHeight is the maximum altitude on the ground
  21436. * @param scene defines the hosting scene
  21437. * @param updatable defines if the mesh must be flagged as updatable
  21438. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21439. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21440. * @returns a new Mesh
  21441. */
  21442. 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;
  21443. /**
  21444. * Creates a tube mesh.
  21445. * The tube is a parametric shape.
  21446. * It has no predefined shape. Its final shape will depend on the input parameters.
  21447. * Please consider using the same method from the MeshBuilder class instead
  21448. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21449. * @param name defines the name of the mesh to create
  21450. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21451. * @param radius sets the tube radius size
  21452. * @param tessellation is the number of sides on the tubular surface
  21453. * @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
  21454. * @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
  21455. * @param scene defines the hosting scene
  21456. * @param updatable defines if the mesh must be flagged as updatable
  21457. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21458. * @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)
  21459. * @returns a new Mesh
  21460. */
  21461. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21462. (i: number, distance: number): number;
  21463. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21464. /**
  21465. * Creates a polyhedron mesh.
  21466. * Please consider using the same method from the MeshBuilder class instead.
  21467. * * 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
  21468. * * The parameter `size` (positive float, default 1) sets the polygon size
  21469. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21470. * * 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`
  21471. * * 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
  21472. * * 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)`)
  21473. * * 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
  21474. * * 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
  21475. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21476. * * If you create a double-sided mesh, you can choose what parts of 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
  21477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21478. * @param name defines the name of the mesh to create
  21479. * @param options defines the options used to create the mesh
  21480. * @param scene defines the hosting scene
  21481. * @returns a new Mesh
  21482. */
  21483. static CreatePolyhedron(name: string, options: {
  21484. type?: number;
  21485. size?: number;
  21486. sizeX?: number;
  21487. sizeY?: number;
  21488. sizeZ?: number;
  21489. custom?: any;
  21490. faceUV?: Vector4[];
  21491. faceColors?: Color4[];
  21492. updatable?: boolean;
  21493. sideOrientation?: number;
  21494. }, scene: Scene): Mesh;
  21495. /**
  21496. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21497. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21498. * * 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`)
  21499. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21500. * * 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
  21501. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21502. * * If you create a double-sided mesh, you can choose what parts of 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
  21503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21504. * @param name defines the name of the mesh
  21505. * @param options defines the options used to create the mesh
  21506. * @param scene defines the hosting scene
  21507. * @returns a new Mesh
  21508. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21509. */
  21510. static CreateIcoSphere(name: string, options: {
  21511. radius?: number;
  21512. flat?: boolean;
  21513. subdivisions?: number;
  21514. sideOrientation?: number;
  21515. updatable?: boolean;
  21516. }, scene: Scene): Mesh;
  21517. /**
  21518. * Creates a decal mesh.
  21519. * Please consider using the same method from the MeshBuilder class instead.
  21520. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21521. * @param name defines the name of the mesh
  21522. * @param sourceMesh defines the mesh receiving the decal
  21523. * @param position sets the position of the decal in world coordinates
  21524. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21525. * @param size sets the decal scaling
  21526. * @param angle sets the angle to rotate the decal
  21527. * @returns a new Mesh
  21528. */
  21529. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21530. /**
  21531. * Prepare internal position array for software CPU skinning
  21532. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21533. */
  21534. setPositionsForCPUSkinning(): Float32Array;
  21535. /**
  21536. * Prepare internal normal array for software CPU skinning
  21537. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21538. */
  21539. setNormalsForCPUSkinning(): Float32Array;
  21540. /**
  21541. * Updates the vertex buffer by applying transformation from the bones
  21542. * @param skeleton defines the skeleton to apply to current mesh
  21543. * @returns the current mesh
  21544. */
  21545. applySkeleton(skeleton: Skeleton): Mesh;
  21546. /**
  21547. * 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
  21548. * @param meshes defines the list of meshes to scan
  21549. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21550. */
  21551. static MinMax(meshes: AbstractMesh[]): {
  21552. min: Vector3;
  21553. max: Vector3;
  21554. };
  21555. /**
  21556. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21557. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21558. * @returns a vector3
  21559. */
  21560. static Center(meshesOrMinMaxVector: {
  21561. min: Vector3;
  21562. max: Vector3;
  21563. } | AbstractMesh[]): Vector3;
  21564. /**
  21565. * Merge the array of meshes into a single mesh for performance reasons.
  21566. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21567. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21568. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21569. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21570. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21571. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21572. * @returns a new mesh
  21573. */
  21574. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21575. /** @hidden */
  21576. addInstance(instance: InstancedMesh): void;
  21577. /** @hidden */
  21578. removeInstance(instance: InstancedMesh): void;
  21579. }
  21580. }
  21581. declare module "babylonjs/Materials/material" {
  21582. import { IAnimatable } from "babylonjs/Misc/tools";
  21583. import { SmartArray } from "babylonjs/Misc/smartArray";
  21584. import { Observable } from "babylonjs/Misc/observable";
  21585. import { Nullable } from "babylonjs/types";
  21586. import { Scene } from "babylonjs/scene";
  21587. import { Matrix } from "babylonjs/Maths/math";
  21588. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21590. import { Mesh } from "babylonjs/Meshes/mesh";
  21591. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21592. import { Effect } from "babylonjs/Materials/effect";
  21593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21594. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21595. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21596. import { Animation } from "babylonjs/Animations/animation";
  21597. /**
  21598. * Base class for the main features of a material in Babylon.js
  21599. */
  21600. export class Material implements IAnimatable {
  21601. /**
  21602. * Returns the triangle fill mode
  21603. */
  21604. static readonly TriangleFillMode: number;
  21605. /**
  21606. * Returns the wireframe mode
  21607. */
  21608. static readonly WireFrameFillMode: number;
  21609. /**
  21610. * Returns the point fill mode
  21611. */
  21612. static readonly PointFillMode: number;
  21613. /**
  21614. * Returns the point list draw mode
  21615. */
  21616. static readonly PointListDrawMode: number;
  21617. /**
  21618. * Returns the line list draw mode
  21619. */
  21620. static readonly LineListDrawMode: number;
  21621. /**
  21622. * Returns the line loop draw mode
  21623. */
  21624. static readonly LineLoopDrawMode: number;
  21625. /**
  21626. * Returns the line strip draw mode
  21627. */
  21628. static readonly LineStripDrawMode: number;
  21629. /**
  21630. * Returns the triangle strip draw mode
  21631. */
  21632. static readonly TriangleStripDrawMode: number;
  21633. /**
  21634. * Returns the triangle fan draw mode
  21635. */
  21636. static readonly TriangleFanDrawMode: number;
  21637. /**
  21638. * Stores the clock-wise side orientation
  21639. */
  21640. static readonly ClockWiseSideOrientation: number;
  21641. /**
  21642. * Stores the counter clock-wise side orientation
  21643. */
  21644. static readonly CounterClockWiseSideOrientation: number;
  21645. /**
  21646. * The dirty texture flag value
  21647. */
  21648. static readonly TextureDirtyFlag: number;
  21649. /**
  21650. * The dirty light flag value
  21651. */
  21652. static readonly LightDirtyFlag: number;
  21653. /**
  21654. * The dirty fresnel flag value
  21655. */
  21656. static readonly FresnelDirtyFlag: number;
  21657. /**
  21658. * The dirty attribute flag value
  21659. */
  21660. static readonly AttributesDirtyFlag: number;
  21661. /**
  21662. * The dirty misc flag value
  21663. */
  21664. static readonly MiscDirtyFlag: number;
  21665. /**
  21666. * The all dirty flag value
  21667. */
  21668. static readonly AllDirtyFlag: number;
  21669. /**
  21670. * The ID of the material
  21671. */
  21672. id: string;
  21673. /**
  21674. * Gets or sets the unique id of the material
  21675. */
  21676. uniqueId: number;
  21677. /**
  21678. * The name of the material
  21679. */
  21680. name: string;
  21681. /**
  21682. * Gets or sets user defined metadata
  21683. */
  21684. metadata: any;
  21685. /**
  21686. * For internal use only. Please do not use.
  21687. */
  21688. reservedDataStore: any;
  21689. /**
  21690. * Specifies if the ready state should be checked on each call
  21691. */
  21692. checkReadyOnEveryCall: boolean;
  21693. /**
  21694. * Specifies if the ready state should be checked once
  21695. */
  21696. checkReadyOnlyOnce: boolean;
  21697. /**
  21698. * The state of the material
  21699. */
  21700. state: string;
  21701. /**
  21702. * The alpha value of the material
  21703. */
  21704. protected _alpha: number;
  21705. /**
  21706. * Sets the alpha value of the material
  21707. */
  21708. /**
  21709. * Gets the alpha value of the material
  21710. */
  21711. alpha: number;
  21712. /**
  21713. * Specifies if back face culling is enabled
  21714. */
  21715. protected _backFaceCulling: boolean;
  21716. /**
  21717. * Sets the back-face culling state
  21718. */
  21719. /**
  21720. * Gets the back-face culling state
  21721. */
  21722. backFaceCulling: boolean;
  21723. /**
  21724. * Stores the value for side orientation
  21725. */
  21726. sideOrientation: number;
  21727. /**
  21728. * Callback triggered when the material is compiled
  21729. */
  21730. onCompiled: (effect: Effect) => void;
  21731. /**
  21732. * Callback triggered when an error occurs
  21733. */
  21734. onError: (effect: Effect, errors: string) => void;
  21735. /**
  21736. * Callback triggered to get the render target textures
  21737. */
  21738. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21739. /**
  21740. * Gets a boolean indicating that current material needs to register RTT
  21741. */
  21742. readonly hasRenderTargetTextures: boolean;
  21743. /**
  21744. * Specifies if the material should be serialized
  21745. */
  21746. doNotSerialize: boolean;
  21747. /**
  21748. * @hidden
  21749. */
  21750. _storeEffectOnSubMeshes: boolean;
  21751. /**
  21752. * Stores the animations for the material
  21753. */
  21754. animations: Array<Animation>;
  21755. /**
  21756. * An event triggered when the material is disposed
  21757. */
  21758. onDisposeObservable: Observable<Material>;
  21759. /**
  21760. * An observer which watches for dispose events
  21761. */
  21762. private _onDisposeObserver;
  21763. private _onUnBindObservable;
  21764. /**
  21765. * Called during a dispose event
  21766. */
  21767. onDispose: () => void;
  21768. private _onBindObservable;
  21769. /**
  21770. * An event triggered when the material is bound
  21771. */
  21772. readonly onBindObservable: Observable<AbstractMesh>;
  21773. /**
  21774. * An observer which watches for bind events
  21775. */
  21776. private _onBindObserver;
  21777. /**
  21778. * Called during a bind event
  21779. */
  21780. onBind: (Mesh: AbstractMesh) => void;
  21781. /**
  21782. * An event triggered when the material is unbound
  21783. */
  21784. readonly onUnBindObservable: Observable<Material>;
  21785. /**
  21786. * Stores the value of the alpha mode
  21787. */
  21788. private _alphaMode;
  21789. /**
  21790. * Sets the value of the alpha mode.
  21791. *
  21792. * | Value | Type | Description |
  21793. * | --- | --- | --- |
  21794. * | 0 | ALPHA_DISABLE | |
  21795. * | 1 | ALPHA_ADD | |
  21796. * | 2 | ALPHA_COMBINE | |
  21797. * | 3 | ALPHA_SUBTRACT | |
  21798. * | 4 | ALPHA_MULTIPLY | |
  21799. * | 5 | ALPHA_MAXIMIZED | |
  21800. * | 6 | ALPHA_ONEONE | |
  21801. * | 7 | ALPHA_PREMULTIPLIED | |
  21802. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21803. * | 9 | ALPHA_INTERPOLATE | |
  21804. * | 10 | ALPHA_SCREENMODE | |
  21805. *
  21806. */
  21807. /**
  21808. * Gets the value of the alpha mode
  21809. */
  21810. alphaMode: number;
  21811. /**
  21812. * Stores the state of the need depth pre-pass value
  21813. */
  21814. private _needDepthPrePass;
  21815. /**
  21816. * Sets the need depth pre-pass value
  21817. */
  21818. /**
  21819. * Gets the depth pre-pass value
  21820. */
  21821. needDepthPrePass: boolean;
  21822. /**
  21823. * Specifies if depth writing should be disabled
  21824. */
  21825. disableDepthWrite: boolean;
  21826. /**
  21827. * Specifies if depth writing should be forced
  21828. */
  21829. forceDepthWrite: boolean;
  21830. /**
  21831. * Specifies if there should be a separate pass for culling
  21832. */
  21833. separateCullingPass: boolean;
  21834. /**
  21835. * Stores the state specifing if fog should be enabled
  21836. */
  21837. private _fogEnabled;
  21838. /**
  21839. * Sets the state for enabling fog
  21840. */
  21841. /**
  21842. * Gets the value of the fog enabled state
  21843. */
  21844. fogEnabled: boolean;
  21845. /**
  21846. * Stores the size of points
  21847. */
  21848. pointSize: number;
  21849. /**
  21850. * Stores the z offset value
  21851. */
  21852. zOffset: number;
  21853. /**
  21854. * Gets a value specifying if wireframe mode is enabled
  21855. */
  21856. /**
  21857. * Sets the state of wireframe mode
  21858. */
  21859. wireframe: boolean;
  21860. /**
  21861. * Gets the value specifying if point clouds are enabled
  21862. */
  21863. /**
  21864. * Sets the state of point cloud mode
  21865. */
  21866. pointsCloud: boolean;
  21867. /**
  21868. * Gets the material fill mode
  21869. */
  21870. /**
  21871. * Sets the material fill mode
  21872. */
  21873. fillMode: number;
  21874. /**
  21875. * @hidden
  21876. * Stores the effects for the material
  21877. */
  21878. _effect: Nullable<Effect>;
  21879. /**
  21880. * @hidden
  21881. * Specifies if the material was previously ready
  21882. */
  21883. _wasPreviouslyReady: boolean;
  21884. /**
  21885. * Specifies if uniform buffers should be used
  21886. */
  21887. private _useUBO;
  21888. /**
  21889. * Stores a reference to the scene
  21890. */
  21891. private _scene;
  21892. /**
  21893. * Stores the fill mode state
  21894. */
  21895. private _fillMode;
  21896. /**
  21897. * Specifies if the depth write state should be cached
  21898. */
  21899. private _cachedDepthWriteState;
  21900. /**
  21901. * Stores the uniform buffer
  21902. */
  21903. protected _uniformBuffer: UniformBuffer;
  21904. /** @hidden */
  21905. _indexInSceneMaterialArray: number;
  21906. /** @hidden */
  21907. meshMap: Nullable<{
  21908. [id: string]: AbstractMesh | undefined;
  21909. }>;
  21910. /**
  21911. * Creates a material instance
  21912. * @param name defines the name of the material
  21913. * @param scene defines the scene to reference
  21914. * @param doNotAdd specifies if the material should be added to the scene
  21915. */
  21916. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21917. /**
  21918. * Returns a string representation of the current material
  21919. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21920. * @returns a string with material information
  21921. */
  21922. toString(fullDetails?: boolean): string;
  21923. /**
  21924. * Gets the class name of the material
  21925. * @returns a string with the class name of the material
  21926. */
  21927. getClassName(): string;
  21928. /**
  21929. * Specifies if updates for the material been locked
  21930. */
  21931. readonly isFrozen: boolean;
  21932. /**
  21933. * Locks updates for the material
  21934. */
  21935. freeze(): void;
  21936. /**
  21937. * Unlocks updates for the material
  21938. */
  21939. unfreeze(): void;
  21940. /**
  21941. * Specifies if the material is ready to be used
  21942. * @param mesh defines the mesh to check
  21943. * @param useInstances specifies if instances should be used
  21944. * @returns a boolean indicating if the material is ready to be used
  21945. */
  21946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21947. /**
  21948. * Specifies that the submesh is ready to be used
  21949. * @param mesh defines the mesh to check
  21950. * @param subMesh defines which submesh to check
  21951. * @param useInstances specifies that instances should be used
  21952. * @returns a boolean indicating that the submesh is ready or not
  21953. */
  21954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21955. /**
  21956. * Returns the material effect
  21957. * @returns the effect associated with the material
  21958. */
  21959. getEffect(): Nullable<Effect>;
  21960. /**
  21961. * Returns the current scene
  21962. * @returns a Scene
  21963. */
  21964. getScene(): Scene;
  21965. /**
  21966. * Specifies if the material will require alpha blending
  21967. * @returns a boolean specifying if alpha blending is needed
  21968. */
  21969. needAlphaBlending(): boolean;
  21970. /**
  21971. * Specifies if the mesh will require alpha blending
  21972. * @param mesh defines the mesh to check
  21973. * @returns a boolean specifying if alpha blending is needed for the mesh
  21974. */
  21975. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21976. /**
  21977. * Specifies if this material should be rendered in alpha test mode
  21978. * @returns a boolean specifying if an alpha test is needed.
  21979. */
  21980. needAlphaTesting(): boolean;
  21981. /**
  21982. * Gets the texture used for the alpha test
  21983. * @returns the texture to use for alpha testing
  21984. */
  21985. getAlphaTestTexture(): Nullable<BaseTexture>;
  21986. /**
  21987. * Marks the material to indicate that it needs to be re-calculated
  21988. */
  21989. markDirty(): void;
  21990. /** @hidden */
  21991. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21992. /**
  21993. * Binds the material to the mesh
  21994. * @param world defines the world transformation matrix
  21995. * @param mesh defines the mesh to bind the material to
  21996. */
  21997. bind(world: Matrix, mesh?: Mesh): void;
  21998. /**
  21999. * Binds the submesh to the material
  22000. * @param world defines the world transformation matrix
  22001. * @param mesh defines the mesh containing the submesh
  22002. * @param subMesh defines the submesh to bind the material to
  22003. */
  22004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22005. /**
  22006. * Binds the world matrix to the material
  22007. * @param world defines the world transformation matrix
  22008. */
  22009. bindOnlyWorldMatrix(world: Matrix): void;
  22010. /**
  22011. * Binds the scene's uniform buffer to the effect.
  22012. * @param effect defines the effect to bind to the scene uniform buffer
  22013. * @param sceneUbo defines the uniform buffer storing scene data
  22014. */
  22015. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22016. /**
  22017. * Binds the view matrix to the effect
  22018. * @param effect defines the effect to bind the view matrix to
  22019. */
  22020. bindView(effect: Effect): void;
  22021. /**
  22022. * Binds the view projection matrix to the effect
  22023. * @param effect defines the effect to bind the view projection matrix to
  22024. */
  22025. bindViewProjection(effect: Effect): void;
  22026. /**
  22027. * Specifies if material alpha testing should be turned on for the mesh
  22028. * @param mesh defines the mesh to check
  22029. */
  22030. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22031. /**
  22032. * Processes to execute after binding the material to a mesh
  22033. * @param mesh defines the rendered mesh
  22034. */
  22035. protected _afterBind(mesh?: Mesh): void;
  22036. /**
  22037. * Unbinds the material from the mesh
  22038. */
  22039. unbind(): void;
  22040. /**
  22041. * Gets the active textures from the material
  22042. * @returns an array of textures
  22043. */
  22044. getActiveTextures(): BaseTexture[];
  22045. /**
  22046. * Specifies if the material uses a texture
  22047. * @param texture defines the texture to check against the material
  22048. * @returns a boolean specifying if the material uses the texture
  22049. */
  22050. hasTexture(texture: BaseTexture): boolean;
  22051. /**
  22052. * Makes a duplicate of the material, and gives it a new name
  22053. * @param name defines the new name for the duplicated material
  22054. * @returns the cloned material
  22055. */
  22056. clone(name: string): Nullable<Material>;
  22057. /**
  22058. * Gets the meshes bound to the material
  22059. * @returns an array of meshes bound to the material
  22060. */
  22061. getBindedMeshes(): AbstractMesh[];
  22062. /**
  22063. * Force shader compilation
  22064. * @param mesh defines the mesh associated with this material
  22065. * @param onCompiled defines a function to execute once the material is compiled
  22066. * @param options defines the options to configure the compilation
  22067. */
  22068. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22069. clipPlane: boolean;
  22070. }>): void;
  22071. /**
  22072. * Force shader compilation
  22073. * @param mesh defines the mesh that will use this material
  22074. * @param options defines additional options for compiling the shaders
  22075. * @returns a promise that resolves when the compilation completes
  22076. */
  22077. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22078. clipPlane: boolean;
  22079. }>): Promise<void>;
  22080. private static readonly _ImageProcessingDirtyCallBack;
  22081. private static readonly _TextureDirtyCallBack;
  22082. private static readonly _FresnelDirtyCallBack;
  22083. private static readonly _MiscDirtyCallBack;
  22084. private static readonly _LightsDirtyCallBack;
  22085. private static readonly _AttributeDirtyCallBack;
  22086. private static _FresnelAndMiscDirtyCallBack;
  22087. private static _TextureAndMiscDirtyCallBack;
  22088. private static readonly _DirtyCallbackArray;
  22089. private static readonly _RunDirtyCallBacks;
  22090. /**
  22091. * Marks a define in the material to indicate that it needs to be re-computed
  22092. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22093. */
  22094. markAsDirty(flag: number): void;
  22095. /**
  22096. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22097. * @param func defines a function which checks material defines against the submeshes
  22098. */
  22099. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22100. /**
  22101. * Indicates that image processing needs to be re-calculated for all submeshes
  22102. */
  22103. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22104. /**
  22105. * Indicates that textures need to be re-calculated for all submeshes
  22106. */
  22107. protected _markAllSubMeshesAsTexturesDirty(): void;
  22108. /**
  22109. * Indicates that fresnel needs to be re-calculated for all submeshes
  22110. */
  22111. protected _markAllSubMeshesAsFresnelDirty(): void;
  22112. /**
  22113. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22114. */
  22115. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22116. /**
  22117. * Indicates that lights need to be re-calculated for all submeshes
  22118. */
  22119. protected _markAllSubMeshesAsLightsDirty(): void;
  22120. /**
  22121. * Indicates that attributes need to be re-calculated for all submeshes
  22122. */
  22123. protected _markAllSubMeshesAsAttributesDirty(): void;
  22124. /**
  22125. * Indicates that misc needs to be re-calculated for all submeshes
  22126. */
  22127. protected _markAllSubMeshesAsMiscDirty(): void;
  22128. /**
  22129. * Indicates that textures and misc need to be re-calculated for all submeshes
  22130. */
  22131. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22132. /**
  22133. * Disposes the material
  22134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22136. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22137. */
  22138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22139. /** @hidden */
  22140. private releaseVertexArrayObject;
  22141. /**
  22142. * Serializes this material
  22143. * @returns the serialized material object
  22144. */
  22145. serialize(): any;
  22146. /**
  22147. * Creates a material from parsed material data
  22148. * @param parsedMaterial defines parsed material data
  22149. * @param scene defines the hosting scene
  22150. * @param rootUrl defines the root URL to use to load textures
  22151. * @returns a new material
  22152. */
  22153. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22154. }
  22155. }
  22156. declare module "babylonjs/Meshes/subMesh" {
  22157. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22158. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22159. import { Engine } from "babylonjs/Engines/engine";
  22160. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22161. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22162. import { Effect } from "babylonjs/Materials/effect";
  22163. import { Collider } from "babylonjs/Collisions/collider";
  22164. import { Material } from "babylonjs/Materials/material";
  22165. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22167. import { Mesh } from "babylonjs/Meshes/mesh";
  22168. import { Ray } from "babylonjs/Culling/ray";
  22169. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22170. /**
  22171. * Base class for submeshes
  22172. */
  22173. export class BaseSubMesh {
  22174. /** @hidden */
  22175. _materialDefines: Nullable<MaterialDefines>;
  22176. /** @hidden */
  22177. _materialEffect: Nullable<Effect>;
  22178. /**
  22179. * Gets associated effect
  22180. */
  22181. readonly effect: Nullable<Effect>;
  22182. /**
  22183. * Sets associated effect (effect used to render this submesh)
  22184. * @param effect defines the effect to associate with
  22185. * @param defines defines the set of defines used to compile this effect
  22186. */
  22187. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22188. }
  22189. /**
  22190. * Defines a subdivision inside a mesh
  22191. */
  22192. export class SubMesh extends BaseSubMesh implements ICullable {
  22193. /** the material index to use */
  22194. materialIndex: number;
  22195. /** vertex index start */
  22196. verticesStart: number;
  22197. /** vertices count */
  22198. verticesCount: number;
  22199. /** index start */
  22200. indexStart: number;
  22201. /** indices count */
  22202. indexCount: number;
  22203. /** @hidden */
  22204. _linesIndexCount: number;
  22205. private _mesh;
  22206. private _renderingMesh;
  22207. private _boundingInfo;
  22208. private _linesIndexBuffer;
  22209. /** @hidden */
  22210. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22211. /** @hidden */
  22212. _trianglePlanes: Plane[];
  22213. /** @hidden */
  22214. _lastColliderTransformMatrix: Matrix;
  22215. /** @hidden */
  22216. _renderId: number;
  22217. /** @hidden */
  22218. _alphaIndex: number;
  22219. /** @hidden */
  22220. _distanceToCamera: number;
  22221. /** @hidden */
  22222. _id: number;
  22223. private _currentMaterial;
  22224. /**
  22225. * Add a new submesh to a mesh
  22226. * @param materialIndex defines the material index to use
  22227. * @param verticesStart defines vertex index start
  22228. * @param verticesCount defines vertices count
  22229. * @param indexStart defines index start
  22230. * @param indexCount defines indices count
  22231. * @param mesh defines the parent mesh
  22232. * @param renderingMesh defines an optional rendering mesh
  22233. * @param createBoundingBox defines if bounding box should be created for this submesh
  22234. * @returns the new submesh
  22235. */
  22236. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22237. /**
  22238. * Creates a new submesh
  22239. * @param materialIndex defines the material index to use
  22240. * @param verticesStart defines vertex index start
  22241. * @param verticesCount defines vertices count
  22242. * @param indexStart defines index start
  22243. * @param indexCount defines indices count
  22244. * @param mesh defines the parent mesh
  22245. * @param renderingMesh defines an optional rendering mesh
  22246. * @param createBoundingBox defines if bounding box should be created for this submesh
  22247. */
  22248. constructor(
  22249. /** the material index to use */
  22250. materialIndex: number,
  22251. /** vertex index start */
  22252. verticesStart: number,
  22253. /** vertices count */
  22254. verticesCount: number,
  22255. /** index start */
  22256. indexStart: number,
  22257. /** indices count */
  22258. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22259. /**
  22260. * Returns true if this submesh covers the entire parent mesh
  22261. * @ignorenaming
  22262. */
  22263. readonly IsGlobal: boolean;
  22264. /**
  22265. * Returns the submesh BoudingInfo object
  22266. * @returns current bounding info (or mesh's one if the submesh is global)
  22267. */
  22268. getBoundingInfo(): BoundingInfo;
  22269. /**
  22270. * Sets the submesh BoundingInfo
  22271. * @param boundingInfo defines the new bounding info to use
  22272. * @returns the SubMesh
  22273. */
  22274. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22275. /**
  22276. * Returns the mesh of the current submesh
  22277. * @return the parent mesh
  22278. */
  22279. getMesh(): AbstractMesh;
  22280. /**
  22281. * Returns the rendering mesh of the submesh
  22282. * @returns the rendering mesh (could be different from parent mesh)
  22283. */
  22284. getRenderingMesh(): Mesh;
  22285. /**
  22286. * Returns the submesh material
  22287. * @returns null or the current material
  22288. */
  22289. getMaterial(): Nullable<Material>;
  22290. /**
  22291. * Sets a new updated BoundingInfo object to the submesh
  22292. * @returns the SubMesh
  22293. */
  22294. refreshBoundingInfo(): SubMesh;
  22295. /** @hidden */
  22296. _checkCollision(collider: Collider): boolean;
  22297. /**
  22298. * Updates the submesh BoundingInfo
  22299. * @param world defines the world matrix to use to update the bounding info
  22300. * @returns the submesh
  22301. */
  22302. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22303. /**
  22304. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22305. * @param frustumPlanes defines the frustum planes
  22306. * @returns true if the submesh is intersecting with the frustum
  22307. */
  22308. isInFrustum(frustumPlanes: Plane[]): boolean;
  22309. /**
  22310. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22311. * @param frustumPlanes defines the frustum planes
  22312. * @returns true if the submesh is inside the frustum
  22313. */
  22314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22315. /**
  22316. * Renders the submesh
  22317. * @param enableAlphaMode defines if alpha needs to be used
  22318. * @returns the submesh
  22319. */
  22320. render(enableAlphaMode: boolean): SubMesh;
  22321. /**
  22322. * @hidden
  22323. */
  22324. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22325. /**
  22326. * Checks if the submesh intersects with a ray
  22327. * @param ray defines the ray to test
  22328. * @returns true is the passed ray intersects the submesh bounding box
  22329. */
  22330. canIntersects(ray: Ray): boolean;
  22331. /**
  22332. * Intersects current submesh with a ray
  22333. * @param ray defines the ray to test
  22334. * @param positions defines mesh's positions array
  22335. * @param indices defines mesh's indices array
  22336. * @param fastCheck defines if only bounding info should be used
  22337. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22338. * @returns intersection info or null if no intersection
  22339. */
  22340. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22341. /** @hidden */
  22342. private _intersectLines;
  22343. /** @hidden */
  22344. private _intersectTriangles;
  22345. /** @hidden */
  22346. _rebuild(): void;
  22347. /**
  22348. * Creates a new submesh from the passed mesh
  22349. * @param newMesh defines the new hosting mesh
  22350. * @param newRenderingMesh defines an optional rendering mesh
  22351. * @returns the new submesh
  22352. */
  22353. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22354. /**
  22355. * Release associated resources
  22356. */
  22357. dispose(): void;
  22358. /**
  22359. * Gets the class name
  22360. * @returns the string "SubMesh".
  22361. */
  22362. getClassName(): string;
  22363. /**
  22364. * Creates a new submesh from indices data
  22365. * @param materialIndex the index of the main mesh material
  22366. * @param startIndex the index where to start the copy in the mesh indices array
  22367. * @param indexCount the number of indices to copy then from the startIndex
  22368. * @param mesh the main mesh to create the submesh from
  22369. * @param renderingMesh the optional rendering mesh
  22370. * @returns a new submesh
  22371. */
  22372. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22373. }
  22374. }
  22375. declare module "babylonjs/Meshes/geometry" {
  22376. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22377. import { Scene } from "babylonjs/scene";
  22378. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22379. import { Engine } from "babylonjs/Engines/engine";
  22380. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22382. import { Effect } from "babylonjs/Materials/effect";
  22383. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22384. import { Mesh } from "babylonjs/Meshes/mesh";
  22385. /**
  22386. * Class used to store geometry data (vertex buffers + index buffer)
  22387. */
  22388. export class Geometry implements IGetSetVerticesData {
  22389. /**
  22390. * Gets or sets the ID of the geometry
  22391. */
  22392. id: string;
  22393. /**
  22394. * Gets or sets the unique ID of the geometry
  22395. */
  22396. uniqueId: number;
  22397. /**
  22398. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22399. */
  22400. delayLoadState: number;
  22401. /**
  22402. * Gets the file containing the data to load when running in delay load state
  22403. */
  22404. delayLoadingFile: Nullable<string>;
  22405. /**
  22406. * Callback called when the geometry is updated
  22407. */
  22408. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22409. private _scene;
  22410. private _engine;
  22411. private _meshes;
  22412. private _totalVertices;
  22413. /** @hidden */
  22414. _indices: IndicesArray;
  22415. /** @hidden */
  22416. _vertexBuffers: {
  22417. [key: string]: VertexBuffer;
  22418. };
  22419. private _isDisposed;
  22420. private _extend;
  22421. private _boundingBias;
  22422. /** @hidden */
  22423. _delayInfo: Array<string>;
  22424. private _indexBuffer;
  22425. private _indexBufferIsUpdatable;
  22426. /** @hidden */
  22427. _boundingInfo: Nullable<BoundingInfo>;
  22428. /** @hidden */
  22429. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22430. /** @hidden */
  22431. _softwareSkinningFrameId: number;
  22432. private _vertexArrayObjects;
  22433. private _updatable;
  22434. /** @hidden */
  22435. _positions: Nullable<Vector3[]>;
  22436. /**
  22437. * 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
  22438. */
  22439. /**
  22440. * 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
  22441. */
  22442. boundingBias: Vector2;
  22443. /**
  22444. * Static function used to attach a new empty geometry to a mesh
  22445. * @param mesh defines the mesh to attach the geometry to
  22446. * @returns the new Geometry
  22447. */
  22448. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22449. /**
  22450. * Creates a new geometry
  22451. * @param id defines the unique ID
  22452. * @param scene defines the hosting scene
  22453. * @param vertexData defines the VertexData used to get geometry data
  22454. * @param updatable defines if geometry must be updatable (false by default)
  22455. * @param mesh defines the mesh that will be associated with the geometry
  22456. */
  22457. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22458. /**
  22459. * Gets the current extend of the geometry
  22460. */
  22461. readonly extend: {
  22462. minimum: Vector3;
  22463. maximum: Vector3;
  22464. };
  22465. /**
  22466. * Gets the hosting scene
  22467. * @returns the hosting Scene
  22468. */
  22469. getScene(): Scene;
  22470. /**
  22471. * Gets the hosting engine
  22472. * @returns the hosting Engine
  22473. */
  22474. getEngine(): Engine;
  22475. /**
  22476. * Defines if the geometry is ready to use
  22477. * @returns true if the geometry is ready to be used
  22478. */
  22479. isReady(): boolean;
  22480. /**
  22481. * Gets a value indicating that the geometry should not be serialized
  22482. */
  22483. readonly doNotSerialize: boolean;
  22484. /** @hidden */
  22485. _rebuild(): void;
  22486. /**
  22487. * Affects all geometry data in one call
  22488. * @param vertexData defines the geometry data
  22489. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22490. */
  22491. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22492. /**
  22493. * Set specific vertex data
  22494. * @param kind defines the data kind (Position, normal, etc...)
  22495. * @param data defines the vertex data to use
  22496. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22497. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22498. */
  22499. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22500. /**
  22501. * Removes a specific vertex data
  22502. * @param kind defines the data kind (Position, normal, etc...)
  22503. */
  22504. removeVerticesData(kind: string): void;
  22505. /**
  22506. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22507. * @param buffer defines the vertex buffer to use
  22508. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22509. */
  22510. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22511. /**
  22512. * Update a specific vertex buffer
  22513. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22514. * It will do nothing if the buffer is not updatable
  22515. * @param kind defines the data kind (Position, normal, etc...)
  22516. * @param data defines the data to use
  22517. * @param offset defines the offset in the target buffer where to store the data
  22518. * @param useBytes set to true if the offset is in bytes
  22519. */
  22520. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22521. /**
  22522. * Update a specific vertex buffer
  22523. * This function will create a new buffer if the current one is not updatable
  22524. * @param kind defines the data kind (Position, normal, etc...)
  22525. * @param data defines the data to use
  22526. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22527. */
  22528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22529. private _updateBoundingInfo;
  22530. /** @hidden */
  22531. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22532. /**
  22533. * Gets total number of vertices
  22534. * @returns the total number of vertices
  22535. */
  22536. getTotalVertices(): number;
  22537. /**
  22538. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22539. * @param kind defines the data kind (Position, normal, etc...)
  22540. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22541. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22542. * @returns a float array containing vertex data
  22543. */
  22544. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22545. /**
  22546. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22547. * @param kind defines the data kind (Position, normal, etc...)
  22548. * @returns true if the vertex buffer with the specified kind is updatable
  22549. */
  22550. isVertexBufferUpdatable(kind: string): boolean;
  22551. /**
  22552. * Gets a specific vertex buffer
  22553. * @param kind defines the data kind (Position, normal, etc...)
  22554. * @returns a VertexBuffer
  22555. */
  22556. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22557. /**
  22558. * Returns all vertex buffers
  22559. * @return an object holding all vertex buffers indexed by kind
  22560. */
  22561. getVertexBuffers(): Nullable<{
  22562. [key: string]: VertexBuffer;
  22563. }>;
  22564. /**
  22565. * Gets a boolean indicating if specific vertex buffer is present
  22566. * @param kind defines the data kind (Position, normal, etc...)
  22567. * @returns true if data is present
  22568. */
  22569. isVerticesDataPresent(kind: string): boolean;
  22570. /**
  22571. * Gets a list of all attached data kinds (Position, normal, etc...)
  22572. * @returns a list of string containing all kinds
  22573. */
  22574. getVerticesDataKinds(): string[];
  22575. /**
  22576. * Update index buffer
  22577. * @param indices defines the indices to store in the index buffer
  22578. * @param offset defines the offset in the target buffer where to store the data
  22579. * @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)
  22580. */
  22581. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22582. /**
  22583. * Creates a new index buffer
  22584. * @param indices defines the indices to store in the index buffer
  22585. * @param totalVertices defines the total number of vertices (could be null)
  22586. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22587. */
  22588. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22589. /**
  22590. * Return the total number of indices
  22591. * @returns the total number of indices
  22592. */
  22593. getTotalIndices(): number;
  22594. /**
  22595. * Gets the index buffer array
  22596. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22598. * @returns the index buffer array
  22599. */
  22600. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22601. /**
  22602. * Gets the index buffer
  22603. * @return the index buffer
  22604. */
  22605. getIndexBuffer(): Nullable<WebGLBuffer>;
  22606. /** @hidden */
  22607. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22608. /**
  22609. * Release the associated resources for a specific mesh
  22610. * @param mesh defines the source mesh
  22611. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22612. */
  22613. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22614. /**
  22615. * Apply current geometry to a given mesh
  22616. * @param mesh defines the mesh to apply geometry to
  22617. */
  22618. applyToMesh(mesh: Mesh): void;
  22619. private _updateExtend;
  22620. private _applyToMesh;
  22621. private notifyUpdate;
  22622. /**
  22623. * Load the geometry if it was flagged as delay loaded
  22624. * @param scene defines the hosting scene
  22625. * @param onLoaded defines a callback called when the geometry is loaded
  22626. */
  22627. load(scene: Scene, onLoaded?: () => void): void;
  22628. private _queueLoad;
  22629. /**
  22630. * Invert the geometry to move from a right handed system to a left handed one.
  22631. */
  22632. toLeftHanded(): void;
  22633. /** @hidden */
  22634. _resetPointsArrayCache(): void;
  22635. /** @hidden */
  22636. _generatePointsArray(): boolean;
  22637. /**
  22638. * Gets a value indicating if the geometry is disposed
  22639. * @returns true if the geometry was disposed
  22640. */
  22641. isDisposed(): boolean;
  22642. private _disposeVertexArrayObjects;
  22643. /**
  22644. * Free all associated resources
  22645. */
  22646. dispose(): void;
  22647. /**
  22648. * Clone the current geometry into a new geometry
  22649. * @param id defines the unique ID of the new geometry
  22650. * @returns a new geometry object
  22651. */
  22652. copy(id: string): Geometry;
  22653. /**
  22654. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22655. * @return a JSON representation of the current geometry data (without the vertices data)
  22656. */
  22657. serialize(): any;
  22658. private toNumberArray;
  22659. /**
  22660. * Serialize all vertices data into a JSON oject
  22661. * @returns a JSON representation of the current geometry data
  22662. */
  22663. serializeVerticeData(): any;
  22664. /**
  22665. * Extracts a clone of a mesh geometry
  22666. * @param mesh defines the source mesh
  22667. * @param id defines the unique ID of the new geometry object
  22668. * @returns the new geometry object
  22669. */
  22670. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22671. /**
  22672. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22673. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22674. * Be aware Math.random() could cause collisions, but:
  22675. * "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"
  22676. * @returns a string containing a new GUID
  22677. */
  22678. static RandomId(): string;
  22679. /** @hidden */
  22680. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22681. private static _CleanMatricesWeights;
  22682. /**
  22683. * Create a new geometry from persisted data (Using .babylon file format)
  22684. * @param parsedVertexData defines the persisted data
  22685. * @param scene defines the hosting scene
  22686. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22687. * @returns the new geometry object
  22688. */
  22689. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22690. }
  22691. }
  22692. declare module "babylonjs/Meshes/mesh.vertexData" {
  22693. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22694. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22695. import { Geometry } from "babylonjs/Meshes/geometry";
  22696. import { Mesh } from "babylonjs/Meshes/mesh";
  22697. /**
  22698. * Define an interface for all classes that will get and set the data on vertices
  22699. */
  22700. export interface IGetSetVerticesData {
  22701. /**
  22702. * Gets a boolean indicating if specific vertex data is present
  22703. * @param kind defines the vertex data kind to use
  22704. * @returns true is data kind is present
  22705. */
  22706. isVerticesDataPresent(kind: string): boolean;
  22707. /**
  22708. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22709. * @param kind defines the data kind (Position, normal, etc...)
  22710. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22712. * @returns a float array containing vertex data
  22713. */
  22714. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22715. /**
  22716. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22717. * @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.
  22718. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22719. * @returns the indices array or an empty array if the mesh has no geometry
  22720. */
  22721. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22722. /**
  22723. * Set specific vertex data
  22724. * @param kind defines the data kind (Position, normal, etc...)
  22725. * @param data defines the vertex data to use
  22726. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22727. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22728. */
  22729. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22730. /**
  22731. * Update a specific associated vertex buffer
  22732. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22733. * - VertexBuffer.PositionKind
  22734. * - VertexBuffer.UVKind
  22735. * - VertexBuffer.UV2Kind
  22736. * - VertexBuffer.UV3Kind
  22737. * - VertexBuffer.UV4Kind
  22738. * - VertexBuffer.UV5Kind
  22739. * - VertexBuffer.UV6Kind
  22740. * - VertexBuffer.ColorKind
  22741. * - VertexBuffer.MatricesIndicesKind
  22742. * - VertexBuffer.MatricesIndicesExtraKind
  22743. * - VertexBuffer.MatricesWeightsKind
  22744. * - VertexBuffer.MatricesWeightsExtraKind
  22745. * @param data defines the data source
  22746. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22747. * @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)
  22748. */
  22749. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22750. /**
  22751. * Creates a new index buffer
  22752. * @param indices defines the indices to store in the index buffer
  22753. * @param totalVertices defines the total number of vertices (could be null)
  22754. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22755. */
  22756. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22757. }
  22758. /**
  22759. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22760. */
  22761. export class VertexData {
  22762. /**
  22763. * Mesh side orientation : usually the external or front surface
  22764. */
  22765. static readonly FRONTSIDE: number;
  22766. /**
  22767. * Mesh side orientation : usually the internal or back surface
  22768. */
  22769. static readonly BACKSIDE: number;
  22770. /**
  22771. * Mesh side orientation : both internal and external or front and back surfaces
  22772. */
  22773. static readonly DOUBLESIDE: number;
  22774. /**
  22775. * Mesh side orientation : by default, `FRONTSIDE`
  22776. */
  22777. static readonly DEFAULTSIDE: number;
  22778. /**
  22779. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22780. */
  22781. positions: Nullable<FloatArray>;
  22782. /**
  22783. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22784. */
  22785. normals: Nullable<FloatArray>;
  22786. /**
  22787. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22788. */
  22789. tangents: Nullable<FloatArray>;
  22790. /**
  22791. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22792. */
  22793. uvs: Nullable<FloatArray>;
  22794. /**
  22795. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22796. */
  22797. uvs2: Nullable<FloatArray>;
  22798. /**
  22799. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22800. */
  22801. uvs3: Nullable<FloatArray>;
  22802. /**
  22803. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22804. */
  22805. uvs4: Nullable<FloatArray>;
  22806. /**
  22807. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22808. */
  22809. uvs5: Nullable<FloatArray>;
  22810. /**
  22811. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22812. */
  22813. uvs6: Nullable<FloatArray>;
  22814. /**
  22815. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22816. */
  22817. colors: Nullable<FloatArray>;
  22818. /**
  22819. * 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).
  22820. */
  22821. matricesIndices: Nullable<FloatArray>;
  22822. /**
  22823. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22824. */
  22825. matricesWeights: Nullable<FloatArray>;
  22826. /**
  22827. * An array extending the number of possible indices
  22828. */
  22829. matricesIndicesExtra: Nullable<FloatArray>;
  22830. /**
  22831. * An array extending the number of possible weights when the number of indices is extended
  22832. */
  22833. matricesWeightsExtra: Nullable<FloatArray>;
  22834. /**
  22835. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22836. */
  22837. indices: Nullable<IndicesArray>;
  22838. /**
  22839. * Uses the passed data array to set the set the values for the specified kind of data
  22840. * @param data a linear array of floating numbers
  22841. * @param kind the type of data that is being set, eg positions, colors etc
  22842. */
  22843. set(data: FloatArray, kind: string): void;
  22844. /**
  22845. * Associates the vertexData to the passed Mesh.
  22846. * Sets it as updatable or not (default `false`)
  22847. * @param mesh the mesh the vertexData is applied to
  22848. * @param updatable when used and having the value true allows new data to update the vertexData
  22849. * @returns the VertexData
  22850. */
  22851. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22852. /**
  22853. * Associates the vertexData to the passed Geometry.
  22854. * Sets it as updatable or not (default `false`)
  22855. * @param geometry the geometry the vertexData is applied to
  22856. * @param updatable when used and having the value true allows new data to update the vertexData
  22857. * @returns VertexData
  22858. */
  22859. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22860. /**
  22861. * Updates the associated mesh
  22862. * @param mesh the mesh to be updated
  22863. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22864. * @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
  22865. * @returns VertexData
  22866. */
  22867. updateMesh(mesh: Mesh): VertexData;
  22868. /**
  22869. * Updates the associated geometry
  22870. * @param geometry the geometry to be updated
  22871. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22872. * @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
  22873. * @returns VertexData.
  22874. */
  22875. updateGeometry(geometry: Geometry): VertexData;
  22876. private _applyTo;
  22877. private _update;
  22878. /**
  22879. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22880. * @param matrix the transforming matrix
  22881. * @returns the VertexData
  22882. */
  22883. transform(matrix: Matrix): VertexData;
  22884. /**
  22885. * Merges the passed VertexData into the current one
  22886. * @param other the VertexData to be merged into the current one
  22887. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22888. * @returns the modified VertexData
  22889. */
  22890. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22891. private _mergeElement;
  22892. private _validate;
  22893. /**
  22894. * Serializes the VertexData
  22895. * @returns a serialized object
  22896. */
  22897. serialize(): any;
  22898. /**
  22899. * Extracts the vertexData from a mesh
  22900. * @param mesh the mesh from which to extract the VertexData
  22901. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22902. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22903. * @returns the object VertexData associated to the passed mesh
  22904. */
  22905. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22906. /**
  22907. * Extracts the vertexData from the geometry
  22908. * @param geometry the geometry from which to extract the VertexData
  22909. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22910. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22911. * @returns the object VertexData associated to the passed mesh
  22912. */
  22913. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22914. private static _ExtractFrom;
  22915. /**
  22916. * Creates the VertexData for a Ribbon
  22917. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22918. * * pathArray array of paths, each of which an array of successive Vector3
  22919. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22920. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22921. * * 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
  22922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22923. * * 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)
  22924. * * 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)
  22925. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22926. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22927. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22928. * @returns the VertexData of the ribbon
  22929. */
  22930. static CreateRibbon(options: {
  22931. pathArray: Vector3[][];
  22932. closeArray?: boolean;
  22933. closePath?: boolean;
  22934. offset?: number;
  22935. sideOrientation?: number;
  22936. frontUVs?: Vector4;
  22937. backUVs?: Vector4;
  22938. invertUV?: boolean;
  22939. uvs?: Vector2[];
  22940. colors?: Color4[];
  22941. }): VertexData;
  22942. /**
  22943. * Creates the VertexData for a box
  22944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22945. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22946. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22947. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22948. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22949. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22950. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22952. * * 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)
  22953. * * 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)
  22954. * @returns the VertexData of the box
  22955. */
  22956. static CreateBox(options: {
  22957. size?: number;
  22958. width?: number;
  22959. height?: number;
  22960. depth?: number;
  22961. faceUV?: Vector4[];
  22962. faceColors?: Color4[];
  22963. sideOrientation?: number;
  22964. frontUVs?: Vector4;
  22965. backUVs?: Vector4;
  22966. }): VertexData;
  22967. /**
  22968. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22969. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22970. * * segments sets the number of horizontal strips optional, default 32
  22971. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22972. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22973. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22974. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22975. * * 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
  22976. * * 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
  22977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22978. * * 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)
  22979. * * 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)
  22980. * @returns the VertexData of the ellipsoid
  22981. */
  22982. static CreateSphere(options: {
  22983. segments?: number;
  22984. diameter?: number;
  22985. diameterX?: number;
  22986. diameterY?: number;
  22987. diameterZ?: number;
  22988. arc?: number;
  22989. slice?: number;
  22990. sideOrientation?: number;
  22991. frontUVs?: Vector4;
  22992. backUVs?: Vector4;
  22993. }): VertexData;
  22994. /**
  22995. * Creates the VertexData for a cylinder, cone or prism
  22996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22997. * * height sets the height (y direction) of the cylinder, optional, default 2
  22998. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22999. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23000. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23001. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23002. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23003. * * 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
  23004. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23005. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23006. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23007. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23009. * * 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)
  23010. * * 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)
  23011. * @returns the VertexData of the cylinder, cone or prism
  23012. */
  23013. static CreateCylinder(options: {
  23014. height?: number;
  23015. diameterTop?: number;
  23016. diameterBottom?: number;
  23017. diameter?: number;
  23018. tessellation?: number;
  23019. subdivisions?: number;
  23020. arc?: number;
  23021. faceColors?: Color4[];
  23022. faceUV?: Vector4[];
  23023. hasRings?: boolean;
  23024. enclose?: boolean;
  23025. sideOrientation?: number;
  23026. frontUVs?: Vector4;
  23027. backUVs?: Vector4;
  23028. }): VertexData;
  23029. /**
  23030. * Creates the VertexData for a torus
  23031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23032. * * diameter the diameter of the torus, optional default 1
  23033. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23034. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23036. * * 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)
  23037. * * 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)
  23038. * @returns the VertexData of the torus
  23039. */
  23040. static CreateTorus(options: {
  23041. diameter?: number;
  23042. thickness?: number;
  23043. tessellation?: number;
  23044. sideOrientation?: number;
  23045. frontUVs?: Vector4;
  23046. backUVs?: Vector4;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData of the LineSystem
  23050. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23051. * - lines an array of lines, each line being an array of successive Vector3
  23052. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23053. * @returns the VertexData of the LineSystem
  23054. */
  23055. static CreateLineSystem(options: {
  23056. lines: Vector3[][];
  23057. colors?: Nullable<Color4[][]>;
  23058. }): VertexData;
  23059. /**
  23060. * Create the VertexData for a DashedLines
  23061. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23062. * - points an array successive Vector3
  23063. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23064. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23065. * - dashNb the intended total number of dashes, optional, default 200
  23066. * @returns the VertexData for the DashedLines
  23067. */
  23068. static CreateDashedLines(options: {
  23069. points: Vector3[];
  23070. dashSize?: number;
  23071. gapSize?: number;
  23072. dashNb?: number;
  23073. }): VertexData;
  23074. /**
  23075. * Creates the VertexData for a Ground
  23076. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23077. * - width the width (x direction) of the ground, optional, default 1
  23078. * - height the height (z direction) of the ground, optional, default 1
  23079. * - subdivisions the number of subdivisions per side, optional, default 1
  23080. * @returns the VertexData of the Ground
  23081. */
  23082. static CreateGround(options: {
  23083. width?: number;
  23084. height?: number;
  23085. subdivisions?: number;
  23086. subdivisionsX?: number;
  23087. subdivisionsY?: number;
  23088. }): VertexData;
  23089. /**
  23090. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23091. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23092. * * xmin the ground minimum X coordinate, optional, default -1
  23093. * * zmin the ground minimum Z coordinate, optional, default -1
  23094. * * xmax the ground maximum X coordinate, optional, default 1
  23095. * * zmax the ground maximum Z coordinate, optional, default 1
  23096. * * 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}
  23097. * * 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}
  23098. * @returns the VertexData of the TiledGround
  23099. */
  23100. static CreateTiledGround(options: {
  23101. xmin: number;
  23102. zmin: number;
  23103. xmax: number;
  23104. zmax: number;
  23105. subdivisions?: {
  23106. w: number;
  23107. h: number;
  23108. };
  23109. precision?: {
  23110. w: number;
  23111. h: number;
  23112. };
  23113. }): VertexData;
  23114. /**
  23115. * Creates the VertexData of the Ground designed from a heightmap
  23116. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23117. * * width the width (x direction) of the ground
  23118. * * height the height (z direction) of the ground
  23119. * * subdivisions the number of subdivisions per side
  23120. * * minHeight the minimum altitude on the ground, optional, default 0
  23121. * * maxHeight the maximum altitude on the ground, optional default 1
  23122. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23123. * * buffer the array holding the image color data
  23124. * * bufferWidth the width of image
  23125. * * bufferHeight the height of image
  23126. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23127. * @returns the VertexData of the Ground designed from a heightmap
  23128. */
  23129. static CreateGroundFromHeightMap(options: {
  23130. width: number;
  23131. height: number;
  23132. subdivisions: number;
  23133. minHeight: number;
  23134. maxHeight: number;
  23135. colorFilter: Color3;
  23136. buffer: Uint8Array;
  23137. bufferWidth: number;
  23138. bufferHeight: number;
  23139. alphaFilter: number;
  23140. }): VertexData;
  23141. /**
  23142. * Creates the VertexData for a Plane
  23143. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23144. * * size sets the width and height of the plane to the value of size, optional default 1
  23145. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23146. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23148. * * 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)
  23149. * * 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)
  23150. * @returns the VertexData of the box
  23151. */
  23152. static CreatePlane(options: {
  23153. size?: number;
  23154. width?: number;
  23155. height?: number;
  23156. sideOrientation?: number;
  23157. frontUVs?: Vector4;
  23158. backUVs?: Vector4;
  23159. }): VertexData;
  23160. /**
  23161. * Creates the VertexData of the Disc or regular Polygon
  23162. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23163. * * radius the radius of the disc, optional default 0.5
  23164. * * tessellation the number of polygon sides, optional, default 64
  23165. * * 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
  23166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23167. * * 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)
  23168. * * 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)
  23169. * @returns the VertexData of the box
  23170. */
  23171. static CreateDisc(options: {
  23172. radius?: number;
  23173. tessellation?: number;
  23174. arc?: number;
  23175. sideOrientation?: number;
  23176. frontUVs?: Vector4;
  23177. backUVs?: Vector4;
  23178. }): VertexData;
  23179. /**
  23180. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23181. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23182. * @param polygon a mesh built from polygonTriangulation.build()
  23183. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23184. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23185. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23186. * @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)
  23187. * @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)
  23188. * @returns the VertexData of the Polygon
  23189. */
  23190. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23191. /**
  23192. * Creates the VertexData of the IcoSphere
  23193. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23194. * * radius the radius of the IcoSphere, optional default 1
  23195. * * radiusX allows stretching in the x direction, optional, default radius
  23196. * * radiusY allows stretching in the y direction, optional, default radius
  23197. * * radiusZ allows stretching in the z direction, optional, default radius
  23198. * * flat when true creates a flat shaded mesh, optional, default true
  23199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23201. * * 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)
  23202. * * 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)
  23203. * @returns the VertexData of the IcoSphere
  23204. */
  23205. static CreateIcoSphere(options: {
  23206. radius?: number;
  23207. radiusX?: number;
  23208. radiusY?: number;
  23209. radiusZ?: number;
  23210. flat?: boolean;
  23211. subdivisions?: number;
  23212. sideOrientation?: number;
  23213. frontUVs?: Vector4;
  23214. backUVs?: Vector4;
  23215. }): VertexData;
  23216. /**
  23217. * Creates the VertexData for a Polyhedron
  23218. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23219. * * type provided types are:
  23220. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23221. * * 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)
  23222. * * size the size of the IcoSphere, optional default 1
  23223. * * sizeX allows stretching in the x direction, optional, default size
  23224. * * sizeY allows stretching in the y direction, optional, default size
  23225. * * sizeZ allows stretching in the z direction, optional, default size
  23226. * * 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
  23227. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23228. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23229. * * flat when true creates a flat shaded mesh, optional, default true
  23230. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23232. * * 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)
  23233. * * 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)
  23234. * @returns the VertexData of the Polyhedron
  23235. */
  23236. static CreatePolyhedron(options: {
  23237. type?: number;
  23238. size?: number;
  23239. sizeX?: number;
  23240. sizeY?: number;
  23241. sizeZ?: number;
  23242. custom?: any;
  23243. faceUV?: Vector4[];
  23244. faceColors?: Color4[];
  23245. flat?: boolean;
  23246. sideOrientation?: number;
  23247. frontUVs?: Vector4;
  23248. backUVs?: Vector4;
  23249. }): VertexData;
  23250. /**
  23251. * Creates the VertexData for a TorusKnot
  23252. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23253. * * radius the radius of the torus knot, optional, default 2
  23254. * * tube the thickness of the tube, optional, default 0.5
  23255. * * radialSegments the number of sides on each tube segments, optional, default 32
  23256. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23257. * * p the number of windings around the z axis, optional, default 2
  23258. * * q the number of windings around the x axis, optional, default 3
  23259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23260. * * 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)
  23261. * * 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)
  23262. * @returns the VertexData of the Torus Knot
  23263. */
  23264. static CreateTorusKnot(options: {
  23265. radius?: number;
  23266. tube?: number;
  23267. radialSegments?: number;
  23268. tubularSegments?: number;
  23269. p?: number;
  23270. q?: number;
  23271. sideOrientation?: number;
  23272. frontUVs?: Vector4;
  23273. backUVs?: Vector4;
  23274. }): VertexData;
  23275. /**
  23276. * Compute normals for given positions and indices
  23277. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23278. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23279. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23280. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23281. * * facetNormals : optional array of facet normals (vector3)
  23282. * * facetPositions : optional array of facet positions (vector3)
  23283. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23284. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23285. * * bInfo : optional bounding info, required for facetPartitioning computation
  23286. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23287. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23288. * * useRightHandedSystem: optional boolean to for right handed system computation
  23289. * * depthSort : optional boolean to enable the facet depth sort computation
  23290. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23291. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23292. */
  23293. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23294. facetNormals?: any;
  23295. facetPositions?: any;
  23296. facetPartitioning?: any;
  23297. ratio?: number;
  23298. bInfo?: any;
  23299. bbSize?: Vector3;
  23300. subDiv?: any;
  23301. useRightHandedSystem?: boolean;
  23302. depthSort?: boolean;
  23303. distanceTo?: Vector3;
  23304. depthSortedFacets?: any;
  23305. }): void;
  23306. /** @hidden */
  23307. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23308. /**
  23309. * Applies VertexData created from the imported parameters to the geometry
  23310. * @param parsedVertexData the parsed data from an imported file
  23311. * @param geometry the geometry to apply the VertexData to
  23312. */
  23313. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23314. }
  23315. }
  23316. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23317. import { Nullable } from "babylonjs/types";
  23318. import { Scene } from "babylonjs/scene";
  23319. import { Vector4 } from "babylonjs/Maths/math";
  23320. import { Mesh } from "babylonjs/Meshes/mesh";
  23321. /**
  23322. * Class containing static functions to help procedurally build meshes
  23323. */
  23324. export class DiscBuilder {
  23325. /**
  23326. * Creates a plane polygonal mesh. By default, this is a disc
  23327. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23328. * * 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
  23329. * * 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
  23330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23333. * @param name defines the name of the mesh
  23334. * @param options defines the options used to create the mesh
  23335. * @param scene defines the hosting scene
  23336. * @returns the plane polygonal mesh
  23337. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23338. */
  23339. static CreateDisc(name: string, options: {
  23340. radius?: number;
  23341. tessellation?: number;
  23342. arc?: number;
  23343. updatable?: boolean;
  23344. sideOrientation?: number;
  23345. frontUVs?: Vector4;
  23346. backUVs?: Vector4;
  23347. }, scene?: Nullable<Scene>): Mesh;
  23348. }
  23349. }
  23350. declare module "babylonjs/Particles/solidParticleSystem" {
  23351. import { Vector3 } from "babylonjs/Maths/math";
  23352. import { Mesh } from "babylonjs/Meshes/mesh";
  23353. import { Scene, IDisposable } from "babylonjs/scene";
  23354. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23355. /**
  23356. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23357. *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.
  23358. * The SPS is also a particle system. It provides some methods to manage the particles.
  23359. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23360. *
  23361. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23362. */
  23363. export class SolidParticleSystem implements IDisposable {
  23364. /**
  23365. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23366. * Example : var p = SPS.particles[i];
  23367. */
  23368. particles: SolidParticle[];
  23369. /**
  23370. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23371. */
  23372. nbParticles: number;
  23373. /**
  23374. * If the particles must ever face the camera (default false). Useful for planar particles.
  23375. */
  23376. billboard: boolean;
  23377. /**
  23378. * Recompute normals when adding a shape
  23379. */
  23380. recomputeNormals: boolean;
  23381. /**
  23382. * This a counter ofr your own usage. It's not set by any SPS functions.
  23383. */
  23384. counter: number;
  23385. /**
  23386. * The SPS name. This name is also given to the underlying mesh.
  23387. */
  23388. name: string;
  23389. /**
  23390. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23391. */
  23392. mesh: Mesh;
  23393. /**
  23394. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23395. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23396. */
  23397. vars: any;
  23398. /**
  23399. * This array is populated when the SPS is set as 'pickable'.
  23400. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23401. * Each element of this array is an object `{idx: int, faceId: int}`.
  23402. * `idx` is the picked particle index in the `SPS.particles` array
  23403. * `faceId` is the picked face index counted within this particle.
  23404. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23405. */
  23406. pickedParticles: {
  23407. idx: number;
  23408. faceId: number;
  23409. }[];
  23410. /**
  23411. * This array is populated when `enableDepthSort` is set to true.
  23412. * Each element of this array is an instance of the class DepthSortedParticle.
  23413. */
  23414. depthSortedParticles: DepthSortedParticle[];
  23415. /**
  23416. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23417. * @hidden
  23418. */
  23419. _bSphereOnly: boolean;
  23420. /**
  23421. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23422. * @hidden
  23423. */
  23424. _bSphereRadiusFactor: number;
  23425. private _scene;
  23426. private _positions;
  23427. private _indices;
  23428. private _normals;
  23429. private _colors;
  23430. private _uvs;
  23431. private _indices32;
  23432. private _positions32;
  23433. private _normals32;
  23434. private _fixedNormal32;
  23435. private _colors32;
  23436. private _uvs32;
  23437. private _index;
  23438. private _updatable;
  23439. private _pickable;
  23440. private _isVisibilityBoxLocked;
  23441. private _alwaysVisible;
  23442. private _depthSort;
  23443. private _shapeCounter;
  23444. private _copy;
  23445. private _color;
  23446. private _computeParticleColor;
  23447. private _computeParticleTexture;
  23448. private _computeParticleRotation;
  23449. private _computeParticleVertex;
  23450. private _computeBoundingBox;
  23451. private _depthSortParticles;
  23452. private _camera;
  23453. private _mustUnrotateFixedNormals;
  23454. private _particlesIntersect;
  23455. private _needs32Bits;
  23456. /**
  23457. * Creates a SPS (Solid Particle System) object.
  23458. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23459. * @param scene (Scene) is the scene in which the SPS is added.
  23460. * @param options defines the options of the sps e.g.
  23461. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23462. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23463. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23464. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23465. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23466. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23467. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23468. */
  23469. constructor(name: string, scene: Scene, options?: {
  23470. updatable?: boolean;
  23471. isPickable?: boolean;
  23472. enableDepthSort?: boolean;
  23473. particleIntersection?: boolean;
  23474. boundingSphereOnly?: boolean;
  23475. bSphereRadiusFactor?: number;
  23476. });
  23477. /**
  23478. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23479. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23480. * @returns the created mesh
  23481. */
  23482. buildMesh(): Mesh;
  23483. /**
  23484. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23485. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23486. * Thus the particles generated from `digest()` have their property `position` set yet.
  23487. * @param mesh ( Mesh ) is the mesh to be digested
  23488. * @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
  23489. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23490. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23491. * @returns the current SPS
  23492. */
  23493. digest(mesh: Mesh, options?: {
  23494. facetNb?: number;
  23495. number?: number;
  23496. delta?: number;
  23497. }): SolidParticleSystem;
  23498. private _unrotateFixedNormals;
  23499. private _resetCopy;
  23500. private _meshBuilder;
  23501. private _posToShape;
  23502. private _uvsToShapeUV;
  23503. private _addParticle;
  23504. /**
  23505. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23506. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23507. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23508. * @param nb (positive integer) the number of particles to be created from this model
  23509. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23510. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23511. * @returns the number of shapes in the system
  23512. */
  23513. addShape(mesh: Mesh, nb: number, options?: {
  23514. positionFunction?: any;
  23515. vertexFunction?: any;
  23516. }): number;
  23517. private _rebuildParticle;
  23518. /**
  23519. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23520. * @returns the SPS.
  23521. */
  23522. rebuildMesh(): SolidParticleSystem;
  23523. /**
  23524. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23525. * This method calls `updateParticle()` for each particle of the SPS.
  23526. * For an animated SPS, it is usually called within the render loop.
  23527. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23528. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23529. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23530. * @returns the SPS.
  23531. */
  23532. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23533. /**
  23534. * Disposes the SPS.
  23535. */
  23536. dispose(): void;
  23537. /**
  23538. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23539. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23540. * @returns the SPS.
  23541. */
  23542. refreshVisibleSize(): SolidParticleSystem;
  23543. /**
  23544. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23545. * @param size the size (float) of the visibility box
  23546. * note : this doesn't lock the SPS mesh bounding box.
  23547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23548. */
  23549. setVisibilityBox(size: number): void;
  23550. /**
  23551. * Gets whether the SPS as always visible or not
  23552. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23553. */
  23554. /**
  23555. * Sets the SPS as always visible or not
  23556. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23557. */
  23558. isAlwaysVisible: boolean;
  23559. /**
  23560. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23562. */
  23563. /**
  23564. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23565. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23566. */
  23567. isVisibilityBoxLocked: boolean;
  23568. /**
  23569. * Tells to `setParticles()` to compute the particle rotations or not.
  23570. * Default value : true. The SPS is faster when it's set to false.
  23571. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23572. */
  23573. /**
  23574. * Gets if `setParticles()` computes the particle rotations or not.
  23575. * Default value : true. The SPS is faster when it's set to false.
  23576. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23577. */
  23578. computeParticleRotation: boolean;
  23579. /**
  23580. * Tells to `setParticles()` to compute the particle colors or not.
  23581. * Default value : true. The SPS is faster when it's set to false.
  23582. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23583. */
  23584. /**
  23585. * Gets if `setParticles()` computes the particle colors or not.
  23586. * Default value : true. The SPS is faster when it's set to false.
  23587. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23588. */
  23589. computeParticleColor: boolean;
  23590. /**
  23591. * Gets if `setParticles()` computes the particle textures or not.
  23592. * Default value : true. The SPS is faster when it's set to false.
  23593. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23594. */
  23595. computeParticleTexture: boolean;
  23596. /**
  23597. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23598. * Default value : false. The SPS is faster when it's set to false.
  23599. * Note : the particle custom vertex positions aren't stored values.
  23600. */
  23601. /**
  23602. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23603. * Default value : false. The SPS is faster when it's set to false.
  23604. * Note : the particle custom vertex positions aren't stored values.
  23605. */
  23606. computeParticleVertex: boolean;
  23607. /**
  23608. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23609. */
  23610. /**
  23611. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23612. */
  23613. computeBoundingBox: boolean;
  23614. /**
  23615. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23616. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23617. * Default : `true`
  23618. */
  23619. /**
  23620. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23621. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23622. * Default : `true`
  23623. */
  23624. depthSortParticles: boolean;
  23625. /**
  23626. * This function does nothing. It may be overwritten to set all the particle first values.
  23627. * The SPS doesn't call this function, you may have to call it by your own.
  23628. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23629. */
  23630. initParticles(): void;
  23631. /**
  23632. * This function does nothing. It may be overwritten to recycle a particle.
  23633. * The SPS doesn't call this function, you may have to call it by your own.
  23634. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23635. * @param particle The particle to recycle
  23636. * @returns the recycled particle
  23637. */
  23638. recycleParticle(particle: SolidParticle): SolidParticle;
  23639. /**
  23640. * Updates a particle : this function should be overwritten by the user.
  23641. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23642. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23643. * @example : just set a particle position or velocity and recycle conditions
  23644. * @param particle The particle to update
  23645. * @returns the updated particle
  23646. */
  23647. updateParticle(particle: SolidParticle): SolidParticle;
  23648. /**
  23649. * Updates a vertex of a particle : it can be overwritten by the user.
  23650. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23651. * @param particle the current particle
  23652. * @param vertex the current index of the current particle
  23653. * @param pt the index of the current vertex in the particle shape
  23654. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23655. * @example : just set a vertex particle position
  23656. * @returns the updated vertex
  23657. */
  23658. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23659. /**
  23660. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23661. * This does nothing and may be overwritten by the user.
  23662. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23663. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23664. * @param update the boolean update value actually passed to setParticles()
  23665. */
  23666. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23667. /**
  23668. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23669. * This will be passed three parameters.
  23670. * This does nothing and may be overwritten by the user.
  23671. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23672. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23673. * @param update the boolean update value actually passed to setParticles()
  23674. */
  23675. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23676. }
  23677. }
  23678. declare module "babylonjs/Particles/solidParticle" {
  23679. import { Nullable } from "babylonjs/types";
  23680. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23681. import { Mesh } from "babylonjs/Meshes/mesh";
  23682. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23683. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23684. /**
  23685. * Represents one particle of a solid particle system.
  23686. */
  23687. export class SolidParticle {
  23688. /**
  23689. * particle global index
  23690. */
  23691. idx: number;
  23692. /**
  23693. * The color of the particle
  23694. */
  23695. color: Nullable<Color4>;
  23696. /**
  23697. * The world space position of the particle.
  23698. */
  23699. position: Vector3;
  23700. /**
  23701. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23702. */
  23703. rotation: Vector3;
  23704. /**
  23705. * The world space rotation quaternion of the particle.
  23706. */
  23707. rotationQuaternion: Nullable<Quaternion>;
  23708. /**
  23709. * The scaling of the particle.
  23710. */
  23711. scaling: Vector3;
  23712. /**
  23713. * The uvs of the particle.
  23714. */
  23715. uvs: Vector4;
  23716. /**
  23717. * The current speed of the particle.
  23718. */
  23719. velocity: Vector3;
  23720. /**
  23721. * The pivot point in the particle local space.
  23722. */
  23723. pivot: Vector3;
  23724. /**
  23725. * Must the particle be translated from its pivot point in its local space ?
  23726. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23727. * Default : false
  23728. */
  23729. translateFromPivot: boolean;
  23730. /**
  23731. * Is the particle active or not ?
  23732. */
  23733. alive: boolean;
  23734. /**
  23735. * Is the particle visible or not ?
  23736. */
  23737. isVisible: boolean;
  23738. /**
  23739. * Index of this particle in the global "positions" array (Internal use)
  23740. * @hidden
  23741. */
  23742. _pos: number;
  23743. /**
  23744. * @hidden Index of this particle in the global "indices" array (Internal use)
  23745. */
  23746. _ind: number;
  23747. /**
  23748. * @hidden ModelShape of this particle (Internal use)
  23749. */
  23750. _model: ModelShape;
  23751. /**
  23752. * ModelShape id of this particle
  23753. */
  23754. shapeId: number;
  23755. /**
  23756. * Index of the particle in its shape id (Internal use)
  23757. */
  23758. idxInShape: number;
  23759. /**
  23760. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23761. */
  23762. _modelBoundingInfo: BoundingInfo;
  23763. /**
  23764. * @hidden Particle BoundingInfo object (Internal use)
  23765. */
  23766. _boundingInfo: BoundingInfo;
  23767. /**
  23768. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23769. */
  23770. _sps: SolidParticleSystem;
  23771. /**
  23772. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23773. */
  23774. _stillInvisible: boolean;
  23775. /**
  23776. * @hidden Last computed particle rotation matrix
  23777. */
  23778. _rotationMatrix: number[];
  23779. /**
  23780. * Parent particle Id, if any.
  23781. * Default null.
  23782. */
  23783. parentId: Nullable<number>;
  23784. /**
  23785. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23786. * The possible values are :
  23787. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23788. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23789. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23790. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23791. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23792. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23793. * */
  23794. cullingStrategy: number;
  23795. /**
  23796. * @hidden Internal global position in the SPS.
  23797. */
  23798. _globalPosition: Vector3;
  23799. /**
  23800. * Creates a Solid Particle object.
  23801. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23802. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23803. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23804. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23805. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23806. * @param shapeId (integer) is the model shape identifier in the SPS.
  23807. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23808. * @param sps defines the sps it is associated to
  23809. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23810. */
  23811. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23812. /**
  23813. * Legacy support, changed scale to scaling
  23814. */
  23815. /**
  23816. * Legacy support, changed scale to scaling
  23817. */
  23818. scale: Vector3;
  23819. /**
  23820. * Legacy support, changed quaternion to rotationQuaternion
  23821. */
  23822. /**
  23823. * Legacy support, changed quaternion to rotationQuaternion
  23824. */
  23825. quaternion: Nullable<Quaternion>;
  23826. /**
  23827. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23828. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23829. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23830. * @returns true if it intersects
  23831. */
  23832. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23833. /**
  23834. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23835. * A particle is in the frustum if its bounding box intersects the frustum
  23836. * @param frustumPlanes defines the frustum to test
  23837. * @returns true if the particle is in the frustum planes
  23838. */
  23839. isInFrustum(frustumPlanes: Plane[]): boolean;
  23840. /**
  23841. * get the rotation matrix of the particle
  23842. * @hidden
  23843. */
  23844. getRotationMatrix(m: Matrix): void;
  23845. }
  23846. /**
  23847. * Represents the shape of the model used by one particle of a solid particle system.
  23848. * SPS internal tool, don't use it manually.
  23849. */
  23850. export class ModelShape {
  23851. /**
  23852. * The shape id
  23853. * @hidden
  23854. */
  23855. shapeID: number;
  23856. /**
  23857. * flat array of model positions (internal use)
  23858. * @hidden
  23859. */
  23860. _shape: Vector3[];
  23861. /**
  23862. * flat array of model UVs (internal use)
  23863. * @hidden
  23864. */
  23865. _shapeUV: number[];
  23866. /**
  23867. * length of the shape in the model indices array (internal use)
  23868. * @hidden
  23869. */
  23870. _indicesLength: number;
  23871. /**
  23872. * Custom position function (internal use)
  23873. * @hidden
  23874. */
  23875. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23876. /**
  23877. * Custom vertex function (internal use)
  23878. * @hidden
  23879. */
  23880. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23881. /**
  23882. * 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.
  23883. * SPS internal tool, don't use it manually.
  23884. * @hidden
  23885. */
  23886. 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>);
  23887. }
  23888. /**
  23889. * Represents a Depth Sorted Particle in the solid particle system.
  23890. */
  23891. export class DepthSortedParticle {
  23892. /**
  23893. * Index of the particle in the "indices" array
  23894. */
  23895. ind: number;
  23896. /**
  23897. * Length of the particle shape in the "indices" array
  23898. */
  23899. indicesLength: number;
  23900. /**
  23901. * Squared distance from the particle to the camera
  23902. */
  23903. sqDistance: number;
  23904. }
  23905. }
  23906. declare module "babylonjs/Meshes/abstractMesh" {
  23907. import { Observable } from "babylonjs/Misc/observable";
  23908. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23909. import { Camera } from "babylonjs/Cameras/camera";
  23910. import { Scene, IDisposable } from "babylonjs/scene";
  23911. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23912. import { Node } from "babylonjs/node";
  23913. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23914. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23916. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23917. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23918. import { Material } from "babylonjs/Materials/material";
  23919. import { Light } from "babylonjs/Lights/light";
  23920. import { Skeleton } from "babylonjs/Bones/skeleton";
  23921. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23922. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23923. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23924. import { Ray } from "babylonjs/Culling/ray";
  23925. import { Collider } from "babylonjs/Collisions/collider";
  23926. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23927. /**
  23928. * Class used to store all common mesh properties
  23929. */
  23930. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23931. /** No occlusion */
  23932. static OCCLUSION_TYPE_NONE: number;
  23933. /** Occlusion set to optimisitic */
  23934. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23935. /** Occlusion set to strict */
  23936. static OCCLUSION_TYPE_STRICT: number;
  23937. /** Use an accurante occlusion algorithm */
  23938. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23939. /** Use a conservative occlusion algorithm */
  23940. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23941. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23942. * Test order :
  23943. * Is the bounding sphere outside the frustum ?
  23944. * If not, are the bounding box vertices outside the frustum ?
  23945. * It not, then the cullable object is in the frustum.
  23946. */
  23947. static readonly CULLINGSTRATEGY_STANDARD: number;
  23948. /** Culling strategy : Bounding Sphere Only.
  23949. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23950. * It's also less accurate than the standard because some not visible objects can still be selected.
  23951. * Test : is the bounding sphere outside the frustum ?
  23952. * If not, then the cullable object is in the frustum.
  23953. */
  23954. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23955. /** Culling strategy : Optimistic Inclusion.
  23956. * This in an inclusion test first, then the standard exclusion test.
  23957. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23958. * 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.
  23959. * Anyway, it's as accurate as the standard strategy.
  23960. * Test :
  23961. * Is the cullable object bounding sphere center in the frustum ?
  23962. * If not, apply the default culling strategy.
  23963. */
  23964. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23965. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23966. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23967. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23968. * 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.
  23969. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23970. * Test :
  23971. * Is the cullable object bounding sphere center in the frustum ?
  23972. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23973. */
  23974. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23975. /**
  23976. * No billboard
  23977. */
  23978. static readonly BILLBOARDMODE_NONE: number;
  23979. /** Billboard on X axis */
  23980. static readonly BILLBOARDMODE_X: number;
  23981. /** Billboard on Y axis */
  23982. static readonly BILLBOARDMODE_Y: number;
  23983. /** Billboard on Z axis */
  23984. static readonly BILLBOARDMODE_Z: number;
  23985. /** Billboard on all axes */
  23986. static readonly BILLBOARDMODE_ALL: number;
  23987. private _facetData;
  23988. /**
  23989. * The culling strategy to use to check whether the mesh must be rendered or not.
  23990. * This value can be changed at any time and will be used on the next render mesh selection.
  23991. * The possible values are :
  23992. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23993. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23994. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23995. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23996. * Please read each static variable documentation to get details about the culling process.
  23997. * */
  23998. cullingStrategy: number;
  23999. /**
  24000. * Gets the number of facets in the mesh
  24001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24002. */
  24003. readonly facetNb: number;
  24004. /**
  24005. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24007. */
  24008. partitioningSubdivisions: number;
  24009. /**
  24010. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24011. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24013. */
  24014. partitioningBBoxRatio: number;
  24015. /**
  24016. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24017. * Works only for updatable meshes.
  24018. * Doesn't work with multi-materials
  24019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24020. */
  24021. mustDepthSortFacets: boolean;
  24022. /**
  24023. * The location (Vector3) where the facet depth sort must be computed from.
  24024. * By default, the active camera position.
  24025. * Used only when facet depth sort is enabled
  24026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24027. */
  24028. facetDepthSortFrom: Vector3;
  24029. /**
  24030. * gets a boolean indicating if facetData is enabled
  24031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24032. */
  24033. readonly isFacetDataEnabled: boolean;
  24034. /** @hidden */
  24035. _updateNonUniformScalingState(value: boolean): boolean;
  24036. /**
  24037. * An event triggered when this mesh collides with another one
  24038. */
  24039. onCollideObservable: Observable<AbstractMesh>;
  24040. private _onCollideObserver;
  24041. /** Set a function to call when this mesh collides with another one */
  24042. onCollide: () => void;
  24043. /**
  24044. * An event triggered when the collision's position changes
  24045. */
  24046. onCollisionPositionChangeObservable: Observable<Vector3>;
  24047. private _onCollisionPositionChangeObserver;
  24048. /** Set a function to call when the collision's position changes */
  24049. onCollisionPositionChange: () => void;
  24050. /**
  24051. * An event triggered when material is changed
  24052. */
  24053. onMaterialChangedObservable: Observable<AbstractMesh>;
  24054. /**
  24055. * Gets or sets the orientation for POV movement & rotation
  24056. */
  24057. definedFacingForward: boolean;
  24058. /** @hidden */
  24059. _occlusionQuery: Nullable<WebGLQuery>;
  24060. private _visibility;
  24061. /**
  24062. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24063. */
  24064. /**
  24065. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24066. */
  24067. visibility: number;
  24068. /** Gets or sets the alpha index used to sort transparent meshes
  24069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24070. */
  24071. alphaIndex: number;
  24072. /**
  24073. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24074. */
  24075. isVisible: boolean;
  24076. /**
  24077. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24078. */
  24079. isPickable: boolean;
  24080. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24081. showSubMeshesBoundingBox: boolean;
  24082. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24084. */
  24085. isBlocker: boolean;
  24086. /**
  24087. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24088. */
  24089. enablePointerMoveEvents: boolean;
  24090. /**
  24091. * Specifies the rendering group id for this mesh (0 by default)
  24092. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24093. */
  24094. renderingGroupId: number;
  24095. private _material;
  24096. /** Gets or sets current material */
  24097. material: Nullable<Material>;
  24098. private _receiveShadows;
  24099. /**
  24100. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24101. * @see http://doc.babylonjs.com/babylon101/shadows
  24102. */
  24103. receiveShadows: boolean;
  24104. /** Defines color to use when rendering outline */
  24105. outlineColor: Color3;
  24106. /** Define width to use when rendering outline */
  24107. outlineWidth: number;
  24108. /** Defines color to use when rendering overlay */
  24109. overlayColor: Color3;
  24110. /** Defines alpha to use when rendering overlay */
  24111. overlayAlpha: number;
  24112. private _hasVertexAlpha;
  24113. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24114. hasVertexAlpha: boolean;
  24115. private _useVertexColors;
  24116. /** 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) */
  24117. useVertexColors: boolean;
  24118. private _computeBonesUsingShaders;
  24119. /**
  24120. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24121. */
  24122. computeBonesUsingShaders: boolean;
  24123. private _numBoneInfluencers;
  24124. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24125. numBoneInfluencers: number;
  24126. private _applyFog;
  24127. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24128. applyFog: boolean;
  24129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24130. useOctreeForRenderingSelection: boolean;
  24131. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24132. useOctreeForPicking: boolean;
  24133. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24134. useOctreeForCollisions: boolean;
  24135. private _layerMask;
  24136. /**
  24137. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24138. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24139. */
  24140. layerMask: number;
  24141. /**
  24142. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24143. */
  24144. alwaysSelectAsActiveMesh: boolean;
  24145. /**
  24146. * Gets or sets the current action manager
  24147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24148. */
  24149. actionManager: Nullable<AbstractActionManager>;
  24150. private _checkCollisions;
  24151. private _collisionMask;
  24152. private _collisionGroup;
  24153. /**
  24154. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24156. */
  24157. ellipsoid: Vector3;
  24158. /**
  24159. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24161. */
  24162. ellipsoidOffset: Vector3;
  24163. private _collider;
  24164. private _oldPositionForCollisions;
  24165. private _diffPositionForCollisions;
  24166. /**
  24167. * Gets or sets a collision mask used to mask collisions (default is -1).
  24168. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24169. */
  24170. collisionMask: number;
  24171. /**
  24172. * Gets or sets the current collision group mask (-1 by default).
  24173. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24174. */
  24175. collisionGroup: number;
  24176. /**
  24177. * Defines edge width used when edgesRenderer is enabled
  24178. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24179. */
  24180. edgesWidth: number;
  24181. /**
  24182. * Defines edge color used when edgesRenderer is enabled
  24183. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24184. */
  24185. edgesColor: Color4;
  24186. /** @hidden */
  24187. _edgesRenderer: Nullable<IEdgesRenderer>;
  24188. /** @hidden */
  24189. _masterMesh: Nullable<AbstractMesh>;
  24190. /** @hidden */
  24191. _boundingInfo: Nullable<BoundingInfo>;
  24192. /** @hidden */
  24193. _renderId: number;
  24194. /**
  24195. * Gets or sets the list of subMeshes
  24196. * @see http://doc.babylonjs.com/how_to/multi_materials
  24197. */
  24198. subMeshes: SubMesh[];
  24199. /** @hidden */
  24200. _intersectionsInProgress: AbstractMesh[];
  24201. /** @hidden */
  24202. _unIndexed: boolean;
  24203. /** @hidden */
  24204. _lightSources: Light[];
  24205. /** @hidden */
  24206. readonly _positions: Nullable<Vector3[]>;
  24207. /** @hidden */
  24208. _waitingActions: any;
  24209. /** @hidden */
  24210. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24211. private _skeleton;
  24212. /** @hidden */
  24213. _bonesTransformMatrices: Nullable<Float32Array>;
  24214. /**
  24215. * Gets or sets a skeleton to apply skining transformations
  24216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24217. */
  24218. skeleton: Nullable<Skeleton>;
  24219. /**
  24220. * An event triggered when the mesh is rebuilt.
  24221. */
  24222. onRebuildObservable: Observable<AbstractMesh>;
  24223. /**
  24224. * Creates a new AbstractMesh
  24225. * @param name defines the name of the mesh
  24226. * @param scene defines the hosting scene
  24227. */
  24228. constructor(name: string, scene?: Nullable<Scene>);
  24229. /**
  24230. * Returns the string "AbstractMesh"
  24231. * @returns "AbstractMesh"
  24232. */
  24233. getClassName(): string;
  24234. /**
  24235. * Gets a string representation of the current mesh
  24236. * @param fullDetails defines a boolean indicating if full details must be included
  24237. * @returns a string representation of the current mesh
  24238. */
  24239. toString(fullDetails?: boolean): string;
  24240. /** @hidden */
  24241. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24242. /** @hidden */
  24243. _rebuild(): void;
  24244. /** @hidden */
  24245. _resyncLightSources(): void;
  24246. /** @hidden */
  24247. _resyncLighSource(light: Light): void;
  24248. /** @hidden */
  24249. _unBindEffect(): void;
  24250. /** @hidden */
  24251. _removeLightSource(light: Light): void;
  24252. private _markSubMeshesAsDirty;
  24253. /** @hidden */
  24254. _markSubMeshesAsLightDirty(): void;
  24255. /** @hidden */
  24256. _markSubMeshesAsAttributesDirty(): void;
  24257. /** @hidden */
  24258. _markSubMeshesAsMiscDirty(): void;
  24259. /**
  24260. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24261. */
  24262. scaling: Vector3;
  24263. /**
  24264. * Returns true if the mesh is blocked. Implemented by child classes
  24265. */
  24266. readonly isBlocked: boolean;
  24267. /**
  24268. * Returns the mesh itself by default. Implemented by child classes
  24269. * @param camera defines the camera to use to pick the right LOD level
  24270. * @returns the currentAbstractMesh
  24271. */
  24272. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24273. /**
  24274. * Returns 0 by default. Implemented by child classes
  24275. * @returns an integer
  24276. */
  24277. getTotalVertices(): number;
  24278. /**
  24279. * Returns a positive integer : the total number of indices in this mesh geometry.
  24280. * @returns the numner of indices or zero if the mesh has no geometry.
  24281. */
  24282. getTotalIndices(): number;
  24283. /**
  24284. * Returns null by default. Implemented by child classes
  24285. * @returns null
  24286. */
  24287. getIndices(): Nullable<IndicesArray>;
  24288. /**
  24289. * Returns the array of the requested vertex data kind. Implemented by child classes
  24290. * @param kind defines the vertex data kind to use
  24291. * @returns null
  24292. */
  24293. getVerticesData(kind: string): Nullable<FloatArray>;
  24294. /**
  24295. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24296. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24297. * Note that a new underlying VertexBuffer object is created each call.
  24298. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24299. * @param kind defines vertex data kind:
  24300. * * VertexBuffer.PositionKind
  24301. * * VertexBuffer.UVKind
  24302. * * VertexBuffer.UV2Kind
  24303. * * VertexBuffer.UV3Kind
  24304. * * VertexBuffer.UV4Kind
  24305. * * VertexBuffer.UV5Kind
  24306. * * VertexBuffer.UV6Kind
  24307. * * VertexBuffer.ColorKind
  24308. * * VertexBuffer.MatricesIndicesKind
  24309. * * VertexBuffer.MatricesIndicesExtraKind
  24310. * * VertexBuffer.MatricesWeightsKind
  24311. * * VertexBuffer.MatricesWeightsExtraKind
  24312. * @param data defines the data source
  24313. * @param updatable defines if the data must be flagged as updatable (or static)
  24314. * @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
  24315. * @returns the current mesh
  24316. */
  24317. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24318. /**
  24319. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24320. * If the mesh has no geometry, it is simply returned as it is.
  24321. * @param kind defines vertex data kind:
  24322. * * VertexBuffer.PositionKind
  24323. * * VertexBuffer.UVKind
  24324. * * VertexBuffer.UV2Kind
  24325. * * VertexBuffer.UV3Kind
  24326. * * VertexBuffer.UV4Kind
  24327. * * VertexBuffer.UV5Kind
  24328. * * VertexBuffer.UV6Kind
  24329. * * VertexBuffer.ColorKind
  24330. * * VertexBuffer.MatricesIndicesKind
  24331. * * VertexBuffer.MatricesIndicesExtraKind
  24332. * * VertexBuffer.MatricesWeightsKind
  24333. * * VertexBuffer.MatricesWeightsExtraKind
  24334. * @param data defines the data source
  24335. * @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
  24336. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24337. * @returns the current mesh
  24338. */
  24339. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24340. /**
  24341. * Sets the mesh indices,
  24342. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24343. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24344. * @param totalVertices Defines the total number of vertices
  24345. * @returns the current mesh
  24346. */
  24347. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24348. /**
  24349. * Gets a boolean indicating if specific vertex data is present
  24350. * @param kind defines the vertex data kind to use
  24351. * @returns true is data kind is present
  24352. */
  24353. isVerticesDataPresent(kind: string): boolean;
  24354. /**
  24355. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24356. * @returns a BoundingInfo
  24357. */
  24358. getBoundingInfo(): BoundingInfo;
  24359. /**
  24360. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24361. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24362. * @returns the current mesh
  24363. */
  24364. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24365. /**
  24366. * Overwrite the current bounding info
  24367. * @param boundingInfo defines the new bounding info
  24368. * @returns the current mesh
  24369. */
  24370. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24371. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24372. readonly useBones: boolean;
  24373. /** @hidden */
  24374. _preActivate(): void;
  24375. /** @hidden */
  24376. _preActivateForIntermediateRendering(renderId: number): void;
  24377. /** @hidden */
  24378. _activate(renderId: number): void;
  24379. /**
  24380. * Gets the current world matrix
  24381. * @returns a Matrix
  24382. */
  24383. getWorldMatrix(): Matrix;
  24384. /** @hidden */
  24385. _getWorldMatrixDeterminant(): number;
  24386. /**
  24387. * Perform relative position change from the point of view of behind the front of the mesh.
  24388. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24389. * Supports definition of mesh facing forward or backward
  24390. * @param amountRight defines the distance on the right axis
  24391. * @param amountUp defines the distance on the up axis
  24392. * @param amountForward defines the distance on the forward axis
  24393. * @returns the current mesh
  24394. */
  24395. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24396. /**
  24397. * Calculate relative position change from the point of view of behind the front of the mesh.
  24398. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24399. * Supports definition of mesh facing forward or backward
  24400. * @param amountRight defines the distance on the right axis
  24401. * @param amountUp defines the distance on the up axis
  24402. * @param amountForward defines the distance on the forward axis
  24403. * @returns the new displacement vector
  24404. */
  24405. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24406. /**
  24407. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24408. * Supports definition of mesh facing forward or backward
  24409. * @param flipBack defines the flip
  24410. * @param twirlClockwise defines the twirl
  24411. * @param tiltRight defines the tilt
  24412. * @returns the current mesh
  24413. */
  24414. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24415. /**
  24416. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24417. * Supports definition of mesh facing forward or backward.
  24418. * @param flipBack defines the flip
  24419. * @param twirlClockwise defines the twirl
  24420. * @param tiltRight defines the tilt
  24421. * @returns the new rotation vector
  24422. */
  24423. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24424. /**
  24425. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24426. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24427. * @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
  24428. * @returns the new bounding vectors
  24429. */
  24430. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24431. min: Vector3;
  24432. max: Vector3;
  24433. };
  24434. /**
  24435. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24436. * This means the mesh underlying bounding box and sphere are recomputed.
  24437. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24438. * @returns the current mesh
  24439. */
  24440. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24441. /** @hidden */
  24442. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24443. /** @hidden */
  24444. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24445. /** @hidden */
  24446. _updateBoundingInfo(): AbstractMesh;
  24447. /** @hidden */
  24448. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24449. /** @hidden */
  24450. protected _afterComputeWorldMatrix(): void;
  24451. /**
  24452. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24453. * A mesh is in the frustum if its bounding box intersects the frustum
  24454. * @param frustumPlanes defines the frustum to test
  24455. * @returns true if the mesh is in the frustum planes
  24456. */
  24457. isInFrustum(frustumPlanes: Plane[]): boolean;
  24458. /**
  24459. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24460. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24461. * @param frustumPlanes defines the frustum to test
  24462. * @returns true if the mesh is completely in the frustum planes
  24463. */
  24464. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24465. /**
  24466. * True if the mesh intersects another mesh or a SolidParticle object
  24467. * @param mesh defines a target mesh or SolidParticle to test
  24468. * @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)
  24469. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24470. * @returns true if there is an intersection
  24471. */
  24472. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24473. /**
  24474. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24475. * @param point defines the point to test
  24476. * @returns true if there is an intersection
  24477. */
  24478. intersectsPoint(point: Vector3): boolean;
  24479. /**
  24480. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24481. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24482. */
  24483. checkCollisions: boolean;
  24484. /**
  24485. * Gets Collider object used to compute collisions (not physics)
  24486. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24487. */
  24488. readonly collider: Collider;
  24489. /**
  24490. * Move the mesh using collision engine
  24491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24492. * @param displacement defines the requested displacement vector
  24493. * @returns the current mesh
  24494. */
  24495. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24496. private _onCollisionPositionChange;
  24497. /** @hidden */
  24498. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24499. /** @hidden */
  24500. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24501. /** @hidden */
  24502. _checkCollision(collider: Collider): AbstractMesh;
  24503. /** @hidden */
  24504. _generatePointsArray(): boolean;
  24505. /**
  24506. * Checks if the passed Ray intersects with the mesh
  24507. * @param ray defines the ray to use
  24508. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24510. * @returns the picking info
  24511. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24512. */
  24513. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24514. /**
  24515. * Clones the current mesh
  24516. * @param name defines the mesh name
  24517. * @param newParent defines the new mesh parent
  24518. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24519. * @returns the new mesh
  24520. */
  24521. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24522. /**
  24523. * Disposes all the submeshes of the current meshnp
  24524. * @returns the current mesh
  24525. */
  24526. releaseSubMeshes(): AbstractMesh;
  24527. /**
  24528. * Releases resources associated with this abstract mesh.
  24529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24531. */
  24532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24533. /**
  24534. * Adds the passed mesh as a child to the current mesh
  24535. * @param mesh defines the child mesh
  24536. * @returns the current mesh
  24537. */
  24538. addChild(mesh: AbstractMesh): AbstractMesh;
  24539. /**
  24540. * Removes the passed mesh from the current mesh children list
  24541. * @param mesh defines the child mesh
  24542. * @returns the current mesh
  24543. */
  24544. removeChild(mesh: AbstractMesh): AbstractMesh;
  24545. /** @hidden */
  24546. private _initFacetData;
  24547. /**
  24548. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24549. * This method can be called within the render loop.
  24550. * 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
  24551. * @returns the current mesh
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24553. */
  24554. updateFacetData(): AbstractMesh;
  24555. /**
  24556. * Returns the facetLocalNormals array.
  24557. * The normals are expressed in the mesh local spac
  24558. * @returns an array of Vector3
  24559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24560. */
  24561. getFacetLocalNormals(): Vector3[];
  24562. /**
  24563. * Returns the facetLocalPositions array.
  24564. * The facet positions are expressed in the mesh local space
  24565. * @returns an array of Vector3
  24566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24567. */
  24568. getFacetLocalPositions(): Vector3[];
  24569. /**
  24570. * Returns the facetLocalPartioning array
  24571. * @returns an array of array of numbers
  24572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24573. */
  24574. getFacetLocalPartitioning(): number[][];
  24575. /**
  24576. * Returns the i-th facet position in the world system.
  24577. * This method allocates a new Vector3 per call
  24578. * @param i defines the facet index
  24579. * @returns a new Vector3
  24580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24581. */
  24582. getFacetPosition(i: number): Vector3;
  24583. /**
  24584. * Sets the reference Vector3 with the i-th facet position in the world system
  24585. * @param i defines the facet index
  24586. * @param ref defines the target vector
  24587. * @returns the current mesh
  24588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24589. */
  24590. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24591. /**
  24592. * Returns the i-th facet normal in the world system.
  24593. * This method allocates a new Vector3 per call
  24594. * @param i defines the facet index
  24595. * @returns a new Vector3
  24596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24597. */
  24598. getFacetNormal(i: number): Vector3;
  24599. /**
  24600. * Sets the reference Vector3 with the i-th facet normal in the world system
  24601. * @param i defines the facet index
  24602. * @param ref defines the target vector
  24603. * @returns the current mesh
  24604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24605. */
  24606. getFacetNormalToRef(i: number, ref: Vector3): this;
  24607. /**
  24608. * 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)
  24609. * @param x defines x coordinate
  24610. * @param y defines y coordinate
  24611. * @param z defines z coordinate
  24612. * @returns the array of facet indexes
  24613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24614. */
  24615. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24616. /**
  24617. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24618. * @param projected sets as the (x,y,z) world projection on the facet
  24619. * @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
  24620. * @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
  24621. * @param x defines x coordinate
  24622. * @param y defines y coordinate
  24623. * @param z defines z coordinate
  24624. * @returns the face index if found (or null instead)
  24625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24626. */
  24627. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24628. /**
  24629. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24630. * @param projected sets as the (x,y,z) local projection on the facet
  24631. * @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
  24632. * @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
  24633. * @param x defines x coordinate
  24634. * @param y defines y coordinate
  24635. * @param z defines z coordinate
  24636. * @returns the face index if found (or null instead)
  24637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24638. */
  24639. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24640. /**
  24641. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24642. * @returns the parameters
  24643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24644. */
  24645. getFacetDataParameters(): any;
  24646. /**
  24647. * Disables the feature FacetData and frees the related memory
  24648. * @returns the current mesh
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24650. */
  24651. disableFacetData(): AbstractMesh;
  24652. /**
  24653. * Updates the AbstractMesh indices array
  24654. * @param indices defines the data source
  24655. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24656. * @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)
  24657. * @returns the current mesh
  24658. */
  24659. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24660. /**
  24661. * Creates new normals data for the mesh
  24662. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24663. * @returns the current mesh
  24664. */
  24665. createNormals(updatable: boolean): AbstractMesh;
  24666. /**
  24667. * Align the mesh with a normal
  24668. * @param normal defines the normal to use
  24669. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24670. * @returns the current mesh
  24671. */
  24672. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24673. /** @hidden */
  24674. _checkOcclusionQuery(): boolean;
  24675. }
  24676. }
  24677. declare module "babylonjs/Actions/actionEvent" {
  24678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24679. import { Nullable } from "babylonjs/types";
  24680. import { Sprite } from "babylonjs/Sprites/sprite";
  24681. import { Scene } from "babylonjs/scene";
  24682. import { Vector2 } from "babylonjs/Maths/math";
  24683. /**
  24684. * Interface used to define ActionEvent
  24685. */
  24686. export interface IActionEvent {
  24687. /** The mesh or sprite that triggered the action */
  24688. source: any;
  24689. /** The X mouse cursor position at the time of the event */
  24690. pointerX: number;
  24691. /** The Y mouse cursor position at the time of the event */
  24692. pointerY: number;
  24693. /** The mesh that is currently pointed at (can be null) */
  24694. meshUnderPointer: Nullable<AbstractMesh>;
  24695. /** the original (browser) event that triggered the ActionEvent */
  24696. sourceEvent?: any;
  24697. /** additional data for the event */
  24698. additionalData?: any;
  24699. }
  24700. /**
  24701. * ActionEvent is the event being sent when an action is triggered.
  24702. */
  24703. export class ActionEvent implements IActionEvent {
  24704. /** The mesh or sprite that triggered the action */
  24705. source: any;
  24706. /** The X mouse cursor position at the time of the event */
  24707. pointerX: number;
  24708. /** The Y mouse cursor position at the time of the event */
  24709. pointerY: number;
  24710. /** The mesh that is currently pointed at (can be null) */
  24711. meshUnderPointer: Nullable<AbstractMesh>;
  24712. /** the original (browser) event that triggered the ActionEvent */
  24713. sourceEvent?: any;
  24714. /** additional data for the event */
  24715. additionalData?: any;
  24716. /**
  24717. * Creates a new ActionEvent
  24718. * @param source The mesh or sprite that triggered the action
  24719. * @param pointerX The X mouse cursor position at the time of the event
  24720. * @param pointerY The Y mouse cursor position at the time of the event
  24721. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24722. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24723. * @param additionalData additional data for the event
  24724. */
  24725. constructor(
  24726. /** The mesh or sprite that triggered the action */
  24727. source: any,
  24728. /** The X mouse cursor position at the time of the event */
  24729. pointerX: number,
  24730. /** The Y mouse cursor position at the time of the event */
  24731. pointerY: number,
  24732. /** The mesh that is currently pointed at (can be null) */
  24733. meshUnderPointer: Nullable<AbstractMesh>,
  24734. /** the original (browser) event that triggered the ActionEvent */
  24735. sourceEvent?: any,
  24736. /** additional data for the event */
  24737. additionalData?: any);
  24738. /**
  24739. * Helper function to auto-create an ActionEvent from a source mesh.
  24740. * @param source The source mesh that triggered the event
  24741. * @param evt The original (browser) event
  24742. * @param additionalData additional data for the event
  24743. * @returns the new ActionEvent
  24744. */
  24745. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24746. /**
  24747. * Helper function to auto-create an ActionEvent from a source sprite
  24748. * @param source The source sprite that triggered the event
  24749. * @param scene Scene associated with the sprite
  24750. * @param evt The original (browser) event
  24751. * @param additionalData additional data for the event
  24752. * @returns the new ActionEvent
  24753. */
  24754. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24755. /**
  24756. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24757. * @param scene the scene where the event occurred
  24758. * @param evt The original (browser) event
  24759. * @returns the new ActionEvent
  24760. */
  24761. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24762. /**
  24763. * Helper function to auto-create an ActionEvent from a primitive
  24764. * @param prim defines the target primitive
  24765. * @param pointerPos defines the pointer position
  24766. * @param evt The original (browser) event
  24767. * @param additionalData additional data for the event
  24768. * @returns the new ActionEvent
  24769. */
  24770. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24771. }
  24772. }
  24773. declare module "babylonjs/Actions/abstractActionManager" {
  24774. import { IDisposable } from "babylonjs/scene";
  24775. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24776. import { IAction } from "babylonjs/Actions/action";
  24777. import { Nullable } from "babylonjs/types";
  24778. /**
  24779. * Abstract class used to decouple action Manager from scene and meshes.
  24780. * Do not instantiate.
  24781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24782. */
  24783. export abstract class AbstractActionManager implements IDisposable {
  24784. /** Gets the list of active triggers */
  24785. static Triggers: {
  24786. [key: string]: number;
  24787. };
  24788. /** Gets the cursor to use when hovering items */
  24789. hoverCursor: string;
  24790. /** Gets the list of actions */
  24791. actions: IAction[];
  24792. /**
  24793. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24794. */
  24795. isRecursive: boolean;
  24796. /**
  24797. * Releases all associated resources
  24798. */
  24799. abstract dispose(): void;
  24800. /**
  24801. * Does this action manager has pointer triggers
  24802. */
  24803. abstract readonly hasPointerTriggers: boolean;
  24804. /**
  24805. * Does this action manager has pick triggers
  24806. */
  24807. abstract readonly hasPickTriggers: boolean;
  24808. /**
  24809. * Process a specific trigger
  24810. * @param trigger defines the trigger to process
  24811. * @param evt defines the event details to be processed
  24812. */
  24813. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24814. /**
  24815. * Does this action manager handles actions of any of the given triggers
  24816. * @param triggers defines the triggers to be tested
  24817. * @return a boolean indicating whether one (or more) of the triggers is handled
  24818. */
  24819. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24820. /**
  24821. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24822. * speed.
  24823. * @param triggerA defines the trigger to be tested
  24824. * @param triggerB defines the trigger to be tested
  24825. * @return a boolean indicating whether one (or more) of the triggers is handled
  24826. */
  24827. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24828. /**
  24829. * Does this action manager handles actions of a given trigger
  24830. * @param trigger defines the trigger to be tested
  24831. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24832. * @return whether the trigger is handled
  24833. */
  24834. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24835. /**
  24836. * Serialize this manager to a JSON object
  24837. * @param name defines the property name to store this manager
  24838. * @returns a JSON representation of this manager
  24839. */
  24840. abstract serialize(name: string): any;
  24841. /**
  24842. * Registers an action to this action manager
  24843. * @param action defines the action to be registered
  24844. * @return the action amended (prepared) after registration
  24845. */
  24846. abstract registerAction(action: IAction): Nullable<IAction>;
  24847. /**
  24848. * Unregisters an action to this action manager
  24849. * @param action defines the action to be unregistered
  24850. * @return a boolean indicating whether the action has been unregistered
  24851. */
  24852. abstract unregisterAction(action: IAction): Boolean;
  24853. /**
  24854. * Does exist one action manager with at least one trigger
  24855. **/
  24856. static readonly HasTriggers: boolean;
  24857. /**
  24858. * Does exist one action manager with at least one pick trigger
  24859. **/
  24860. static readonly HasPickTriggers: boolean;
  24861. /**
  24862. * Does exist one action manager that handles actions of a given trigger
  24863. * @param trigger defines the trigger to be tested
  24864. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24865. **/
  24866. static HasSpecificTrigger(trigger: number): boolean;
  24867. }
  24868. }
  24869. declare module "babylonjs/node" {
  24870. import { Scene } from "babylonjs/scene";
  24871. import { Nullable } from "babylonjs/types";
  24872. import { Matrix } from "babylonjs/Maths/math";
  24873. import { Engine } from "babylonjs/Engines/engine";
  24874. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24875. import { Observable } from "babylonjs/Misc/observable";
  24876. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24877. import { Animatable } from "babylonjs/Animations/animatable";
  24878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24879. import { Animation } from "babylonjs/Animations/animation";
  24880. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24882. /**
  24883. * Defines how a node can be built from a string name.
  24884. */
  24885. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24886. /**
  24887. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24888. */
  24889. export class Node implements IBehaviorAware<Node> {
  24890. /** @hidden */
  24891. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24892. private static _NodeConstructors;
  24893. /**
  24894. * Add a new node constructor
  24895. * @param type defines the type name of the node to construct
  24896. * @param constructorFunc defines the constructor function
  24897. */
  24898. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24899. /**
  24900. * Returns a node constructor based on type name
  24901. * @param type defines the type name
  24902. * @param name defines the new node name
  24903. * @param scene defines the hosting scene
  24904. * @param options defines optional options to transmit to constructors
  24905. * @returns the new constructor or null
  24906. */
  24907. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24908. /**
  24909. * Gets or sets the name of the node
  24910. */
  24911. name: string;
  24912. /**
  24913. * Gets or sets the id of the node
  24914. */
  24915. id: string;
  24916. /**
  24917. * Gets or sets the unique id of the node
  24918. */
  24919. uniqueId: number;
  24920. /**
  24921. * Gets or sets a string used to store user defined state for the node
  24922. */
  24923. state: string;
  24924. /**
  24925. * Gets or sets an object used to store user defined information for the node
  24926. */
  24927. metadata: any;
  24928. /**
  24929. * For internal use only. Please do not use.
  24930. */
  24931. reservedDataStore: any;
  24932. /**
  24933. * Gets or sets a boolean used to define if the node must be serialized
  24934. */
  24935. doNotSerialize: boolean;
  24936. /** @hidden */
  24937. _isDisposed: boolean;
  24938. /**
  24939. * Gets a list of Animations associated with the node
  24940. */
  24941. animations: import("babylonjs/Animations/animation").Animation[];
  24942. protected _ranges: {
  24943. [name: string]: Nullable<AnimationRange>;
  24944. };
  24945. /**
  24946. * Callback raised when the node is ready to be used
  24947. */
  24948. onReady: (node: Node) => void;
  24949. private _isEnabled;
  24950. private _isParentEnabled;
  24951. private _isReady;
  24952. /** @hidden */
  24953. _currentRenderId: number;
  24954. private _parentRenderId;
  24955. protected _childRenderId: number;
  24956. /** @hidden */
  24957. _waitingParentId: Nullable<string>;
  24958. /** @hidden */
  24959. _scene: Scene;
  24960. /** @hidden */
  24961. _cache: any;
  24962. private _parentNode;
  24963. private _children;
  24964. /** @hidden */
  24965. _worldMatrix: Matrix;
  24966. /** @hidden */
  24967. _worldMatrixDeterminant: number;
  24968. /** @hidden */
  24969. private _sceneRootNodesIndex;
  24970. /**
  24971. * Gets a boolean indicating if the node has been disposed
  24972. * @returns true if the node was disposed
  24973. */
  24974. isDisposed(): boolean;
  24975. /**
  24976. * Gets or sets the parent of the node
  24977. */
  24978. parent: Nullable<Node>;
  24979. private addToSceneRootNodes;
  24980. private removeFromSceneRootNodes;
  24981. private _animationPropertiesOverride;
  24982. /**
  24983. * Gets or sets the animation properties override
  24984. */
  24985. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24986. /**
  24987. * Gets a string idenfifying the name of the class
  24988. * @returns "Node" string
  24989. */
  24990. getClassName(): string;
  24991. /** @hidden */
  24992. readonly _isNode: boolean;
  24993. /**
  24994. * An event triggered when the mesh is disposed
  24995. */
  24996. onDisposeObservable: Observable<Node>;
  24997. private _onDisposeObserver;
  24998. /**
  24999. * Sets a callback that will be raised when the node will be disposed
  25000. */
  25001. onDispose: () => void;
  25002. /**
  25003. * Creates a new Node
  25004. * @param name the name and id to be given to this node
  25005. * @param scene the scene this node will be added to
  25006. * @param addToRootNodes the node will be added to scene.rootNodes
  25007. */
  25008. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25009. /**
  25010. * Gets the scene of the node
  25011. * @returns a scene
  25012. */
  25013. getScene(): Scene;
  25014. /**
  25015. * Gets the engine of the node
  25016. * @returns a Engine
  25017. */
  25018. getEngine(): Engine;
  25019. private _behaviors;
  25020. /**
  25021. * Attach a behavior to the node
  25022. * @see http://doc.babylonjs.com/features/behaviour
  25023. * @param behavior defines the behavior to attach
  25024. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25025. * @returns the current Node
  25026. */
  25027. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25028. /**
  25029. * Remove an attached behavior
  25030. * @see http://doc.babylonjs.com/features/behaviour
  25031. * @param behavior defines the behavior to attach
  25032. * @returns the current Node
  25033. */
  25034. removeBehavior(behavior: Behavior<Node>): Node;
  25035. /**
  25036. * Gets the list of attached behaviors
  25037. * @see http://doc.babylonjs.com/features/behaviour
  25038. */
  25039. readonly behaviors: Behavior<Node>[];
  25040. /**
  25041. * Gets an attached behavior by name
  25042. * @param name defines the name of the behavior to look for
  25043. * @see http://doc.babylonjs.com/features/behaviour
  25044. * @returns null if behavior was not found else the requested behavior
  25045. */
  25046. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25047. /**
  25048. * Returns the latest update of the World matrix
  25049. * @returns a Matrix
  25050. */
  25051. getWorldMatrix(): Matrix;
  25052. /** @hidden */
  25053. _getWorldMatrixDeterminant(): number;
  25054. /**
  25055. * Returns directly the latest state of the mesh World matrix.
  25056. * A Matrix is returned.
  25057. */
  25058. readonly worldMatrixFromCache: Matrix;
  25059. /** @hidden */
  25060. _initCache(): void;
  25061. /** @hidden */
  25062. updateCache(force?: boolean): void;
  25063. /** @hidden */
  25064. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25065. /** @hidden */
  25066. _updateCache(ignoreParentClass?: boolean): void;
  25067. /** @hidden */
  25068. _isSynchronized(): boolean;
  25069. /** @hidden */
  25070. _markSyncedWithParent(): void;
  25071. /** @hidden */
  25072. isSynchronizedWithParent(): boolean;
  25073. /** @hidden */
  25074. isSynchronized(): boolean;
  25075. /**
  25076. * Is this node ready to be used/rendered
  25077. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25078. * @return true if the node is ready
  25079. */
  25080. isReady(completeCheck?: boolean): boolean;
  25081. /**
  25082. * Is this node enabled?
  25083. * 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
  25084. * @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
  25085. * @return whether this node (and its parent) is enabled
  25086. */
  25087. isEnabled(checkAncestors?: boolean): boolean;
  25088. /** @hidden */
  25089. protected _syncParentEnabledState(): void;
  25090. /**
  25091. * Set the enabled state of this node
  25092. * @param value defines the new enabled state
  25093. */
  25094. setEnabled(value: boolean): void;
  25095. /**
  25096. * Is this node a descendant of the given node?
  25097. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25098. * @param ancestor defines the parent node to inspect
  25099. * @returns a boolean indicating if this node is a descendant of the given node
  25100. */
  25101. isDescendantOf(ancestor: Node): boolean;
  25102. /** @hidden */
  25103. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25104. /**
  25105. * Will return all nodes that have this node as ascendant
  25106. * @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
  25107. * @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
  25108. * @return all children nodes of all types
  25109. */
  25110. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25111. /**
  25112. * Get all child-meshes of this node
  25113. * @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)
  25114. * @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
  25115. * @returns an array of AbstractMesh
  25116. */
  25117. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25118. /**
  25119. * Get all direct children of this node
  25120. * @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
  25121. * @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)
  25122. * @returns an array of Node
  25123. */
  25124. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25125. /** @hidden */
  25126. _setReady(state: boolean): void;
  25127. /**
  25128. * Get an animation by name
  25129. * @param name defines the name of the animation to look for
  25130. * @returns null if not found else the requested animation
  25131. */
  25132. getAnimationByName(name: string): Nullable<Animation>;
  25133. /**
  25134. * Creates an animation range for this node
  25135. * @param name defines the name of the range
  25136. * @param from defines the starting key
  25137. * @param to defines the end key
  25138. */
  25139. createAnimationRange(name: string, from: number, to: number): void;
  25140. /**
  25141. * Delete a specific animation range
  25142. * @param name defines the name of the range to delete
  25143. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25144. */
  25145. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25146. /**
  25147. * Get an animation range by name
  25148. * @param name defines the name of the animation range to look for
  25149. * @returns null if not found else the requested animation range
  25150. */
  25151. getAnimationRange(name: string): Nullable<AnimationRange>;
  25152. /**
  25153. * Gets the list of all animation ranges defined on this node
  25154. * @returns an array
  25155. */
  25156. getAnimationRanges(): Nullable<AnimationRange>[];
  25157. /**
  25158. * Will start the animation sequence
  25159. * @param name defines the range frames for animation sequence
  25160. * @param loop defines if the animation should loop (false by default)
  25161. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25162. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25163. * @returns the object created for this animation. If range does not exist, it will return null
  25164. */
  25165. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25166. /**
  25167. * Serialize animation ranges into a JSON compatible object
  25168. * @returns serialization object
  25169. */
  25170. serializeAnimationRanges(): any;
  25171. /**
  25172. * Computes the world matrix of the node
  25173. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25174. * @returns the world matrix
  25175. */
  25176. computeWorldMatrix(force?: boolean): Matrix;
  25177. /**
  25178. * Releases resources associated with this node.
  25179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25181. */
  25182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25183. /**
  25184. * Parse animation range data from a serialization object and store them into a given node
  25185. * @param node defines where to store the animation ranges
  25186. * @param parsedNode defines the serialization object to read data from
  25187. * @param scene defines the hosting scene
  25188. */
  25189. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25190. }
  25191. }
  25192. declare module "babylonjs/Animations/animation" {
  25193. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25194. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25195. import { Nullable } from "babylonjs/types";
  25196. import { Scene } from "babylonjs/scene";
  25197. import { IAnimatable } from "babylonjs/Misc/tools";
  25198. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25199. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25200. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25201. import { Node } from "babylonjs/node";
  25202. import { Animatable } from "babylonjs/Animations/animatable";
  25203. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25204. /**
  25205. * Class used to store any kind of animation
  25206. */
  25207. export class Animation {
  25208. /**Name of the animation */
  25209. name: string;
  25210. /**Property to animate */
  25211. targetProperty: string;
  25212. /**The frames per second of the animation */
  25213. framePerSecond: number;
  25214. /**The data type of the animation */
  25215. dataType: number;
  25216. /**The loop mode of the animation */
  25217. loopMode?: number | undefined;
  25218. /**Specifies if blending should be enabled */
  25219. enableBlending?: boolean | undefined;
  25220. /**
  25221. * Use matrix interpolation instead of using direct key value when animating matrices
  25222. */
  25223. static AllowMatricesInterpolation: boolean;
  25224. /**
  25225. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25226. */
  25227. static AllowMatrixDecomposeForInterpolation: boolean;
  25228. /**
  25229. * Stores the key frames of the animation
  25230. */
  25231. private _keys;
  25232. /**
  25233. * Stores the easing function of the animation
  25234. */
  25235. private _easingFunction;
  25236. /**
  25237. * @hidden Internal use only
  25238. */
  25239. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25240. /**
  25241. * The set of event that will be linked to this animation
  25242. */
  25243. private _events;
  25244. /**
  25245. * Stores an array of target property paths
  25246. */
  25247. targetPropertyPath: string[];
  25248. /**
  25249. * Stores the blending speed of the animation
  25250. */
  25251. blendingSpeed: number;
  25252. /**
  25253. * Stores the animation ranges for the animation
  25254. */
  25255. private _ranges;
  25256. /**
  25257. * @hidden Internal use
  25258. */
  25259. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25260. /**
  25261. * Sets up an animation
  25262. * @param property The property to animate
  25263. * @param animationType The animation type to apply
  25264. * @param framePerSecond The frames per second of the animation
  25265. * @param easingFunction The easing function used in the animation
  25266. * @returns The created animation
  25267. */
  25268. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25269. /**
  25270. * Create and start an animation on a node
  25271. * @param name defines the name of the global animation that will be run on all nodes
  25272. * @param node defines the root node where the animation will take place
  25273. * @param targetProperty defines property to animate
  25274. * @param framePerSecond defines the number of frame per second yo use
  25275. * @param totalFrame defines the number of frames in total
  25276. * @param from defines the initial value
  25277. * @param to defines the final value
  25278. * @param loopMode defines which loop mode you want to use (off by default)
  25279. * @param easingFunction defines the easing function to use (linear by default)
  25280. * @param onAnimationEnd defines the callback to call when animation end
  25281. * @returns the animatable created for this animation
  25282. */
  25283. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25284. /**
  25285. * Create and start an animation on a node and its descendants
  25286. * @param name defines the name of the global animation that will be run on all nodes
  25287. * @param node defines the root node where the animation will take place
  25288. * @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
  25289. * @param targetProperty defines property to animate
  25290. * @param framePerSecond defines the number of frame per second to use
  25291. * @param totalFrame defines the number of frames in total
  25292. * @param from defines the initial value
  25293. * @param to defines the final value
  25294. * @param loopMode defines which loop mode you want to use (off by default)
  25295. * @param easingFunction defines the easing function to use (linear by default)
  25296. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25297. * @returns the list of animatables created for all nodes
  25298. * @example https://www.babylonjs-playground.com/#MH0VLI
  25299. */
  25300. 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[]>;
  25301. /**
  25302. * Creates a new animation, merges it with the existing animations and starts it
  25303. * @param name Name of the animation
  25304. * @param node Node which contains the scene that begins the animations
  25305. * @param targetProperty Specifies which property to animate
  25306. * @param framePerSecond The frames per second of the animation
  25307. * @param totalFrame The total number of frames
  25308. * @param from The frame at the beginning of the animation
  25309. * @param to The frame at the end of the animation
  25310. * @param loopMode Specifies the loop mode of the animation
  25311. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25312. * @param onAnimationEnd Callback to run once the animation is complete
  25313. * @returns Nullable animation
  25314. */
  25315. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25316. /**
  25317. * Transition property of an host to the target Value
  25318. * @param property The property to transition
  25319. * @param targetValue The target Value of the property
  25320. * @param host The object where the property to animate belongs
  25321. * @param scene Scene used to run the animation
  25322. * @param frameRate Framerate (in frame/s) to use
  25323. * @param transition The transition type we want to use
  25324. * @param duration The duration of the animation, in milliseconds
  25325. * @param onAnimationEnd Callback trigger at the end of the animation
  25326. * @returns Nullable animation
  25327. */
  25328. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25329. /**
  25330. * Return the array of runtime animations currently using this animation
  25331. */
  25332. readonly runtimeAnimations: RuntimeAnimation[];
  25333. /**
  25334. * Specifies if any of the runtime animations are currently running
  25335. */
  25336. readonly hasRunningRuntimeAnimations: boolean;
  25337. /**
  25338. * Initializes the animation
  25339. * @param name Name of the animation
  25340. * @param targetProperty Property to animate
  25341. * @param framePerSecond The frames per second of the animation
  25342. * @param dataType The data type of the animation
  25343. * @param loopMode The loop mode of the animation
  25344. * @param enableBlending Specifies if blending should be enabled
  25345. */
  25346. constructor(
  25347. /**Name of the animation */
  25348. name: string,
  25349. /**Property to animate */
  25350. targetProperty: string,
  25351. /**The frames per second of the animation */
  25352. framePerSecond: number,
  25353. /**The data type of the animation */
  25354. dataType: number,
  25355. /**The loop mode of the animation */
  25356. loopMode?: number | undefined,
  25357. /**Specifies if blending should be enabled */
  25358. enableBlending?: boolean | undefined);
  25359. /**
  25360. * Converts the animation to a string
  25361. * @param fullDetails support for multiple levels of logging within scene loading
  25362. * @returns String form of the animation
  25363. */
  25364. toString(fullDetails?: boolean): string;
  25365. /**
  25366. * Add an event to this animation
  25367. * @param event Event to add
  25368. */
  25369. addEvent(event: AnimationEvent): void;
  25370. /**
  25371. * Remove all events found at the given frame
  25372. * @param frame The frame to remove events from
  25373. */
  25374. removeEvents(frame: number): void;
  25375. /**
  25376. * Retrieves all the events from the animation
  25377. * @returns Events from the animation
  25378. */
  25379. getEvents(): AnimationEvent[];
  25380. /**
  25381. * Creates an animation range
  25382. * @param name Name of the animation range
  25383. * @param from Starting frame of the animation range
  25384. * @param to Ending frame of the animation
  25385. */
  25386. createRange(name: string, from: number, to: number): void;
  25387. /**
  25388. * Deletes an animation range by name
  25389. * @param name Name of the animation range to delete
  25390. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25391. */
  25392. deleteRange(name: string, deleteFrames?: boolean): void;
  25393. /**
  25394. * Gets the animation range by name, or null if not defined
  25395. * @param name Name of the animation range
  25396. * @returns Nullable animation range
  25397. */
  25398. getRange(name: string): Nullable<AnimationRange>;
  25399. /**
  25400. * Gets the key frames from the animation
  25401. * @returns The key frames of the animation
  25402. */
  25403. getKeys(): Array<IAnimationKey>;
  25404. /**
  25405. * Gets the highest frame rate of the animation
  25406. * @returns Highest frame rate of the animation
  25407. */
  25408. getHighestFrame(): number;
  25409. /**
  25410. * Gets the easing function of the animation
  25411. * @returns Easing function of the animation
  25412. */
  25413. getEasingFunction(): IEasingFunction;
  25414. /**
  25415. * Sets the easing function of the animation
  25416. * @param easingFunction A custom mathematical formula for animation
  25417. */
  25418. setEasingFunction(easingFunction: EasingFunction): void;
  25419. /**
  25420. * Interpolates a scalar linearly
  25421. * @param startValue Start value of the animation curve
  25422. * @param endValue End value of the animation curve
  25423. * @param gradient Scalar amount to interpolate
  25424. * @returns Interpolated scalar value
  25425. */
  25426. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25427. /**
  25428. * Interpolates a scalar cubically
  25429. * @param startValue Start value of the animation curve
  25430. * @param outTangent End tangent of the animation
  25431. * @param endValue End value of the animation curve
  25432. * @param inTangent Start tangent of the animation curve
  25433. * @param gradient Scalar amount to interpolate
  25434. * @returns Interpolated scalar value
  25435. */
  25436. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25437. /**
  25438. * Interpolates a quaternion using a spherical linear interpolation
  25439. * @param startValue Start value of the animation curve
  25440. * @param endValue End value of the animation curve
  25441. * @param gradient Scalar amount to interpolate
  25442. * @returns Interpolated quaternion value
  25443. */
  25444. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25445. /**
  25446. * Interpolates a quaternion cubically
  25447. * @param startValue Start value of the animation curve
  25448. * @param outTangent End tangent of the animation curve
  25449. * @param endValue End value of the animation curve
  25450. * @param inTangent Start tangent of the animation curve
  25451. * @param gradient Scalar amount to interpolate
  25452. * @returns Interpolated quaternion value
  25453. */
  25454. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25455. /**
  25456. * Interpolates a Vector3 linearl
  25457. * @param startValue Start value of the animation curve
  25458. * @param endValue End value of the animation curve
  25459. * @param gradient Scalar amount to interpolate
  25460. * @returns Interpolated scalar value
  25461. */
  25462. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25463. /**
  25464. * Interpolates a Vector3 cubically
  25465. * @param startValue Start value of the animation curve
  25466. * @param outTangent End tangent of the animation
  25467. * @param endValue End value of the animation curve
  25468. * @param inTangent Start tangent of the animation curve
  25469. * @param gradient Scalar amount to interpolate
  25470. * @returns InterpolatedVector3 value
  25471. */
  25472. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25473. /**
  25474. * Interpolates a Vector2 linearly
  25475. * @param startValue Start value of the animation curve
  25476. * @param endValue End value of the animation curve
  25477. * @param gradient Scalar amount to interpolate
  25478. * @returns Interpolated Vector2 value
  25479. */
  25480. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25481. /**
  25482. * Interpolates a Vector2 cubically
  25483. * @param startValue Start value of the animation curve
  25484. * @param outTangent End tangent of the animation
  25485. * @param endValue End value of the animation curve
  25486. * @param inTangent Start tangent of the animation curve
  25487. * @param gradient Scalar amount to interpolate
  25488. * @returns Interpolated Vector2 value
  25489. */
  25490. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25491. /**
  25492. * Interpolates a size linearly
  25493. * @param startValue Start value of the animation curve
  25494. * @param endValue End value of the animation curve
  25495. * @param gradient Scalar amount to interpolate
  25496. * @returns Interpolated Size value
  25497. */
  25498. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25499. /**
  25500. * Interpolates a Color3 linearly
  25501. * @param startValue Start value of the animation curve
  25502. * @param endValue End value of the animation curve
  25503. * @param gradient Scalar amount to interpolate
  25504. * @returns Interpolated Color3 value
  25505. */
  25506. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25507. /**
  25508. * @hidden Internal use only
  25509. */
  25510. _getKeyValue(value: any): any;
  25511. /**
  25512. * @hidden Internal use only
  25513. */
  25514. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25515. /**
  25516. * Defines the function to use to interpolate matrices
  25517. * @param startValue defines the start matrix
  25518. * @param endValue defines the end matrix
  25519. * @param gradient defines the gradient between both matrices
  25520. * @param result defines an optional target matrix where to store the interpolation
  25521. * @returns the interpolated matrix
  25522. */
  25523. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25524. /**
  25525. * Makes a copy of the animation
  25526. * @returns Cloned animation
  25527. */
  25528. clone(): Animation;
  25529. /**
  25530. * Sets the key frames of the animation
  25531. * @param values The animation key frames to set
  25532. */
  25533. setKeys(values: Array<IAnimationKey>): void;
  25534. /**
  25535. * Serializes the animation to an object
  25536. * @returns Serialized object
  25537. */
  25538. serialize(): any;
  25539. /**
  25540. * Float animation type
  25541. */
  25542. private static _ANIMATIONTYPE_FLOAT;
  25543. /**
  25544. * Vector3 animation type
  25545. */
  25546. private static _ANIMATIONTYPE_VECTOR3;
  25547. /**
  25548. * Quaternion animation type
  25549. */
  25550. private static _ANIMATIONTYPE_QUATERNION;
  25551. /**
  25552. * Matrix animation type
  25553. */
  25554. private static _ANIMATIONTYPE_MATRIX;
  25555. /**
  25556. * Color3 animation type
  25557. */
  25558. private static _ANIMATIONTYPE_COLOR3;
  25559. /**
  25560. * Vector2 animation type
  25561. */
  25562. private static _ANIMATIONTYPE_VECTOR2;
  25563. /**
  25564. * Size animation type
  25565. */
  25566. private static _ANIMATIONTYPE_SIZE;
  25567. /**
  25568. * Relative Loop Mode
  25569. */
  25570. private static _ANIMATIONLOOPMODE_RELATIVE;
  25571. /**
  25572. * Cycle Loop Mode
  25573. */
  25574. private static _ANIMATIONLOOPMODE_CYCLE;
  25575. /**
  25576. * Constant Loop Mode
  25577. */
  25578. private static _ANIMATIONLOOPMODE_CONSTANT;
  25579. /**
  25580. * Get the float animation type
  25581. */
  25582. static readonly ANIMATIONTYPE_FLOAT: number;
  25583. /**
  25584. * Get the Vector3 animation type
  25585. */
  25586. static readonly ANIMATIONTYPE_VECTOR3: number;
  25587. /**
  25588. * Get the Vector2 animation type
  25589. */
  25590. static readonly ANIMATIONTYPE_VECTOR2: number;
  25591. /**
  25592. * Get the Size animation type
  25593. */
  25594. static readonly ANIMATIONTYPE_SIZE: number;
  25595. /**
  25596. * Get the Quaternion animation type
  25597. */
  25598. static readonly ANIMATIONTYPE_QUATERNION: number;
  25599. /**
  25600. * Get the Matrix animation type
  25601. */
  25602. static readonly ANIMATIONTYPE_MATRIX: number;
  25603. /**
  25604. * Get the Color3 animation type
  25605. */
  25606. static readonly ANIMATIONTYPE_COLOR3: number;
  25607. /**
  25608. * Get the Relative Loop Mode
  25609. */
  25610. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25611. /**
  25612. * Get the Cycle Loop Mode
  25613. */
  25614. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25615. /**
  25616. * Get the Constant Loop Mode
  25617. */
  25618. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25619. /** @hidden */
  25620. static _UniversalLerp(left: any, right: any, amount: number): any;
  25621. /**
  25622. * Parses an animation object and creates an animation
  25623. * @param parsedAnimation Parsed animation object
  25624. * @returns Animation object
  25625. */
  25626. static Parse(parsedAnimation: any): Animation;
  25627. /**
  25628. * Appends the serialized animations from the source animations
  25629. * @param source Source containing the animations
  25630. * @param destination Target to store the animations
  25631. */
  25632. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25633. }
  25634. }
  25635. declare module "babylonjs/Materials/Textures/baseTexture" {
  25636. import { Observable } from "babylonjs/Misc/observable";
  25637. import { IAnimatable } from "babylonjs/Misc/tools";
  25638. import { Nullable } from "babylonjs/types";
  25639. import { Scene } from "babylonjs/scene";
  25640. import { Matrix, ISize } from "babylonjs/Maths/math";
  25641. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25643. /**
  25644. * Base class of all the textures in babylon.
  25645. * It groups all the common properties the materials, post process, lights... might need
  25646. * in order to make a correct use of the texture.
  25647. */
  25648. export class BaseTexture implements IAnimatable {
  25649. /**
  25650. * Default anisotropic filtering level for the application.
  25651. * It is set to 4 as a good tradeoff between perf and quality.
  25652. */
  25653. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25654. /**
  25655. * Gets or sets the unique id of the texture
  25656. */
  25657. uniqueId: number;
  25658. /**
  25659. * Define the name of the texture.
  25660. */
  25661. name: string;
  25662. /**
  25663. * Gets or sets an object used to store user defined information.
  25664. */
  25665. metadata: any;
  25666. /**
  25667. * For internal use only. Please do not use.
  25668. */
  25669. reservedDataStore: any;
  25670. private _hasAlpha;
  25671. /**
  25672. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25673. */
  25674. hasAlpha: boolean;
  25675. /**
  25676. * Defines if the alpha value should be determined via the rgb values.
  25677. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25678. */
  25679. getAlphaFromRGB: boolean;
  25680. /**
  25681. * Intensity or strength of the texture.
  25682. * It is commonly used by materials to fine tune the intensity of the texture
  25683. */
  25684. level: number;
  25685. /**
  25686. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25687. * This is part of the texture as textures usually maps to one uv set.
  25688. */
  25689. coordinatesIndex: number;
  25690. private _coordinatesMode;
  25691. /**
  25692. * How a texture is mapped.
  25693. *
  25694. * | Value | Type | Description |
  25695. * | ----- | ----------------------------------- | ----------- |
  25696. * | 0 | EXPLICIT_MODE | |
  25697. * | 1 | SPHERICAL_MODE | |
  25698. * | 2 | PLANAR_MODE | |
  25699. * | 3 | CUBIC_MODE | |
  25700. * | 4 | PROJECTION_MODE | |
  25701. * | 5 | SKYBOX_MODE | |
  25702. * | 6 | INVCUBIC_MODE | |
  25703. * | 7 | EQUIRECTANGULAR_MODE | |
  25704. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25705. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25706. */
  25707. coordinatesMode: number;
  25708. /**
  25709. * | Value | Type | Description |
  25710. * | ----- | ------------------ | ----------- |
  25711. * | 0 | CLAMP_ADDRESSMODE | |
  25712. * | 1 | WRAP_ADDRESSMODE | |
  25713. * | 2 | MIRROR_ADDRESSMODE | |
  25714. */
  25715. wrapU: number;
  25716. /**
  25717. * | Value | Type | Description |
  25718. * | ----- | ------------------ | ----------- |
  25719. * | 0 | CLAMP_ADDRESSMODE | |
  25720. * | 1 | WRAP_ADDRESSMODE | |
  25721. * | 2 | MIRROR_ADDRESSMODE | |
  25722. */
  25723. wrapV: number;
  25724. /**
  25725. * | Value | Type | Description |
  25726. * | ----- | ------------------ | ----------- |
  25727. * | 0 | CLAMP_ADDRESSMODE | |
  25728. * | 1 | WRAP_ADDRESSMODE | |
  25729. * | 2 | MIRROR_ADDRESSMODE | |
  25730. */
  25731. wrapR: number;
  25732. /**
  25733. * With compliant hardware and browser (supporting anisotropic filtering)
  25734. * this defines the level of anisotropic filtering in the texture.
  25735. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25736. */
  25737. anisotropicFilteringLevel: number;
  25738. /**
  25739. * Define if the texture is a cube texture or if false a 2d texture.
  25740. */
  25741. isCube: boolean;
  25742. /**
  25743. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25744. */
  25745. is3D: boolean;
  25746. /**
  25747. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25748. * HDR texture are usually stored in linear space.
  25749. * This only impacts the PBR and Background materials
  25750. */
  25751. gammaSpace: boolean;
  25752. /**
  25753. * Gets whether or not the texture contains RGBD data.
  25754. */
  25755. readonly isRGBD: boolean;
  25756. /**
  25757. * Is Z inverted in the texture (useful in a cube texture).
  25758. */
  25759. invertZ: boolean;
  25760. /**
  25761. * Are mip maps generated for this texture or not.
  25762. */
  25763. readonly noMipmap: boolean;
  25764. /**
  25765. * @hidden
  25766. */
  25767. lodLevelInAlpha: boolean;
  25768. /**
  25769. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25770. */
  25771. lodGenerationOffset: number;
  25772. /**
  25773. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25774. */
  25775. lodGenerationScale: number;
  25776. /**
  25777. * Define if the texture is a render target.
  25778. */
  25779. isRenderTarget: boolean;
  25780. /**
  25781. * Define the unique id of the texture in the scene.
  25782. */
  25783. readonly uid: string;
  25784. /**
  25785. * Return a string representation of the texture.
  25786. * @returns the texture as a string
  25787. */
  25788. toString(): string;
  25789. /**
  25790. * Get the class name of the texture.
  25791. * @returns "BaseTexture"
  25792. */
  25793. getClassName(): string;
  25794. /**
  25795. * Define the list of animation attached to the texture.
  25796. */
  25797. animations: import("babylonjs/Animations/animation").Animation[];
  25798. /**
  25799. * An event triggered when the texture is disposed.
  25800. */
  25801. onDisposeObservable: Observable<BaseTexture>;
  25802. private _onDisposeObserver;
  25803. /**
  25804. * Callback triggered when the texture has been disposed.
  25805. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25806. */
  25807. onDispose: () => void;
  25808. /**
  25809. * Define the current state of the loading sequence when in delayed load mode.
  25810. */
  25811. delayLoadState: number;
  25812. private _scene;
  25813. /** @hidden */
  25814. _texture: Nullable<InternalTexture>;
  25815. private _uid;
  25816. /**
  25817. * Define if the texture is preventinga material to render or not.
  25818. * If not and the texture is not ready, the engine will use a default black texture instead.
  25819. */
  25820. readonly isBlocking: boolean;
  25821. /**
  25822. * Instantiates a new BaseTexture.
  25823. * Base class of all the textures in babylon.
  25824. * It groups all the common properties the materials, post process, lights... might need
  25825. * in order to make a correct use of the texture.
  25826. * @param scene Define the scene the texture blongs to
  25827. */
  25828. constructor(scene: Nullable<Scene>);
  25829. /**
  25830. * Get the scene the texture belongs to.
  25831. * @returns the scene or null if undefined
  25832. */
  25833. getScene(): Nullable<Scene>;
  25834. /**
  25835. * Get the texture transform matrix used to offset tile the texture for istance.
  25836. * @returns the transformation matrix
  25837. */
  25838. getTextureMatrix(): Matrix;
  25839. /**
  25840. * Get the texture reflection matrix used to rotate/transform the reflection.
  25841. * @returns the reflection matrix
  25842. */
  25843. getReflectionTextureMatrix(): Matrix;
  25844. /**
  25845. * Get the underlying lower level texture from Babylon.
  25846. * @returns the insternal texture
  25847. */
  25848. getInternalTexture(): Nullable<InternalTexture>;
  25849. /**
  25850. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25851. * @returns true if ready or not blocking
  25852. */
  25853. isReadyOrNotBlocking(): boolean;
  25854. /**
  25855. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25856. * @returns true if fully ready
  25857. */
  25858. isReady(): boolean;
  25859. private _cachedSize;
  25860. /**
  25861. * Get the size of the texture.
  25862. * @returns the texture size.
  25863. */
  25864. getSize(): ISize;
  25865. /**
  25866. * Get the base size of the texture.
  25867. * It can be different from the size if the texture has been resized for POT for instance
  25868. * @returns the base size
  25869. */
  25870. getBaseSize(): ISize;
  25871. /**
  25872. * Update the sampling mode of the texture.
  25873. * Default is Trilinear mode.
  25874. *
  25875. * | Value | Type | Description |
  25876. * | ----- | ------------------ | ----------- |
  25877. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25878. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25879. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25880. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25881. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25882. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25883. * | 7 | NEAREST_LINEAR | |
  25884. * | 8 | NEAREST_NEAREST | |
  25885. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25886. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25887. * | 11 | LINEAR_LINEAR | |
  25888. * | 12 | LINEAR_NEAREST | |
  25889. *
  25890. * > _mag_: magnification filter (close to the viewer)
  25891. * > _min_: minification filter (far from the viewer)
  25892. * > _mip_: filter used between mip map levels
  25893. *@param samplingMode Define the new sampling mode of the texture
  25894. */
  25895. updateSamplingMode(samplingMode: number): void;
  25896. /**
  25897. * Scales the texture if is `canRescale()`
  25898. * @param ratio the resize factor we want to use to rescale
  25899. */
  25900. scale(ratio: number): void;
  25901. /**
  25902. * Get if the texture can rescale.
  25903. */
  25904. readonly canRescale: boolean;
  25905. /** @hidden */
  25906. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25907. /** @hidden */
  25908. _rebuild(): void;
  25909. /**
  25910. * Triggers the load sequence in delayed load mode.
  25911. */
  25912. delayLoad(): void;
  25913. /**
  25914. * Clones the texture.
  25915. * @returns the cloned texture
  25916. */
  25917. clone(): Nullable<BaseTexture>;
  25918. /**
  25919. * Get the texture underlying type (INT, FLOAT...)
  25920. */
  25921. readonly textureType: number;
  25922. /**
  25923. * Get the texture underlying format (RGB, RGBA...)
  25924. */
  25925. readonly textureFormat: number;
  25926. /**
  25927. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25928. * This will returns an RGBA array buffer containing either in values (0-255) or
  25929. * float values (0-1) depending of the underlying buffer type.
  25930. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25931. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25932. * @param buffer defines a user defined buffer to fill with data (can be null)
  25933. * @returns The Array buffer containing the pixels data.
  25934. */
  25935. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25936. /**
  25937. * Release and destroy the underlying lower level texture aka internalTexture.
  25938. */
  25939. releaseInternalTexture(): void;
  25940. /**
  25941. * Get the polynomial representation of the texture data.
  25942. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25943. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25944. */
  25945. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25946. /** @hidden */
  25947. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25948. /** @hidden */
  25949. readonly _lodTextureMid: Nullable<BaseTexture>;
  25950. /** @hidden */
  25951. readonly _lodTextureLow: Nullable<BaseTexture>;
  25952. /**
  25953. * Dispose the texture and release its associated resources.
  25954. */
  25955. dispose(): void;
  25956. /**
  25957. * Serialize the texture into a JSON representation that can be parsed later on.
  25958. * @returns the JSON representation of the texture
  25959. */
  25960. serialize(): any;
  25961. /**
  25962. * Helper function to be called back once a list of texture contains only ready textures.
  25963. * @param textures Define the list of textures to wait for
  25964. * @param callback Define the callback triggered once the entire list will be ready
  25965. */
  25966. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25967. }
  25968. }
  25969. declare module "babylonjs/Materials/uniformBuffer" {
  25970. import { Nullable, FloatArray } from "babylonjs/types";
  25971. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25972. import { Engine } from "babylonjs/Engines/engine";
  25973. import { Effect } from "babylonjs/Materials/effect";
  25974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25975. /**
  25976. * Uniform buffer objects.
  25977. *
  25978. * Handles blocks of uniform on the GPU.
  25979. *
  25980. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25981. *
  25982. * For more information, please refer to :
  25983. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25984. */
  25985. export class UniformBuffer {
  25986. private _engine;
  25987. private _buffer;
  25988. private _data;
  25989. private _bufferData;
  25990. private _dynamic?;
  25991. private _uniformLocations;
  25992. private _uniformSizes;
  25993. private _uniformLocationPointer;
  25994. private _needSync;
  25995. private _noUBO;
  25996. private _currentEffect;
  25997. private static _MAX_UNIFORM_SIZE;
  25998. private static _tempBuffer;
  25999. /**
  26000. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26001. * This is dynamic to allow compat with webgl 1 and 2.
  26002. * You will need to pass the name of the uniform as well as the value.
  26003. */
  26004. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26005. /**
  26006. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26007. * This is dynamic to allow compat with webgl 1 and 2.
  26008. * You will need to pass the name of the uniform as well as the value.
  26009. */
  26010. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26011. /**
  26012. * Lambda to Update a single float in a uniform buffer.
  26013. * This is dynamic to allow compat with webgl 1 and 2.
  26014. * You will need to pass the name of the uniform as well as the value.
  26015. */
  26016. updateFloat: (name: string, x: number) => void;
  26017. /**
  26018. * Lambda to Update a vec2 of float in a uniform buffer.
  26019. * This is dynamic to allow compat with webgl 1 and 2.
  26020. * You will need to pass the name of the uniform as well as the value.
  26021. */
  26022. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26023. /**
  26024. * Lambda to Update a vec3 of float in a uniform buffer.
  26025. * This is dynamic to allow compat with webgl 1 and 2.
  26026. * You will need to pass the name of the uniform as well as the value.
  26027. */
  26028. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26029. /**
  26030. * Lambda to Update a vec4 of float in a uniform buffer.
  26031. * This is dynamic to allow compat with webgl 1 and 2.
  26032. * You will need to pass the name of the uniform as well as the value.
  26033. */
  26034. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26035. /**
  26036. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26037. * This is dynamic to allow compat with webgl 1 and 2.
  26038. * You will need to pass the name of the uniform as well as the value.
  26039. */
  26040. updateMatrix: (name: string, mat: Matrix) => void;
  26041. /**
  26042. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26043. * This is dynamic to allow compat with webgl 1 and 2.
  26044. * You will need to pass the name of the uniform as well as the value.
  26045. */
  26046. updateVector3: (name: string, vector: Vector3) => void;
  26047. /**
  26048. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26049. * This is dynamic to allow compat with webgl 1 and 2.
  26050. * You will need to pass the name of the uniform as well as the value.
  26051. */
  26052. updateVector4: (name: string, vector: Vector4) => void;
  26053. /**
  26054. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26055. * This is dynamic to allow compat with webgl 1 and 2.
  26056. * You will need to pass the name of the uniform as well as the value.
  26057. */
  26058. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26059. /**
  26060. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26061. * This is dynamic to allow compat with webgl 1 and 2.
  26062. * You will need to pass the name of the uniform as well as the value.
  26063. */
  26064. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26065. /**
  26066. * Instantiates a new Uniform buffer objects.
  26067. *
  26068. * Handles blocks of uniform on the GPU.
  26069. *
  26070. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26071. *
  26072. * For more information, please refer to :
  26073. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26074. * @param engine Define the engine the buffer is associated with
  26075. * @param data Define the data contained in the buffer
  26076. * @param dynamic Define if the buffer is updatable
  26077. */
  26078. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26079. /**
  26080. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26081. * or just falling back on setUniformXXX calls.
  26082. */
  26083. readonly useUbo: boolean;
  26084. /**
  26085. * Indicates if the WebGL underlying uniform buffer is in sync
  26086. * with the javascript cache data.
  26087. */
  26088. readonly isSync: boolean;
  26089. /**
  26090. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26091. * Also, a dynamic UniformBuffer will disable cache verification and always
  26092. * update the underlying WebGL uniform buffer to the GPU.
  26093. * @returns if Dynamic, otherwise false
  26094. */
  26095. isDynamic(): boolean;
  26096. /**
  26097. * The data cache on JS side.
  26098. * @returns the underlying data as a float array
  26099. */
  26100. getData(): Float32Array;
  26101. /**
  26102. * The underlying WebGL Uniform buffer.
  26103. * @returns the webgl buffer
  26104. */
  26105. getBuffer(): Nullable<WebGLBuffer>;
  26106. /**
  26107. * std140 layout specifies how to align data within an UBO structure.
  26108. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26109. * for specs.
  26110. */
  26111. private _fillAlignment;
  26112. /**
  26113. * Adds an uniform in the buffer.
  26114. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26115. * for the layout to be correct !
  26116. * @param name Name of the uniform, as used in the uniform block in the shader.
  26117. * @param size Data size, or data directly.
  26118. */
  26119. addUniform(name: string, size: number | number[]): void;
  26120. /**
  26121. * Adds a Matrix 4x4 to the uniform buffer.
  26122. * @param name Name of the uniform, as used in the uniform block in the shader.
  26123. * @param mat A 4x4 matrix.
  26124. */
  26125. addMatrix(name: string, mat: Matrix): void;
  26126. /**
  26127. * Adds a vec2 to the uniform buffer.
  26128. * @param name Name of the uniform, as used in the uniform block in the shader.
  26129. * @param x Define the x component value of the vec2
  26130. * @param y Define the y component value of the vec2
  26131. */
  26132. addFloat2(name: string, x: number, y: number): void;
  26133. /**
  26134. * Adds a vec3 to the uniform buffer.
  26135. * @param name Name of the uniform, as used in the uniform block in the shader.
  26136. * @param x Define the x component value of the vec3
  26137. * @param y Define the y component value of the vec3
  26138. * @param z Define the z component value of the vec3
  26139. */
  26140. addFloat3(name: string, x: number, y: number, z: number): void;
  26141. /**
  26142. * Adds a vec3 to the uniform buffer.
  26143. * @param name Name of the uniform, as used in the uniform block in the shader.
  26144. * @param color Define the vec3 from a Color
  26145. */
  26146. addColor3(name: string, color: Color3): void;
  26147. /**
  26148. * Adds a vec4 to the uniform buffer.
  26149. * @param name Name of the uniform, as used in the uniform block in the shader.
  26150. * @param color Define the rgb components from a Color
  26151. * @param alpha Define the a component of the vec4
  26152. */
  26153. addColor4(name: string, color: Color3, alpha: number): void;
  26154. /**
  26155. * Adds a vec3 to the uniform buffer.
  26156. * @param name Name of the uniform, as used in the uniform block in the shader.
  26157. * @param vector Define the vec3 components from a Vector
  26158. */
  26159. addVector3(name: string, vector: Vector3): void;
  26160. /**
  26161. * Adds a Matrix 3x3 to the uniform buffer.
  26162. * @param name Name of the uniform, as used in the uniform block in the shader.
  26163. */
  26164. addMatrix3x3(name: string): void;
  26165. /**
  26166. * Adds a Matrix 2x2 to the uniform buffer.
  26167. * @param name Name of the uniform, as used in the uniform block in the shader.
  26168. */
  26169. addMatrix2x2(name: string): void;
  26170. /**
  26171. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26172. */
  26173. create(): void;
  26174. /** @hidden */
  26175. _rebuild(): void;
  26176. /**
  26177. * Updates the WebGL Uniform Buffer on the GPU.
  26178. * If the `dynamic` flag is set to true, no cache comparison is done.
  26179. * Otherwise, the buffer will be updated only if the cache differs.
  26180. */
  26181. update(): void;
  26182. /**
  26183. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26184. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26185. * @param data Define the flattened data
  26186. * @param size Define the size of the data.
  26187. */
  26188. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26189. private _updateMatrix3x3ForUniform;
  26190. private _updateMatrix3x3ForEffect;
  26191. private _updateMatrix2x2ForEffect;
  26192. private _updateMatrix2x2ForUniform;
  26193. private _updateFloatForEffect;
  26194. private _updateFloatForUniform;
  26195. private _updateFloat2ForEffect;
  26196. private _updateFloat2ForUniform;
  26197. private _updateFloat3ForEffect;
  26198. private _updateFloat3ForUniform;
  26199. private _updateFloat4ForEffect;
  26200. private _updateFloat4ForUniform;
  26201. private _updateMatrixForEffect;
  26202. private _updateMatrixForUniform;
  26203. private _updateVector3ForEffect;
  26204. private _updateVector3ForUniform;
  26205. private _updateVector4ForEffect;
  26206. private _updateVector4ForUniform;
  26207. private _updateColor3ForEffect;
  26208. private _updateColor3ForUniform;
  26209. private _updateColor4ForEffect;
  26210. private _updateColor4ForUniform;
  26211. /**
  26212. * Sets a sampler uniform on the effect.
  26213. * @param name Define the name of the sampler.
  26214. * @param texture Define the texture to set in the sampler
  26215. */
  26216. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26217. /**
  26218. * Directly updates the value of the uniform in the cache AND on the GPU.
  26219. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26220. * @param data Define the flattened data
  26221. */
  26222. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26223. /**
  26224. * Binds this uniform buffer to an effect.
  26225. * @param effect Define the effect to bind the buffer to
  26226. * @param name Name of the uniform block in the shader.
  26227. */
  26228. bindToEffect(effect: Effect, name: string): void;
  26229. /**
  26230. * Disposes the uniform buffer.
  26231. */
  26232. dispose(): void;
  26233. }
  26234. }
  26235. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26236. import { Nullable } from "babylonjs/types";
  26237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26238. /**
  26239. * This represents the required contract to create a new type of texture loader.
  26240. */
  26241. export interface IInternalTextureLoader {
  26242. /**
  26243. * Defines wether the loader supports cascade loading the different faces.
  26244. */
  26245. supportCascades: boolean;
  26246. /**
  26247. * This returns if the loader support the current file information.
  26248. * @param extension defines the file extension of the file being loaded
  26249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26250. * @param fallback defines the fallback internal texture if any
  26251. * @param isBase64 defines whether the texture is encoded as a base64
  26252. * @param isBuffer defines whether the texture data are stored as a buffer
  26253. * @returns true if the loader can load the specified file
  26254. */
  26255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26256. /**
  26257. * Transform the url before loading if required.
  26258. * @param rootUrl the url of the texture
  26259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26260. * @returns the transformed texture
  26261. */
  26262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26263. /**
  26264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26265. * @param rootUrl the url of the texture
  26266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26267. * @returns the fallback texture
  26268. */
  26269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26270. /**
  26271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26272. * @param data contains the texture data
  26273. * @param texture defines the BabylonJS internal texture
  26274. * @param createPolynomials will be true if polynomials have been requested
  26275. * @param onLoad defines the callback to trigger once the texture is ready
  26276. * @param onError defines the callback to trigger in case of error
  26277. */
  26278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26279. /**
  26280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26281. * @param data contains the texture data
  26282. * @param texture defines the BabylonJS internal texture
  26283. * @param callback defines the method to call once ready to upload
  26284. */
  26285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26286. }
  26287. }
  26288. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26289. import { Scene } from "babylonjs/scene";
  26290. import { Engine } from "babylonjs/Engines/engine";
  26291. import { Texture } from "babylonjs/Materials/Textures/texture";
  26292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26293. /**
  26294. * Creation options of the multi render target texture.
  26295. */
  26296. export interface IMultiRenderTargetOptions {
  26297. /**
  26298. * Define if the texture needs to create mip maps after render.
  26299. */
  26300. generateMipMaps?: boolean;
  26301. /**
  26302. * Define the types of all the draw buffers we want to create
  26303. */
  26304. types?: number[];
  26305. /**
  26306. * Define the sampling modes of all the draw buffers we want to create
  26307. */
  26308. samplingModes?: number[];
  26309. /**
  26310. * Define if a depth buffer is required
  26311. */
  26312. generateDepthBuffer?: boolean;
  26313. /**
  26314. * Define if a stencil buffer is required
  26315. */
  26316. generateStencilBuffer?: boolean;
  26317. /**
  26318. * Define if a depth texture is required instead of a depth buffer
  26319. */
  26320. generateDepthTexture?: boolean;
  26321. /**
  26322. * Define the number of desired draw buffers
  26323. */
  26324. textureCount?: number;
  26325. /**
  26326. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26327. */
  26328. doNotChangeAspectRatio?: boolean;
  26329. /**
  26330. * Define the default type of the buffers we are creating
  26331. */
  26332. defaultType?: number;
  26333. }
  26334. /**
  26335. * A multi render target, like a render target provides the ability to render to a texture.
  26336. * Unlike the render target, it can render to several draw buffers in one draw.
  26337. * This is specially interesting in deferred rendering or for any effects requiring more than
  26338. * just one color from a single pass.
  26339. */
  26340. export class MultiRenderTarget extends RenderTargetTexture {
  26341. private _internalTextures;
  26342. private _textures;
  26343. private _multiRenderTargetOptions;
  26344. /**
  26345. * Get if draw buffers are currently supported by the used hardware and browser.
  26346. */
  26347. readonly isSupported: boolean;
  26348. /**
  26349. * Get the list of textures generated by the multi render target.
  26350. */
  26351. readonly textures: Texture[];
  26352. /**
  26353. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26354. */
  26355. readonly depthTexture: Texture;
  26356. /**
  26357. * Set the wrapping mode on U of all the textures we are rendering to.
  26358. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26359. */
  26360. wrapU: number;
  26361. /**
  26362. * Set the wrapping mode on V of all the textures we are rendering to.
  26363. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26364. */
  26365. wrapV: number;
  26366. /**
  26367. * Instantiate a new multi render target texture.
  26368. * A multi render target, like a render target provides the ability to render to a texture.
  26369. * Unlike the render target, it can render to several draw buffers in one draw.
  26370. * This is specially interesting in deferred rendering or for any effects requiring more than
  26371. * just one color from a single pass.
  26372. * @param name Define the name of the texture
  26373. * @param size Define the size of the buffers to render to
  26374. * @param count Define the number of target we are rendering into
  26375. * @param scene Define the scene the texture belongs to
  26376. * @param options Define the options used to create the multi render target
  26377. */
  26378. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26379. /** @hidden */
  26380. _rebuild(): void;
  26381. private _createInternalTextures;
  26382. private _createTextures;
  26383. /**
  26384. * Define the number of samples used if MSAA is enabled.
  26385. */
  26386. samples: number;
  26387. /**
  26388. * Resize all the textures in the multi render target.
  26389. * Be carrefull as it will recreate all the data in the new texture.
  26390. * @param size Define the new size
  26391. */
  26392. resize(size: any): void;
  26393. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26394. /**
  26395. * Dispose the render targets and their associated resources
  26396. */
  26397. dispose(): void;
  26398. /**
  26399. * Release all the underlying texture used as draw buffers.
  26400. */
  26401. releaseInternalTextures(): void;
  26402. }
  26403. }
  26404. declare module "babylonjs/Audio/analyser" {
  26405. import { Scene } from "babylonjs/scene";
  26406. /**
  26407. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26409. */
  26410. export class Analyser {
  26411. /**
  26412. * Gets or sets the smoothing
  26413. * @ignorenaming
  26414. */
  26415. SMOOTHING: number;
  26416. /**
  26417. * Gets or sets the FFT table size
  26418. * @ignorenaming
  26419. */
  26420. FFT_SIZE: number;
  26421. /**
  26422. * Gets or sets the bar graph amplitude
  26423. * @ignorenaming
  26424. */
  26425. BARGRAPHAMPLITUDE: number;
  26426. /**
  26427. * Gets or sets the position of the debug canvas
  26428. * @ignorenaming
  26429. */
  26430. DEBUGCANVASPOS: {
  26431. x: number;
  26432. y: number;
  26433. };
  26434. /**
  26435. * Gets or sets the debug canvas size
  26436. * @ignorenaming
  26437. */
  26438. DEBUGCANVASSIZE: {
  26439. width: number;
  26440. height: number;
  26441. };
  26442. private _byteFreqs;
  26443. private _byteTime;
  26444. private _floatFreqs;
  26445. private _webAudioAnalyser;
  26446. private _debugCanvas;
  26447. private _debugCanvasContext;
  26448. private _scene;
  26449. private _registerFunc;
  26450. private _audioEngine;
  26451. /**
  26452. * Creates a new analyser
  26453. * @param scene defines hosting scene
  26454. */
  26455. constructor(scene: Scene);
  26456. /**
  26457. * Get the number of data values you will have to play with for the visualization
  26458. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26459. * @returns a number
  26460. */
  26461. getFrequencyBinCount(): number;
  26462. /**
  26463. * Gets the current frequency data as a byte array
  26464. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26465. * @returns a Uint8Array
  26466. */
  26467. getByteFrequencyData(): Uint8Array;
  26468. /**
  26469. * Gets the current waveform as a byte array
  26470. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26471. * @returns a Uint8Array
  26472. */
  26473. getByteTimeDomainData(): Uint8Array;
  26474. /**
  26475. * Gets the current frequency data as a float array
  26476. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26477. * @returns a Float32Array
  26478. */
  26479. getFloatFrequencyData(): Float32Array;
  26480. /**
  26481. * Renders the debug canvas
  26482. */
  26483. drawDebugCanvas(): void;
  26484. /**
  26485. * Stops rendering the debug canvas and removes it
  26486. */
  26487. stopDebugCanvas(): void;
  26488. /**
  26489. * Connects two audio nodes
  26490. * @param inputAudioNode defines first node to connect
  26491. * @param outputAudioNode defines second node to connect
  26492. */
  26493. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26494. /**
  26495. * Releases all associated resources
  26496. */
  26497. dispose(): void;
  26498. }
  26499. }
  26500. declare module "babylonjs/Audio/audioEngine" {
  26501. import { IDisposable } from "babylonjs/scene";
  26502. import { Analyser } from "babylonjs/Audio/analyser";
  26503. import { Nullable } from "babylonjs/types";
  26504. import { Observable } from "babylonjs/Misc/observable";
  26505. /**
  26506. * This represents an audio engine and it is responsible
  26507. * to play, synchronize and analyse sounds throughout the application.
  26508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26509. */
  26510. export interface IAudioEngine extends IDisposable {
  26511. /**
  26512. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26513. */
  26514. readonly canUseWebAudio: boolean;
  26515. /**
  26516. * Gets the current AudioContext if available.
  26517. */
  26518. readonly audioContext: Nullable<AudioContext>;
  26519. /**
  26520. * The master gain node defines the global audio volume of your audio engine.
  26521. */
  26522. readonly masterGain: GainNode;
  26523. /**
  26524. * Gets whether or not mp3 are supported by your browser.
  26525. */
  26526. readonly isMP3supported: boolean;
  26527. /**
  26528. * Gets whether or not ogg are supported by your browser.
  26529. */
  26530. readonly isOGGsupported: boolean;
  26531. /**
  26532. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26533. * @ignoreNaming
  26534. */
  26535. WarnedWebAudioUnsupported: boolean;
  26536. /**
  26537. * Defines if the audio engine relies on a custom unlocked button.
  26538. * In this case, the embedded button will not be displayed.
  26539. */
  26540. useCustomUnlockedButton: boolean;
  26541. /**
  26542. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26543. */
  26544. readonly unlocked: boolean;
  26545. /**
  26546. * Event raised when audio has been unlocked on the browser.
  26547. */
  26548. onAudioUnlockedObservable: Observable<AudioEngine>;
  26549. /**
  26550. * Event raised when audio has been locked on the browser.
  26551. */
  26552. onAudioLockedObservable: Observable<AudioEngine>;
  26553. /**
  26554. * Flags the audio engine in Locked state.
  26555. * This happens due to new browser policies preventing audio to autoplay.
  26556. */
  26557. lock(): void;
  26558. /**
  26559. * Unlocks the audio engine once a user action has been done on the dom.
  26560. * This is helpful to resume play once browser policies have been satisfied.
  26561. */
  26562. unlock(): void;
  26563. }
  26564. /**
  26565. * This represents the default audio engine used in babylon.
  26566. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26568. */
  26569. export class AudioEngine implements IAudioEngine {
  26570. private _audioContext;
  26571. private _audioContextInitialized;
  26572. private _muteButton;
  26573. private _hostElement;
  26574. /**
  26575. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26576. */
  26577. canUseWebAudio: boolean;
  26578. /**
  26579. * The master gain node defines the global audio volume of your audio engine.
  26580. */
  26581. masterGain: GainNode;
  26582. /**
  26583. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26584. * @ignoreNaming
  26585. */
  26586. WarnedWebAudioUnsupported: boolean;
  26587. /**
  26588. * Gets whether or not mp3 are supported by your browser.
  26589. */
  26590. isMP3supported: boolean;
  26591. /**
  26592. * Gets whether or not ogg are supported by your browser.
  26593. */
  26594. isOGGsupported: boolean;
  26595. /**
  26596. * Gets whether audio has been unlocked on the device.
  26597. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26598. * a user interaction has happened.
  26599. */
  26600. unlocked: boolean;
  26601. /**
  26602. * Defines if the audio engine relies on a custom unlocked button.
  26603. * In this case, the embedded button will not be displayed.
  26604. */
  26605. useCustomUnlockedButton: boolean;
  26606. /**
  26607. * Event raised when audio has been unlocked on the browser.
  26608. */
  26609. onAudioUnlockedObservable: Observable<AudioEngine>;
  26610. /**
  26611. * Event raised when audio has been locked on the browser.
  26612. */
  26613. onAudioLockedObservable: Observable<AudioEngine>;
  26614. /**
  26615. * Gets the current AudioContext if available.
  26616. */
  26617. readonly audioContext: Nullable<AudioContext>;
  26618. private _connectedAnalyser;
  26619. /**
  26620. * Instantiates a new audio engine.
  26621. *
  26622. * There should be only one per page as some browsers restrict the number
  26623. * of audio contexts you can create.
  26624. * @param hostElement defines the host element where to display the mute icon if necessary
  26625. */
  26626. constructor(hostElement?: Nullable<HTMLElement>);
  26627. /**
  26628. * Flags the audio engine in Locked state.
  26629. * This happens due to new browser policies preventing audio to autoplay.
  26630. */
  26631. lock(): void;
  26632. /**
  26633. * Unlocks the audio engine once a user action has been done on the dom.
  26634. * This is helpful to resume play once browser policies have been satisfied.
  26635. */
  26636. unlock(): void;
  26637. private _resumeAudioContext;
  26638. private _initializeAudioContext;
  26639. private _tryToRun;
  26640. private _triggerRunningState;
  26641. private _triggerSuspendedState;
  26642. private _displayMuteButton;
  26643. private _moveButtonToTopLeft;
  26644. private _onResize;
  26645. private _hideMuteButton;
  26646. /**
  26647. * Destroy and release the resources associated with the audio ccontext.
  26648. */
  26649. dispose(): void;
  26650. /**
  26651. * Gets the global volume sets on the master gain.
  26652. * @returns the global volume if set or -1 otherwise
  26653. */
  26654. getGlobalVolume(): number;
  26655. /**
  26656. * Sets the global volume of your experience (sets on the master gain).
  26657. * @param newVolume Defines the new global volume of the application
  26658. */
  26659. setGlobalVolume(newVolume: number): void;
  26660. /**
  26661. * Connect the audio engine to an audio analyser allowing some amazing
  26662. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26664. * @param analyser The analyser to connect to the engine
  26665. */
  26666. connectToAnalyser(analyser: Analyser): void;
  26667. }
  26668. }
  26669. declare module "babylonjs/Loading/loadingScreen" {
  26670. /**
  26671. * Interface used to present a loading screen while loading a scene
  26672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26673. */
  26674. export interface ILoadingScreen {
  26675. /**
  26676. * Function called to display the loading screen
  26677. */
  26678. displayLoadingUI: () => void;
  26679. /**
  26680. * Function called to hide the loading screen
  26681. */
  26682. hideLoadingUI: () => void;
  26683. /**
  26684. * Gets or sets the color to use for the background
  26685. */
  26686. loadingUIBackgroundColor: string;
  26687. /**
  26688. * Gets or sets the text to display while loading
  26689. */
  26690. loadingUIText: string;
  26691. }
  26692. /**
  26693. * Class used for the default loading screen
  26694. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26695. */
  26696. export class DefaultLoadingScreen implements ILoadingScreen {
  26697. private _renderingCanvas;
  26698. private _loadingText;
  26699. private _loadingDivBackgroundColor;
  26700. private _loadingDiv;
  26701. private _loadingTextDiv;
  26702. /**
  26703. * Creates a new default loading screen
  26704. * @param _renderingCanvas defines the canvas used to render the scene
  26705. * @param _loadingText defines the default text to display
  26706. * @param _loadingDivBackgroundColor defines the default background color
  26707. */
  26708. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26709. /**
  26710. * Function called to display the loading screen
  26711. */
  26712. displayLoadingUI(): void;
  26713. /**
  26714. * Function called to hide the loading screen
  26715. */
  26716. hideLoadingUI(): void;
  26717. /**
  26718. * Gets or sets the text to display while loading
  26719. */
  26720. loadingUIText: string;
  26721. /**
  26722. * Gets or sets the color to use for the background
  26723. */
  26724. loadingUIBackgroundColor: string;
  26725. private _resizeLoadingUI;
  26726. }
  26727. }
  26728. declare module "babylonjs/Materials/Textures/videoTexture" {
  26729. import { Observable } from "babylonjs/Misc/observable";
  26730. import { Nullable } from "babylonjs/types";
  26731. import { Scene } from "babylonjs/scene";
  26732. import { Texture } from "babylonjs/Materials/Textures/texture";
  26733. /**
  26734. * Settings for finer control over video usage
  26735. */
  26736. export interface VideoTextureSettings {
  26737. /**
  26738. * Applies `autoplay` to video, if specified
  26739. */
  26740. autoPlay?: boolean;
  26741. /**
  26742. * Applies `loop` to video, if specified
  26743. */
  26744. loop?: boolean;
  26745. /**
  26746. * Automatically updates internal texture from video at every frame in the render loop
  26747. */
  26748. autoUpdateTexture: boolean;
  26749. /**
  26750. * Image src displayed during the video loading or until the user interacts with the video.
  26751. */
  26752. poster?: string;
  26753. }
  26754. /**
  26755. * If you want to display a video in your scene, this is the special texture for that.
  26756. * This special texture works similar to other textures, with the exception of a few parameters.
  26757. * @see https://doc.babylonjs.com/how_to/video_texture
  26758. */
  26759. export class VideoTexture extends Texture {
  26760. /**
  26761. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26762. */
  26763. readonly autoUpdateTexture: boolean;
  26764. /**
  26765. * The video instance used by the texture internally
  26766. */
  26767. readonly video: HTMLVideoElement;
  26768. private _onUserActionRequestedObservable;
  26769. /**
  26770. * Event triggerd when a dom action is required by the user to play the video.
  26771. * This happens due to recent changes in browser policies preventing video to auto start.
  26772. */
  26773. readonly onUserActionRequestedObservable: Observable<Texture>;
  26774. private _generateMipMaps;
  26775. private _engine;
  26776. private _stillImageCaptured;
  26777. private _displayingPosterTexture;
  26778. private _settings;
  26779. private _createInternalTextureOnEvent;
  26780. /**
  26781. * Creates a video texture.
  26782. * If you want to display a video in your scene, this is the special texture for that.
  26783. * This special texture works similar to other textures, with the exception of a few parameters.
  26784. * @see https://doc.babylonjs.com/how_to/video_texture
  26785. * @param name optional name, will detect from video source, if not defined
  26786. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26787. * @param scene is obviously the current scene.
  26788. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26789. * @param invertY is false by default but can be used to invert video on Y axis
  26790. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26791. * @param settings allows finer control over video usage
  26792. */
  26793. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26794. private _getName;
  26795. private _getVideo;
  26796. private _createInternalTexture;
  26797. private reset;
  26798. /**
  26799. * @hidden Internal method to initiate `update`.
  26800. */
  26801. _rebuild(): void;
  26802. /**
  26803. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26804. */
  26805. update(): void;
  26806. /**
  26807. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26808. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26809. */
  26810. updateTexture(isVisible: boolean): void;
  26811. protected _updateInternalTexture: () => void;
  26812. /**
  26813. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26814. * @param url New url.
  26815. */
  26816. updateURL(url: string): void;
  26817. /**
  26818. * Dispose the texture and release its associated resources.
  26819. */
  26820. dispose(): void;
  26821. /**
  26822. * Creates a video texture straight from a stream.
  26823. * @param scene Define the scene the texture should be created in
  26824. * @param stream Define the stream the texture should be created from
  26825. * @returns The created video texture as a promise
  26826. */
  26827. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26828. /**
  26829. * Creates a video texture straight from your WebCam video feed.
  26830. * @param scene Define the scene the texture should be created in
  26831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26832. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26833. * @returns The created video texture as a promise
  26834. */
  26835. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26836. minWidth: number;
  26837. maxWidth: number;
  26838. minHeight: number;
  26839. maxHeight: number;
  26840. deviceId: string;
  26841. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26842. /**
  26843. * Creates a video texture straight from your WebCam video feed.
  26844. * @param scene Define the scene the texture should be created in
  26845. * @param onReady Define a callback to triggered once the texture will be ready
  26846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26848. */
  26849. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26850. minWidth: number;
  26851. maxWidth: number;
  26852. minHeight: number;
  26853. maxHeight: number;
  26854. deviceId: string;
  26855. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26856. }
  26857. }
  26858. declare module "babylonjs/Engines/engine" {
  26859. import { Observable } from "babylonjs/Misc/observable";
  26860. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26861. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26862. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26863. import { Camera } from "babylonjs/Cameras/camera";
  26864. import { Scene } from "babylonjs/scene";
  26865. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26866. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26867. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26869. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26870. import { Material } from "babylonjs/Materials/material";
  26871. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26874. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26875. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26876. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26877. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26878. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26879. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26880. import { WebRequest } from "babylonjs/Misc/webRequest";
  26881. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26882. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26883. /**
  26884. * Interface for attribute information associated with buffer instanciation
  26885. */
  26886. export class InstancingAttributeInfo {
  26887. /**
  26888. * Index/offset of the attribute in the vertex shader
  26889. */
  26890. index: number;
  26891. /**
  26892. * size of the attribute, 1, 2, 3 or 4
  26893. */
  26894. attributeSize: number;
  26895. /**
  26896. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26897. * default is FLOAT
  26898. */
  26899. attribyteType: number;
  26900. /**
  26901. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26902. */
  26903. normalized: boolean;
  26904. /**
  26905. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26906. */
  26907. offset: number;
  26908. /**
  26909. * Name of the GLSL attribute, for debugging purpose only
  26910. */
  26911. attributeName: string;
  26912. }
  26913. /**
  26914. * Define options used to create a depth texture
  26915. */
  26916. export class DepthTextureCreationOptions {
  26917. /** Specifies whether or not a stencil should be allocated in the texture */
  26918. generateStencil?: boolean;
  26919. /** Specifies whether or not bilinear filtering is enable on the texture */
  26920. bilinearFiltering?: boolean;
  26921. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26922. comparisonFunction?: number;
  26923. /** Specifies if the created texture is a cube texture */
  26924. isCube?: boolean;
  26925. }
  26926. /**
  26927. * Class used to describe the capabilities of the engine relatively to the current browser
  26928. */
  26929. export class EngineCapabilities {
  26930. /** Maximum textures units per fragment shader */
  26931. maxTexturesImageUnits: number;
  26932. /** Maximum texture units per vertex shader */
  26933. maxVertexTextureImageUnits: number;
  26934. /** Maximum textures units in the entire pipeline */
  26935. maxCombinedTexturesImageUnits: number;
  26936. /** Maximum texture size */
  26937. maxTextureSize: number;
  26938. /** Maximum cube texture size */
  26939. maxCubemapTextureSize: number;
  26940. /** Maximum render texture size */
  26941. maxRenderTextureSize: number;
  26942. /** Maximum number of vertex attributes */
  26943. maxVertexAttribs: number;
  26944. /** Maximum number of varyings */
  26945. maxVaryingVectors: number;
  26946. /** Maximum number of uniforms per vertex shader */
  26947. maxVertexUniformVectors: number;
  26948. /** Maximum number of uniforms per fragment shader */
  26949. maxFragmentUniformVectors: number;
  26950. /** Defines if standard derivates (dx/dy) are supported */
  26951. standardDerivatives: boolean;
  26952. /** Defines if s3tc texture compression is supported */
  26953. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26954. /** Defines if pvrtc texture compression is supported */
  26955. pvrtc: any;
  26956. /** Defines if etc1 texture compression is supported */
  26957. etc1: any;
  26958. /** Defines if etc2 texture compression is supported */
  26959. etc2: any;
  26960. /** Defines if astc texture compression is supported */
  26961. astc: any;
  26962. /** Defines if float textures are supported */
  26963. textureFloat: boolean;
  26964. /** Defines if vertex array objects are supported */
  26965. vertexArrayObject: boolean;
  26966. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26967. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26968. /** Gets the maximum level of anisotropy supported */
  26969. maxAnisotropy: number;
  26970. /** Defines if instancing is supported */
  26971. instancedArrays: boolean;
  26972. /** Defines if 32 bits indices are supported */
  26973. uintIndices: boolean;
  26974. /** Defines if high precision shaders are supported */
  26975. highPrecisionShaderSupported: boolean;
  26976. /** Defines if depth reading in the fragment shader is supported */
  26977. fragmentDepthSupported: boolean;
  26978. /** Defines if float texture linear filtering is supported*/
  26979. textureFloatLinearFiltering: boolean;
  26980. /** Defines if rendering to float textures is supported */
  26981. textureFloatRender: boolean;
  26982. /** Defines if half float textures are supported*/
  26983. textureHalfFloat: boolean;
  26984. /** Defines if half float texture linear filtering is supported*/
  26985. textureHalfFloatLinearFiltering: boolean;
  26986. /** Defines if rendering to half float textures is supported */
  26987. textureHalfFloatRender: boolean;
  26988. /** Defines if textureLOD shader command is supported */
  26989. textureLOD: boolean;
  26990. /** Defines if draw buffers extension is supported */
  26991. drawBuffersExtension: boolean;
  26992. /** Defines if depth textures are supported */
  26993. depthTextureExtension: boolean;
  26994. /** Defines if float color buffer are supported */
  26995. colorBufferFloat: boolean;
  26996. /** Gets disjoint timer query extension (null if not supported) */
  26997. timerQuery: EXT_disjoint_timer_query;
  26998. /** Defines if timestamp can be used with timer query */
  26999. canUseTimestampForTimerQuery: boolean;
  27000. /** Function used to let the system compiles shaders in background */
  27001. parallelShaderCompile: {
  27002. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27003. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27004. COMPLETION_STATUS_KHR: number;
  27005. };
  27006. }
  27007. /** Interface defining initialization parameters for Engine class */
  27008. export interface EngineOptions extends WebGLContextAttributes {
  27009. /**
  27010. * Defines if the engine should no exceed a specified device ratio
  27011. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27012. */
  27013. limitDeviceRatio?: number;
  27014. /**
  27015. * Defines if webvr should be enabled automatically
  27016. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27017. */
  27018. autoEnableWebVR?: boolean;
  27019. /**
  27020. * Defines if webgl2 should be turned off even if supported
  27021. * @see http://doc.babylonjs.com/features/webgl2
  27022. */
  27023. disableWebGL2Support?: boolean;
  27024. /**
  27025. * Defines if webaudio should be initialized as well
  27026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27027. */
  27028. audioEngine?: boolean;
  27029. /**
  27030. * Defines if animations should run using a deterministic lock step
  27031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27032. */
  27033. deterministicLockstep?: boolean;
  27034. /** Defines the maximum steps to use with deterministic lock step mode */
  27035. lockstepMaxSteps?: number;
  27036. /**
  27037. * Defines that engine should ignore context lost events
  27038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27039. */
  27040. doNotHandleContextLost?: boolean;
  27041. /**
  27042. * Defines that engine should ignore modifying touch action attribute and style
  27043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27044. */
  27045. doNotHandleTouchAction?: boolean;
  27046. }
  27047. /**
  27048. * Defines the interface used by display changed events
  27049. */
  27050. export interface IDisplayChangedEventArgs {
  27051. /** Gets the vrDisplay object (if any) */
  27052. vrDisplay: Nullable<any>;
  27053. /** Gets a boolean indicating if webVR is supported */
  27054. vrSupported: boolean;
  27055. }
  27056. /**
  27057. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27058. */
  27059. export class Engine {
  27060. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27061. static ExceptionList: ({
  27062. key: string;
  27063. capture: string;
  27064. captureConstraint: number;
  27065. targets: string[];
  27066. } | {
  27067. key: string;
  27068. capture: null;
  27069. captureConstraint: null;
  27070. targets: string[];
  27071. })[];
  27072. /** Gets the list of created engines */
  27073. static readonly Instances: Engine[];
  27074. /**
  27075. * Gets the latest created engine
  27076. */
  27077. static readonly LastCreatedEngine: Nullable<Engine>;
  27078. /**
  27079. * Gets the latest created scene
  27080. */
  27081. static readonly LastCreatedScene: Nullable<Scene>;
  27082. /**
  27083. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27084. * @param flag defines which part of the materials must be marked as dirty
  27085. * @param predicate defines a predicate used to filter which materials should be affected
  27086. */
  27087. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27088. /**
  27089. * Hidden
  27090. */
  27091. static _TextureLoaders: IInternalTextureLoader[];
  27092. /** Defines that alpha blending is disabled */
  27093. static readonly ALPHA_DISABLE: number;
  27094. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27095. static readonly ALPHA_ADD: number;
  27096. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27097. static readonly ALPHA_COMBINE: number;
  27098. /** Defines that alpha blending to DEST - SRC * DEST */
  27099. static readonly ALPHA_SUBTRACT: number;
  27100. /** Defines that alpha blending to SRC * DEST */
  27101. static readonly ALPHA_MULTIPLY: number;
  27102. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27103. static readonly ALPHA_MAXIMIZED: number;
  27104. /** Defines that alpha blending to SRC + DEST */
  27105. static readonly ALPHA_ONEONE: number;
  27106. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27107. static readonly ALPHA_PREMULTIPLIED: number;
  27108. /**
  27109. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27110. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27111. */
  27112. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27113. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27114. static readonly ALPHA_INTERPOLATE: number;
  27115. /**
  27116. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27117. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27118. */
  27119. static readonly ALPHA_SCREENMODE: number;
  27120. /** Defines that the ressource is not delayed*/
  27121. static readonly DELAYLOADSTATE_NONE: number;
  27122. /** Defines that the ressource was successfully delay loaded */
  27123. static readonly DELAYLOADSTATE_LOADED: number;
  27124. /** Defines that the ressource is currently delay loading */
  27125. static readonly DELAYLOADSTATE_LOADING: number;
  27126. /** Defines that the ressource is delayed and has not started loading */
  27127. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27128. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27129. static readonly NEVER: number;
  27130. /** 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 */
  27131. static readonly ALWAYS: number;
  27132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27133. static readonly LESS: number;
  27134. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27135. static readonly EQUAL: number;
  27136. /** 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 */
  27137. static readonly LEQUAL: number;
  27138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27139. static readonly GREATER: number;
  27140. /** 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 */
  27141. static readonly GEQUAL: number;
  27142. /** 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 */
  27143. static readonly NOTEQUAL: number;
  27144. /** Passed to stencilOperation to specify that stencil value must be kept */
  27145. static readonly KEEP: number;
  27146. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27147. static readonly REPLACE: number;
  27148. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27149. static readonly INCR: number;
  27150. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27151. static readonly DECR: number;
  27152. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27153. static readonly INVERT: number;
  27154. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27155. static readonly INCR_WRAP: number;
  27156. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27157. static readonly DECR_WRAP: number;
  27158. /** Texture is not repeating outside of 0..1 UVs */
  27159. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27160. /** Texture is repeating outside of 0..1 UVs */
  27161. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27162. /** Texture is repeating and mirrored */
  27163. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27164. /** ALPHA */
  27165. static readonly TEXTUREFORMAT_ALPHA: number;
  27166. /** LUMINANCE */
  27167. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27168. /** LUMINANCE_ALPHA */
  27169. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27170. /** RGB */
  27171. static readonly TEXTUREFORMAT_RGB: number;
  27172. /** RGBA */
  27173. static readonly TEXTUREFORMAT_RGBA: number;
  27174. /** RED */
  27175. static readonly TEXTUREFORMAT_RED: number;
  27176. /** RED (2nd reference) */
  27177. static readonly TEXTUREFORMAT_R: number;
  27178. /** RG */
  27179. static readonly TEXTUREFORMAT_RG: number;
  27180. /** RED_INTEGER */
  27181. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27182. /** RED_INTEGER (2nd reference) */
  27183. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27184. /** RG_INTEGER */
  27185. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27186. /** RGB_INTEGER */
  27187. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27188. /** RGBA_INTEGER */
  27189. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27190. /** UNSIGNED_BYTE */
  27191. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27192. /** UNSIGNED_BYTE (2nd reference) */
  27193. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27194. /** FLOAT */
  27195. static readonly TEXTURETYPE_FLOAT: number;
  27196. /** HALF_FLOAT */
  27197. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27198. /** BYTE */
  27199. static readonly TEXTURETYPE_BYTE: number;
  27200. /** SHORT */
  27201. static readonly TEXTURETYPE_SHORT: number;
  27202. /** UNSIGNED_SHORT */
  27203. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27204. /** INT */
  27205. static readonly TEXTURETYPE_INT: number;
  27206. /** UNSIGNED_INT */
  27207. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27208. /** UNSIGNED_SHORT_4_4_4_4 */
  27209. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27210. /** UNSIGNED_SHORT_5_5_5_1 */
  27211. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27212. /** UNSIGNED_SHORT_5_6_5 */
  27213. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27214. /** UNSIGNED_INT_2_10_10_10_REV */
  27215. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27216. /** UNSIGNED_INT_24_8 */
  27217. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27218. /** UNSIGNED_INT_10F_11F_11F_REV */
  27219. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27220. /** UNSIGNED_INT_5_9_9_9_REV */
  27221. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27222. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27223. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27224. /** nearest is mag = nearest and min = nearest and mip = linear */
  27225. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27226. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27227. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27228. /** Trilinear is mag = linear and min = linear and mip = linear */
  27229. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27230. /** nearest is mag = nearest and min = nearest and mip = linear */
  27231. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27232. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27233. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27234. /** Trilinear is mag = linear and min = linear and mip = linear */
  27235. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27236. /** mag = nearest and min = nearest and mip = nearest */
  27237. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27238. /** mag = nearest and min = linear and mip = nearest */
  27239. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27240. /** mag = nearest and min = linear and mip = linear */
  27241. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27242. /** mag = nearest and min = linear and mip = none */
  27243. static readonly TEXTURE_NEAREST_LINEAR: number;
  27244. /** mag = nearest and min = nearest and mip = none */
  27245. static readonly TEXTURE_NEAREST_NEAREST: number;
  27246. /** mag = linear and min = nearest and mip = nearest */
  27247. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27248. /** mag = linear and min = nearest and mip = linear */
  27249. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27250. /** mag = linear and min = linear and mip = none */
  27251. static readonly TEXTURE_LINEAR_LINEAR: number;
  27252. /** mag = linear and min = nearest and mip = none */
  27253. static readonly TEXTURE_LINEAR_NEAREST: number;
  27254. /** Explicit coordinates mode */
  27255. static readonly TEXTURE_EXPLICIT_MODE: number;
  27256. /** Spherical coordinates mode */
  27257. static readonly TEXTURE_SPHERICAL_MODE: number;
  27258. /** Planar coordinates mode */
  27259. static readonly TEXTURE_PLANAR_MODE: number;
  27260. /** Cubic coordinates mode */
  27261. static readonly TEXTURE_CUBIC_MODE: number;
  27262. /** Projection coordinates mode */
  27263. static readonly TEXTURE_PROJECTION_MODE: number;
  27264. /** Skybox coordinates mode */
  27265. static readonly TEXTURE_SKYBOX_MODE: number;
  27266. /** Inverse Cubic coordinates mode */
  27267. static readonly TEXTURE_INVCUBIC_MODE: number;
  27268. /** Equirectangular coordinates mode */
  27269. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27270. /** Equirectangular Fixed coordinates mode */
  27271. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27272. /** Equirectangular Fixed Mirrored coordinates mode */
  27273. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27274. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27275. static readonly SCALEMODE_FLOOR: number;
  27276. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27277. static readonly SCALEMODE_NEAREST: number;
  27278. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27279. static readonly SCALEMODE_CEILING: number;
  27280. /**
  27281. * Returns the current version of the framework
  27282. */
  27283. static readonly Version: string;
  27284. /**
  27285. * Returns a string describing the current engine
  27286. */
  27287. readonly description: string;
  27288. /**
  27289. * Gets or sets the epsilon value used by collision engine
  27290. */
  27291. static CollisionsEpsilon: number;
  27292. /**
  27293. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27294. */
  27295. static ShadersRepository: string;
  27296. /**
  27297. * Method called to create the default loading screen.
  27298. * This can be overriden in your own app.
  27299. * @param canvas The rendering canvas element
  27300. * @returns The loading screen
  27301. */
  27302. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27303. /**
  27304. * Method called to create the default rescale post process on each engine.
  27305. */
  27306. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27307. /**
  27308. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27309. */
  27310. forcePOTTextures: boolean;
  27311. /**
  27312. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27313. */
  27314. isFullscreen: boolean;
  27315. /**
  27316. * Gets a boolean indicating if the pointer is currently locked
  27317. */
  27318. isPointerLock: boolean;
  27319. /**
  27320. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27321. */
  27322. cullBackFaces: boolean;
  27323. /**
  27324. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27325. */
  27326. renderEvenInBackground: boolean;
  27327. /**
  27328. * Gets or sets a boolean indicating that cache can be kept between frames
  27329. */
  27330. preventCacheWipeBetweenFrames: boolean;
  27331. /**
  27332. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27333. **/
  27334. enableOfflineSupport: boolean;
  27335. /**
  27336. * 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)
  27337. **/
  27338. disableManifestCheck: boolean;
  27339. /**
  27340. * Gets the list of created scenes
  27341. */
  27342. scenes: Scene[];
  27343. /**
  27344. * Event raised when a new scene is created
  27345. */
  27346. onNewSceneAddedObservable: Observable<Scene>;
  27347. /**
  27348. * Gets the list of created postprocesses
  27349. */
  27350. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27351. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27352. validateShaderPrograms: boolean;
  27353. /**
  27354. * Observable event triggered each time the rendering canvas is resized
  27355. */
  27356. onResizeObservable: Observable<Engine>;
  27357. /**
  27358. * Observable event triggered each time the canvas loses focus
  27359. */
  27360. onCanvasBlurObservable: Observable<Engine>;
  27361. /**
  27362. * Observable event triggered each time the canvas gains focus
  27363. */
  27364. onCanvasFocusObservable: Observable<Engine>;
  27365. /**
  27366. * Observable event triggered each time the canvas receives pointerout event
  27367. */
  27368. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27369. /**
  27370. * Observable event triggered before each texture is initialized
  27371. */
  27372. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27373. private _vrDisplay;
  27374. private _vrSupported;
  27375. private _oldSize;
  27376. private _oldHardwareScaleFactor;
  27377. private _vrExclusivePointerMode;
  27378. private _webVRInitPromise;
  27379. /**
  27380. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27381. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27382. */
  27383. readonly isInVRExclusivePointerMode: boolean;
  27384. /**
  27385. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27386. */
  27387. disableUniformBuffers: boolean;
  27388. /** @hidden */
  27389. _uniformBuffers: UniformBuffer[];
  27390. /**
  27391. * Gets a boolean indicating that the engine supports uniform buffers
  27392. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27393. */
  27394. readonly supportsUniformBuffers: boolean;
  27395. /**
  27396. * Observable raised when the engine begins a new frame
  27397. */
  27398. onBeginFrameObservable: Observable<Engine>;
  27399. /**
  27400. * If set, will be used to request the next animation frame for the render loop
  27401. */
  27402. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27403. /**
  27404. * Observable raised when the engine ends the current frame
  27405. */
  27406. onEndFrameObservable: Observable<Engine>;
  27407. /**
  27408. * Observable raised when the engine is about to compile a shader
  27409. */
  27410. onBeforeShaderCompilationObservable: Observable<Engine>;
  27411. /**
  27412. * Observable raised when the engine has jsut compiled a shader
  27413. */
  27414. onAfterShaderCompilationObservable: Observable<Engine>;
  27415. /** @hidden */
  27416. _gl: WebGLRenderingContext;
  27417. private _renderingCanvas;
  27418. private _windowIsBackground;
  27419. private _webGLVersion;
  27420. /**
  27421. * Gets a boolean indicating that only power of 2 textures are supported
  27422. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27423. */
  27424. readonly needPOTTextures: boolean;
  27425. /** @hidden */
  27426. _badOS: boolean;
  27427. /** @hidden */
  27428. _badDesktopOS: boolean;
  27429. /**
  27430. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27431. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27432. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27433. */
  27434. disableTextureBindingOptimization: boolean;
  27435. /**
  27436. * Gets the audio engine
  27437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27438. * @ignorenaming
  27439. */
  27440. static audioEngine: IAudioEngine;
  27441. /**
  27442. * Default AudioEngine factory responsible of creating the Audio Engine.
  27443. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27444. */
  27445. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27446. /**
  27447. * Default offline support factory responsible of creating a tool used to store data locally.
  27448. * By default, this will create a Database object if the workload has been embedded.
  27449. */
  27450. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27451. private _onFocus;
  27452. private _onBlur;
  27453. private _onCanvasPointerOut;
  27454. private _onCanvasBlur;
  27455. private _onCanvasFocus;
  27456. private _onFullscreenChange;
  27457. private _onPointerLockChange;
  27458. private _onVRDisplayPointerRestricted;
  27459. private _onVRDisplayPointerUnrestricted;
  27460. private _onVrDisplayConnect;
  27461. private _onVrDisplayDisconnect;
  27462. private _onVrDisplayPresentChange;
  27463. /**
  27464. * Observable signaled when VR display mode changes
  27465. */
  27466. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27467. /**
  27468. * Observable signaled when VR request present is complete
  27469. */
  27470. onVRRequestPresentComplete: Observable<boolean>;
  27471. /**
  27472. * Observable signaled when VR request present starts
  27473. */
  27474. onVRRequestPresentStart: Observable<Engine>;
  27475. private _hardwareScalingLevel;
  27476. /** @hidden */
  27477. protected _caps: EngineCapabilities;
  27478. private _pointerLockRequested;
  27479. private _isStencilEnable;
  27480. private _colorWrite;
  27481. private _loadingScreen;
  27482. /** @hidden */
  27483. _drawCalls: PerfCounter;
  27484. /** @hidden */
  27485. _textureCollisions: PerfCounter;
  27486. private _glVersion;
  27487. private _glRenderer;
  27488. private _glVendor;
  27489. private _videoTextureSupported;
  27490. private _renderingQueueLaunched;
  27491. private _activeRenderLoops;
  27492. private _deterministicLockstep;
  27493. private _lockstepMaxSteps;
  27494. /**
  27495. * Observable signaled when a context lost event is raised
  27496. */
  27497. onContextLostObservable: Observable<Engine>;
  27498. /**
  27499. * Observable signaled when a context restored event is raised
  27500. */
  27501. onContextRestoredObservable: Observable<Engine>;
  27502. private _onContextLost;
  27503. private _onContextRestored;
  27504. private _contextWasLost;
  27505. private _doNotHandleContextLost;
  27506. /**
  27507. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27508. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27509. */
  27510. doNotHandleContextLost: boolean;
  27511. private _performanceMonitor;
  27512. private _fps;
  27513. private _deltaTime;
  27514. /**
  27515. * Turn this value on if you want to pause FPS computation when in background
  27516. */
  27517. disablePerformanceMonitorInBackground: boolean;
  27518. /**
  27519. * Gets the performance monitor attached to this engine
  27520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27521. */
  27522. readonly performanceMonitor: PerformanceMonitor;
  27523. /** @hidden */
  27524. protected _depthCullingState: _DepthCullingState;
  27525. /** @hidden */
  27526. protected _stencilState: _StencilState;
  27527. /** @hidden */
  27528. protected _alphaState: _AlphaState;
  27529. /** @hidden */
  27530. protected _alphaMode: number;
  27531. protected _internalTexturesCache: InternalTexture[];
  27532. /** @hidden */
  27533. protected _activeChannel: number;
  27534. private _currentTextureChannel;
  27535. /** @hidden */
  27536. protected _boundTexturesCache: {
  27537. [key: string]: Nullable<InternalTexture>;
  27538. };
  27539. /** @hidden */
  27540. protected _currentEffect: Nullable<Effect>;
  27541. /** @hidden */
  27542. protected _currentProgram: Nullable<WebGLProgram>;
  27543. private _compiledEffects;
  27544. private _vertexAttribArraysEnabled;
  27545. /** @hidden */
  27546. protected _cachedViewport: Nullable<Viewport>;
  27547. private _cachedVertexArrayObject;
  27548. /** @hidden */
  27549. protected _cachedVertexBuffers: any;
  27550. /** @hidden */
  27551. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27552. /** @hidden */
  27553. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27554. /** @hidden */
  27555. protected _currentRenderTarget: Nullable<InternalTexture>;
  27556. private _uintIndicesCurrentlySet;
  27557. private _currentBoundBuffer;
  27558. /** @hidden */
  27559. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27560. private _currentBufferPointers;
  27561. private _currentInstanceLocations;
  27562. private _currentInstanceBuffers;
  27563. private _textureUnits;
  27564. private _firstBoundInternalTextureTracker;
  27565. private _lastBoundInternalTextureTracker;
  27566. private _workingCanvas;
  27567. private _workingContext;
  27568. private _rescalePostProcess;
  27569. private _dummyFramebuffer;
  27570. private _externalData;
  27571. private _bindedRenderFunction;
  27572. private _vaoRecordInProgress;
  27573. private _mustWipeVertexAttributes;
  27574. private _emptyTexture;
  27575. private _emptyCubeTexture;
  27576. private _emptyTexture3D;
  27577. /** @hidden */
  27578. _frameHandler: number;
  27579. private _nextFreeTextureSlots;
  27580. private _maxSimultaneousTextures;
  27581. private _activeRequests;
  27582. private _texturesSupported;
  27583. private _textureFormatInUse;
  27584. /**
  27585. * Gets the list of texture formats supported
  27586. */
  27587. readonly texturesSupported: Array<string>;
  27588. /**
  27589. * Gets the list of texture formats in use
  27590. */
  27591. readonly textureFormatInUse: Nullable<string>;
  27592. /**
  27593. * Gets the current viewport
  27594. */
  27595. readonly currentViewport: Nullable<Viewport>;
  27596. /**
  27597. * Gets the default empty texture
  27598. */
  27599. readonly emptyTexture: InternalTexture;
  27600. /**
  27601. * Gets the default empty 3D texture
  27602. */
  27603. readonly emptyTexture3D: InternalTexture;
  27604. /**
  27605. * Gets the default empty cube texture
  27606. */
  27607. readonly emptyCubeTexture: InternalTexture;
  27608. /**
  27609. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27610. */
  27611. readonly premultipliedAlpha: boolean;
  27612. /**
  27613. * Creates a new engine
  27614. * @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
  27615. * @param antialias defines enable antialiasing (default: false)
  27616. * @param options defines further options to be sent to the getContext() function
  27617. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27618. */
  27619. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27620. private _disableTouchAction;
  27621. private _rebuildInternalTextures;
  27622. private _rebuildEffects;
  27623. /**
  27624. * Gets a boolean indicating if all created effects are ready
  27625. * @returns true if all effects are ready
  27626. */
  27627. areAllEffectsReady(): boolean;
  27628. private _rebuildBuffers;
  27629. private _initGLContext;
  27630. /**
  27631. * Gets version of the current webGL context
  27632. */
  27633. readonly webGLVersion: number;
  27634. /**
  27635. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27636. */
  27637. readonly isStencilEnable: boolean;
  27638. private _prepareWorkingCanvas;
  27639. /**
  27640. * Reset the texture cache to empty state
  27641. */
  27642. resetTextureCache(): void;
  27643. /**
  27644. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27645. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27646. * @returns true if engine is in deterministic lock step mode
  27647. */
  27648. isDeterministicLockStep(): boolean;
  27649. /**
  27650. * Gets the max steps when engine is running in deterministic lock step
  27651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27652. * @returns the max steps
  27653. */
  27654. getLockstepMaxSteps(): number;
  27655. /**
  27656. * Gets an object containing information about the current webGL context
  27657. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27658. */
  27659. getGlInfo(): {
  27660. vendor: string;
  27661. renderer: string;
  27662. version: string;
  27663. };
  27664. /**
  27665. * Gets current aspect ratio
  27666. * @param camera defines the camera to use to get the aspect ratio
  27667. * @param useScreen defines if screen size must be used (or the current render target if any)
  27668. * @returns a number defining the aspect ratio
  27669. */
  27670. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27671. /**
  27672. * Gets current screen aspect ratio
  27673. * @returns a number defining the aspect ratio
  27674. */
  27675. getScreenAspectRatio(): number;
  27676. /**
  27677. * Gets the current render width
  27678. * @param useScreen defines if screen size must be used (or the current render target if any)
  27679. * @returns a number defining the current render width
  27680. */
  27681. getRenderWidth(useScreen?: boolean): number;
  27682. /**
  27683. * Gets the current render height
  27684. * @param useScreen defines if screen size must be used (or the current render target if any)
  27685. * @returns a number defining the current render height
  27686. */
  27687. getRenderHeight(useScreen?: boolean): number;
  27688. /**
  27689. * Gets the HTML canvas attached with the current webGL context
  27690. * @returns a HTML canvas
  27691. */
  27692. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27693. /**
  27694. * Gets the client rect of the HTML canvas attached with the current webGL context
  27695. * @returns a client rectanglee
  27696. */
  27697. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27698. /**
  27699. * Defines the hardware scaling level.
  27700. * By default the hardware scaling level is computed from the window device ratio.
  27701. * 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.
  27702. * @param level defines the level to use
  27703. */
  27704. setHardwareScalingLevel(level: number): void;
  27705. /**
  27706. * Gets the current hardware scaling level.
  27707. * By default the hardware scaling level is computed from the window device ratio.
  27708. * 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.
  27709. * @returns a number indicating the current hardware scaling level
  27710. */
  27711. getHardwareScalingLevel(): number;
  27712. /**
  27713. * Gets the list of loaded textures
  27714. * @returns an array containing all loaded textures
  27715. */
  27716. getLoadedTexturesCache(): InternalTexture[];
  27717. /**
  27718. * Gets the object containing all engine capabilities
  27719. * @returns the EngineCapabilities object
  27720. */
  27721. getCaps(): EngineCapabilities;
  27722. /**
  27723. * Gets the current depth function
  27724. * @returns a number defining the depth function
  27725. */
  27726. getDepthFunction(): Nullable<number>;
  27727. /**
  27728. * Sets the current depth function
  27729. * @param depthFunc defines the function to use
  27730. */
  27731. setDepthFunction(depthFunc: number): void;
  27732. /**
  27733. * Sets the current depth function to GREATER
  27734. */
  27735. setDepthFunctionToGreater(): void;
  27736. /**
  27737. * Sets the current depth function to GEQUAL
  27738. */
  27739. setDepthFunctionToGreaterOrEqual(): void;
  27740. /**
  27741. * Sets the current depth function to LESS
  27742. */
  27743. setDepthFunctionToLess(): void;
  27744. /**
  27745. * Sets the current depth function to LEQUAL
  27746. */
  27747. setDepthFunctionToLessOrEqual(): void;
  27748. /**
  27749. * Gets a boolean indicating if stencil buffer is enabled
  27750. * @returns the current stencil buffer state
  27751. */
  27752. getStencilBuffer(): boolean;
  27753. /**
  27754. * Enable or disable the stencil buffer
  27755. * @param enable defines if the stencil buffer must be enabled or disabled
  27756. */
  27757. setStencilBuffer(enable: boolean): void;
  27758. /**
  27759. * Gets the current stencil mask
  27760. * @returns a number defining the new stencil mask to use
  27761. */
  27762. getStencilMask(): number;
  27763. /**
  27764. * Sets the current stencil mask
  27765. * @param mask defines the new stencil mask to use
  27766. */
  27767. setStencilMask(mask: number): void;
  27768. /**
  27769. * Gets the current stencil function
  27770. * @returns a number defining the stencil function to use
  27771. */
  27772. getStencilFunction(): number;
  27773. /**
  27774. * Gets the current stencil reference value
  27775. * @returns a number defining the stencil reference value to use
  27776. */
  27777. getStencilFunctionReference(): number;
  27778. /**
  27779. * Gets the current stencil mask
  27780. * @returns a number defining the stencil mask to use
  27781. */
  27782. getStencilFunctionMask(): number;
  27783. /**
  27784. * Sets the current stencil function
  27785. * @param stencilFunc defines the new stencil function to use
  27786. */
  27787. setStencilFunction(stencilFunc: number): void;
  27788. /**
  27789. * Sets the current stencil reference
  27790. * @param reference defines the new stencil reference to use
  27791. */
  27792. setStencilFunctionReference(reference: number): void;
  27793. /**
  27794. * Sets the current stencil mask
  27795. * @param mask defines the new stencil mask to use
  27796. */
  27797. setStencilFunctionMask(mask: number): void;
  27798. /**
  27799. * Gets the current stencil operation when stencil fails
  27800. * @returns a number defining stencil operation to use when stencil fails
  27801. */
  27802. getStencilOperationFail(): number;
  27803. /**
  27804. * Gets the current stencil operation when depth fails
  27805. * @returns a number defining stencil operation to use when depth fails
  27806. */
  27807. getStencilOperationDepthFail(): number;
  27808. /**
  27809. * Gets the current stencil operation when stencil passes
  27810. * @returns a number defining stencil operation to use when stencil passes
  27811. */
  27812. getStencilOperationPass(): number;
  27813. /**
  27814. * Sets the stencil operation to use when stencil fails
  27815. * @param operation defines the stencil operation to use when stencil fails
  27816. */
  27817. setStencilOperationFail(operation: number): void;
  27818. /**
  27819. * Sets the stencil operation to use when depth fails
  27820. * @param operation defines the stencil operation to use when depth fails
  27821. */
  27822. setStencilOperationDepthFail(operation: number): void;
  27823. /**
  27824. * Sets the stencil operation to use when stencil passes
  27825. * @param operation defines the stencil operation to use when stencil passes
  27826. */
  27827. setStencilOperationPass(operation: number): void;
  27828. /**
  27829. * Sets a boolean indicating if the dithering state is enabled or disabled
  27830. * @param value defines the dithering state
  27831. */
  27832. setDitheringState(value: boolean): void;
  27833. /**
  27834. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27835. * @param value defines the rasterizer state
  27836. */
  27837. setRasterizerState(value: boolean): void;
  27838. /**
  27839. * stop executing a render loop function and remove it from the execution array
  27840. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27841. */
  27842. stopRenderLoop(renderFunction?: () => void): void;
  27843. /** @hidden */
  27844. _renderLoop(): void;
  27845. /**
  27846. * Register and execute a render loop. The engine can have more than one render function
  27847. * @param renderFunction defines the function to continuously execute
  27848. */
  27849. runRenderLoop(renderFunction: () => void): void;
  27850. /**
  27851. * Toggle full screen mode
  27852. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27853. */
  27854. switchFullscreen(requestPointerLock: boolean): void;
  27855. /**
  27856. * Enters full screen mode
  27857. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27858. */
  27859. enterFullscreen(requestPointerLock: boolean): void;
  27860. /**
  27861. * Exits full screen mode
  27862. */
  27863. exitFullscreen(): void;
  27864. /**
  27865. * Clear the current render buffer or the current render target (if any is set up)
  27866. * @param color defines the color to use
  27867. * @param backBuffer defines if the back buffer must be cleared
  27868. * @param depth defines if the depth buffer must be cleared
  27869. * @param stencil defines if the stencil buffer must be cleared
  27870. */
  27871. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27872. /**
  27873. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27874. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27875. * @param y defines the y-coordinate of the corner of the clear rectangle
  27876. * @param width defines the width of the clear rectangle
  27877. * @param height defines the height of the clear rectangle
  27878. * @param clearColor defines the clear color
  27879. */
  27880. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27881. /**
  27882. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27883. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27884. * @param y defines the y-coordinate of the corner of the clear rectangle
  27885. * @param width defines the width of the clear rectangle
  27886. * @param height defines the height of the clear rectangle
  27887. */
  27888. enableScissor(x: number, y: number, width: number, height: number): void;
  27889. /**
  27890. * Disable previously set scissor test rectangle
  27891. */
  27892. disableScissor(): void;
  27893. private _viewportCached;
  27894. /** @hidden */
  27895. _viewport(x: number, y: number, width: number, height: number): void;
  27896. /**
  27897. * Set the WebGL's viewport
  27898. * @param viewport defines the viewport element to be used
  27899. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27900. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27901. */
  27902. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27903. /**
  27904. * Directly set the WebGL Viewport
  27905. * @param x defines the x coordinate of the viewport (in screen space)
  27906. * @param y defines the y coordinate of the viewport (in screen space)
  27907. * @param width defines the width of the viewport (in screen space)
  27908. * @param height defines the height of the viewport (in screen space)
  27909. * @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
  27910. */
  27911. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27912. /**
  27913. * Begin a new frame
  27914. */
  27915. beginFrame(): void;
  27916. /**
  27917. * Enf the current frame
  27918. */
  27919. endFrame(): void;
  27920. /**
  27921. * Resize the view according to the canvas' size
  27922. */
  27923. resize(): void;
  27924. /**
  27925. * Force a specific size of the canvas
  27926. * @param width defines the new canvas' width
  27927. * @param height defines the new canvas' height
  27928. */
  27929. setSize(width: number, height: number): void;
  27930. /**
  27931. * Gets a boolean indicating if a webVR device was detected
  27932. * @returns true if a webVR device was detected
  27933. */
  27934. isVRDevicePresent(): boolean;
  27935. /**
  27936. * Gets the current webVR device
  27937. * @returns the current webVR device (or null)
  27938. */
  27939. getVRDevice(): any;
  27940. /**
  27941. * Initializes a webVR display and starts listening to display change events
  27942. * The onVRDisplayChangedObservable will be notified upon these changes
  27943. * @returns The onVRDisplayChangedObservable
  27944. */
  27945. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27946. /**
  27947. * Initializes a webVR display and starts listening to display change events
  27948. * The onVRDisplayChangedObservable will be notified upon these changes
  27949. * @returns A promise containing a VRDisplay and if vr is supported
  27950. */
  27951. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27952. /**
  27953. * Call this function to switch to webVR mode
  27954. * Will do nothing if webVR is not supported or if there is no webVR device
  27955. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27956. */
  27957. enableVR(): void;
  27958. /**
  27959. * Call this function to leave webVR mode
  27960. * Will do nothing if webVR is not supported or if there is no webVR device
  27961. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27962. */
  27963. disableVR(): void;
  27964. private _onVRFullScreenTriggered;
  27965. private _getVRDisplaysAsync;
  27966. /**
  27967. * Binds the frame buffer to the specified texture.
  27968. * @param texture The texture to render to or null for the default canvas
  27969. * @param faceIndex The face of the texture to render to in case of cube texture
  27970. * @param requiredWidth The width of the target to render to
  27971. * @param requiredHeight The height of the target to render to
  27972. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27973. * @param depthStencilTexture The depth stencil texture to use to render
  27974. * @param lodLevel defines le lod level to bind to the frame buffer
  27975. */
  27976. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27977. private bindUnboundFramebuffer;
  27978. /**
  27979. * Unbind the current render target texture from the webGL context
  27980. * @param texture defines the render target texture to unbind
  27981. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27982. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27983. */
  27984. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27985. /**
  27986. * Unbind a list of render target textures from the webGL context
  27987. * This is used only when drawBuffer extension or webGL2 are active
  27988. * @param textures defines the render target textures to unbind
  27989. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27990. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27991. */
  27992. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27993. /**
  27994. * Force the mipmap generation for the given render target texture
  27995. * @param texture defines the render target texture to use
  27996. */
  27997. generateMipMapsForCubemap(texture: InternalTexture): void;
  27998. /**
  27999. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28000. */
  28001. flushFramebuffer(): void;
  28002. /**
  28003. * Unbind the current render target and bind the default framebuffer
  28004. */
  28005. restoreDefaultFramebuffer(): void;
  28006. /**
  28007. * Create an uniform buffer
  28008. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28009. * @param elements defines the content of the uniform buffer
  28010. * @returns the webGL uniform buffer
  28011. */
  28012. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28013. /**
  28014. * Create a dynamic uniform buffer
  28015. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28016. * @param elements defines the content of the uniform buffer
  28017. * @returns the webGL uniform buffer
  28018. */
  28019. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28020. /**
  28021. * Update an existing uniform buffer
  28022. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28023. * @param uniformBuffer defines the target uniform buffer
  28024. * @param elements defines the content to update
  28025. * @param offset defines the offset in the uniform buffer where update should start
  28026. * @param count defines the size of the data to update
  28027. */
  28028. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28029. private _resetVertexBufferBinding;
  28030. /**
  28031. * Creates a vertex buffer
  28032. * @param data the data for the vertex buffer
  28033. * @returns the new WebGL static buffer
  28034. */
  28035. createVertexBuffer(data: DataArray): WebGLBuffer;
  28036. /**
  28037. * Creates a dynamic vertex buffer
  28038. * @param data the data for the dynamic vertex buffer
  28039. * @returns the new WebGL dynamic buffer
  28040. */
  28041. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28042. /**
  28043. * Update a dynamic index buffer
  28044. * @param indexBuffer defines the target index buffer
  28045. * @param indices defines the data to update
  28046. * @param offset defines the offset in the target index buffer where update should start
  28047. */
  28048. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28049. /**
  28050. * Updates a dynamic vertex buffer.
  28051. * @param vertexBuffer the vertex buffer to update
  28052. * @param data the data used to update the vertex buffer
  28053. * @param byteOffset the byte offset of the data
  28054. * @param byteLength the byte length of the data
  28055. */
  28056. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28057. private _resetIndexBufferBinding;
  28058. /**
  28059. * Creates a new index buffer
  28060. * @param indices defines the content of the index buffer
  28061. * @param updatable defines if the index buffer must be updatable
  28062. * @returns a new webGL buffer
  28063. */
  28064. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28065. /**
  28066. * Bind a webGL buffer to the webGL context
  28067. * @param buffer defines the buffer to bind
  28068. */
  28069. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28070. /**
  28071. * Bind an uniform buffer to the current webGL context
  28072. * @param buffer defines the buffer to bind
  28073. */
  28074. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28075. /**
  28076. * Bind a buffer to the current webGL context at a given location
  28077. * @param buffer defines the buffer to bind
  28078. * @param location defines the index where to bind the buffer
  28079. */
  28080. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28081. /**
  28082. * Bind a specific block at a given index in a specific shader program
  28083. * @param shaderProgram defines the shader program
  28084. * @param blockName defines the block name
  28085. * @param index defines the index where to bind the block
  28086. */
  28087. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28088. private bindIndexBuffer;
  28089. private bindBuffer;
  28090. /**
  28091. * update the bound buffer with the given data
  28092. * @param data defines the data to update
  28093. */
  28094. updateArrayBuffer(data: Float32Array): void;
  28095. private _vertexAttribPointer;
  28096. private _bindIndexBufferWithCache;
  28097. private _bindVertexBuffersAttributes;
  28098. /**
  28099. * Records a vertex array object
  28100. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28101. * @param vertexBuffers defines the list of vertex buffers to store
  28102. * @param indexBuffer defines the index buffer to store
  28103. * @param effect defines the effect to store
  28104. * @returns the new vertex array object
  28105. */
  28106. recordVertexArrayObject(vertexBuffers: {
  28107. [key: string]: VertexBuffer;
  28108. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28109. /**
  28110. * Bind a specific vertex array object
  28111. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28112. * @param vertexArrayObject defines the vertex array object to bind
  28113. * @param indexBuffer defines the index buffer to bind
  28114. */
  28115. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28116. /**
  28117. * Bind webGl buffers directly to the webGL context
  28118. * @param vertexBuffer defines the vertex buffer to bind
  28119. * @param indexBuffer defines the index buffer to bind
  28120. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28121. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28122. * @param effect defines the effect associated with the vertex buffer
  28123. */
  28124. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28125. private _unbindVertexArrayObject;
  28126. /**
  28127. * Bind a list of vertex buffers to the webGL context
  28128. * @param vertexBuffers defines the list of vertex buffers to bind
  28129. * @param indexBuffer defines the index buffer to bind
  28130. * @param effect defines the effect associated with the vertex buffers
  28131. */
  28132. bindBuffers(vertexBuffers: {
  28133. [key: string]: Nullable<VertexBuffer>;
  28134. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28135. /**
  28136. * Unbind all instance attributes
  28137. */
  28138. unbindInstanceAttributes(): void;
  28139. /**
  28140. * Release and free the memory of a vertex array object
  28141. * @param vao defines the vertex array object to delete
  28142. */
  28143. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28144. /** @hidden */
  28145. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28146. /**
  28147. * Creates a webGL buffer to use with instanciation
  28148. * @param capacity defines the size of the buffer
  28149. * @returns the webGL buffer
  28150. */
  28151. createInstancesBuffer(capacity: number): WebGLBuffer;
  28152. /**
  28153. * Delete a webGL buffer used with instanciation
  28154. * @param buffer defines the webGL buffer to delete
  28155. */
  28156. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28157. /**
  28158. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28159. * @param instancesBuffer defines the webGL buffer to update and bind
  28160. * @param data defines the data to store in the buffer
  28161. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28162. */
  28163. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28164. /**
  28165. * Apply all cached states (depth, culling, stencil and alpha)
  28166. */
  28167. applyStates(): void;
  28168. /**
  28169. * Send a draw order
  28170. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28171. * @param indexStart defines the starting index
  28172. * @param indexCount defines the number of index to draw
  28173. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28174. */
  28175. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28176. /**
  28177. * Draw a list of points
  28178. * @param verticesStart defines the index of first vertex to draw
  28179. * @param verticesCount defines the count of vertices to draw
  28180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28181. */
  28182. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28183. /**
  28184. * Draw a list of unindexed primitives
  28185. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28186. * @param verticesStart defines the index of first vertex to draw
  28187. * @param verticesCount defines the count of vertices to draw
  28188. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28189. */
  28190. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28191. /**
  28192. * Draw a list of indexed primitives
  28193. * @param fillMode defines the primitive to use
  28194. * @param indexStart defines the starting index
  28195. * @param indexCount defines the number of index to draw
  28196. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28197. */
  28198. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28199. /**
  28200. * Draw a list of unindexed primitives
  28201. * @param fillMode defines the primitive to use
  28202. * @param verticesStart defines the index of first vertex to draw
  28203. * @param verticesCount defines the count of vertices to draw
  28204. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28205. */
  28206. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28207. private _drawMode;
  28208. /** @hidden */
  28209. _releaseEffect(effect: Effect): void;
  28210. /** @hidden */
  28211. _deleteProgram(program: WebGLProgram): void;
  28212. /**
  28213. * Create a new effect (used to store vertex/fragment shaders)
  28214. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28215. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28216. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28217. * @param samplers defines an array of string used to represent textures
  28218. * @param defines defines the string containing the defines to use to compile the shaders
  28219. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28220. * @param onCompiled defines a function to call when the effect creation is successful
  28221. * @param onError defines a function to call when the effect creation has failed
  28222. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28223. * @returns the new Effect
  28224. */
  28225. 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;
  28226. private _compileShader;
  28227. private _compileRawShader;
  28228. /**
  28229. * Directly creates a webGL program
  28230. * @param vertexCode defines the vertex shader code to use
  28231. * @param fragmentCode defines the fragment shader code to use
  28232. * @param context defines the webGL context to use (if not set, the current one will be used)
  28233. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28234. * @returns the new webGL program
  28235. */
  28236. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28237. /**
  28238. * Creates a webGL program
  28239. * @param vertexCode defines the vertex shader code to use
  28240. * @param fragmentCode defines the fragment shader code to use
  28241. * @param defines defines the string containing the defines to use to compile the shaders
  28242. * @param context defines the webGL context to use (if not set, the current one will be used)
  28243. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28244. * @returns the new webGL program
  28245. */
  28246. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28247. private _createShaderProgram;
  28248. private _finalizeProgram;
  28249. /** @hidden */
  28250. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28251. /** @hidden */
  28252. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28253. /**
  28254. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28255. * @param shaderProgram defines the webGL program to use
  28256. * @param uniformsNames defines the list of uniform names
  28257. * @returns an array of webGL uniform locations
  28258. */
  28259. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28260. /**
  28261. * Gets the lsit of active attributes for a given webGL program
  28262. * @param shaderProgram defines the webGL program to use
  28263. * @param attributesNames defines the list of attribute names to get
  28264. * @returns an array of indices indicating the offset of each attribute
  28265. */
  28266. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28267. /**
  28268. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28269. * @param effect defines the effect to activate
  28270. */
  28271. enableEffect(effect: Nullable<Effect>): void;
  28272. /**
  28273. * Set the value of an uniform to an array of int32
  28274. * @param uniform defines the webGL uniform location where to store the value
  28275. * @param array defines the array of int32 to store
  28276. */
  28277. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28278. /**
  28279. * Set the value of an uniform to an array of int32 (stored as vec2)
  28280. * @param uniform defines the webGL uniform location where to store the value
  28281. * @param array defines the array of int32 to store
  28282. */
  28283. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28284. /**
  28285. * Set the value of an uniform to an array of int32 (stored as vec3)
  28286. * @param uniform defines the webGL uniform location where to store the value
  28287. * @param array defines the array of int32 to store
  28288. */
  28289. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28290. /**
  28291. * Set the value of an uniform to an array of int32 (stored as vec4)
  28292. * @param uniform defines the webGL uniform location where to store the value
  28293. * @param array defines the array of int32 to store
  28294. */
  28295. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28296. /**
  28297. * Set the value of an uniform to an array of float32
  28298. * @param uniform defines the webGL uniform location where to store the value
  28299. * @param array defines the array of float32 to store
  28300. */
  28301. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28302. /**
  28303. * Set the value of an uniform to an array of float32 (stored as vec2)
  28304. * @param uniform defines the webGL uniform location where to store the value
  28305. * @param array defines the array of float32 to store
  28306. */
  28307. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28308. /**
  28309. * Set the value of an uniform to an array of float32 (stored as vec3)
  28310. * @param uniform defines the webGL uniform location where to store the value
  28311. * @param array defines the array of float32 to store
  28312. */
  28313. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28314. /**
  28315. * Set the value of an uniform to an array of float32 (stored as vec4)
  28316. * @param uniform defines the webGL uniform location where to store the value
  28317. * @param array defines the array of float32 to store
  28318. */
  28319. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28320. /**
  28321. * Set the value of an uniform to an array of number
  28322. * @param uniform defines the webGL uniform location where to store the value
  28323. * @param array defines the array of number to store
  28324. */
  28325. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28326. /**
  28327. * Set the value of an uniform to an array of number (stored as vec2)
  28328. * @param uniform defines the webGL uniform location where to store the value
  28329. * @param array defines the array of number to store
  28330. */
  28331. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28332. /**
  28333. * Set the value of an uniform to an array of number (stored as vec3)
  28334. * @param uniform defines the webGL uniform location where to store the value
  28335. * @param array defines the array of number to store
  28336. */
  28337. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28338. /**
  28339. * Set the value of an uniform to an array of number (stored as vec4)
  28340. * @param uniform defines the webGL uniform location where to store the value
  28341. * @param array defines the array of number to store
  28342. */
  28343. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28344. /**
  28345. * Set the value of an uniform to an array of float32 (stored as matrices)
  28346. * @param uniform defines the webGL uniform location where to store the value
  28347. * @param matrices defines the array of float32 to store
  28348. */
  28349. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28350. /**
  28351. * Set the value of an uniform to a matrix
  28352. * @param uniform defines the webGL uniform location where to store the value
  28353. * @param matrix defines the matrix to store
  28354. */
  28355. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28356. /**
  28357. * Set the value of an uniform to a matrix (3x3)
  28358. * @param uniform defines the webGL uniform location where to store the value
  28359. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28360. */
  28361. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28362. /**
  28363. * Set the value of an uniform to a matrix (2x2)
  28364. * @param uniform defines the webGL uniform location where to store the value
  28365. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28366. */
  28367. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28368. /**
  28369. * Set the value of an uniform to a number (int)
  28370. * @param uniform defines the webGL uniform location where to store the value
  28371. * @param value defines the int number to store
  28372. */
  28373. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28374. /**
  28375. * Set the value of an uniform to a number (float)
  28376. * @param uniform defines the webGL uniform location where to store the value
  28377. * @param value defines the float number to store
  28378. */
  28379. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28380. /**
  28381. * Set the value of an uniform to a vec2
  28382. * @param uniform defines the webGL uniform location where to store the value
  28383. * @param x defines the 1st component of the value
  28384. * @param y defines the 2nd component of the value
  28385. */
  28386. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28387. /**
  28388. * Set the value of an uniform to a vec3
  28389. * @param uniform defines the webGL uniform location where to store the value
  28390. * @param x defines the 1st component of the value
  28391. * @param y defines the 2nd component of the value
  28392. * @param z defines the 3rd component of the value
  28393. */
  28394. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28395. /**
  28396. * Set the value of an uniform to a boolean
  28397. * @param uniform defines the webGL uniform location where to store the value
  28398. * @param bool defines the boolean to store
  28399. */
  28400. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28401. /**
  28402. * Set the value of an uniform to a vec4
  28403. * @param uniform defines the webGL uniform location where to store the value
  28404. * @param x defines the 1st component of the value
  28405. * @param y defines the 2nd component of the value
  28406. * @param z defines the 3rd component of the value
  28407. * @param w defines the 4th component of the value
  28408. */
  28409. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28410. /**
  28411. * Set the value of an uniform to a Color3
  28412. * @param uniform defines the webGL uniform location where to store the value
  28413. * @param color3 defines the color to store
  28414. */
  28415. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28416. /**
  28417. * Set the value of an uniform to a Color3 and an alpha value
  28418. * @param uniform defines the webGL uniform location where to store the value
  28419. * @param color3 defines the color to store
  28420. * @param alpha defines the alpha component to store
  28421. */
  28422. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28423. /**
  28424. * Sets a Color4 on a uniform variable
  28425. * @param uniform defines the uniform location
  28426. * @param color4 defines the value to be set
  28427. */
  28428. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28429. /**
  28430. * Set various states to the webGL context
  28431. * @param culling defines backface culling state
  28432. * @param zOffset defines the value to apply to zOffset (0 by default)
  28433. * @param force defines if states must be applied even if cache is up to date
  28434. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28435. */
  28436. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28437. /**
  28438. * Set the z offset to apply to current rendering
  28439. * @param value defines the offset to apply
  28440. */
  28441. setZOffset(value: number): void;
  28442. /**
  28443. * Gets the current value of the zOffset
  28444. * @returns the current zOffset state
  28445. */
  28446. getZOffset(): number;
  28447. /**
  28448. * Enable or disable depth buffering
  28449. * @param enable defines the state to set
  28450. */
  28451. setDepthBuffer(enable: boolean): void;
  28452. /**
  28453. * Gets a boolean indicating if depth writing is enabled
  28454. * @returns the current depth writing state
  28455. */
  28456. getDepthWrite(): boolean;
  28457. /**
  28458. * Enable or disable depth writing
  28459. * @param enable defines the state to set
  28460. */
  28461. setDepthWrite(enable: boolean): void;
  28462. /**
  28463. * Enable or disable color writing
  28464. * @param enable defines the state to set
  28465. */
  28466. setColorWrite(enable: boolean): void;
  28467. /**
  28468. * Gets a boolean indicating if color writing is enabled
  28469. * @returns the current color writing state
  28470. */
  28471. getColorWrite(): boolean;
  28472. /**
  28473. * Sets alpha constants used by some alpha blending modes
  28474. * @param r defines the red component
  28475. * @param g defines the green component
  28476. * @param b defines the blue component
  28477. * @param a defines the alpha component
  28478. */
  28479. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28480. /**
  28481. * Sets the current alpha mode
  28482. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28483. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28484. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28485. */
  28486. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28487. /**
  28488. * Gets the current alpha mode
  28489. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28490. * @returns the current alpha mode
  28491. */
  28492. getAlphaMode(): number;
  28493. /**
  28494. * Clears the list of texture accessible through engine.
  28495. * This can help preventing texture load conflict due to name collision.
  28496. */
  28497. clearInternalTexturesCache(): void;
  28498. /**
  28499. * Force the entire cache to be cleared
  28500. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28501. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28502. */
  28503. wipeCaches(bruteForce?: boolean): void;
  28504. /**
  28505. * Set the compressed texture format to use, based on the formats you have, and the formats
  28506. * supported by the hardware / browser.
  28507. *
  28508. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28509. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28510. * to API arguments needed to compressed textures. This puts the burden on the container
  28511. * generator to house the arcane code for determining these for current & future formats.
  28512. *
  28513. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28514. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28515. *
  28516. * Note: The result of this call is not taken into account when a texture is base64.
  28517. *
  28518. * @param formatsAvailable defines the list of those format families you have created
  28519. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28520. *
  28521. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28522. * @returns The extension selected.
  28523. */
  28524. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28525. private _getSamplingParameters;
  28526. private _partialLoadImg;
  28527. private _cascadeLoadImgs;
  28528. /** @hidden */
  28529. _createTexture(): WebGLTexture;
  28530. /**
  28531. * Usually called from Texture.ts.
  28532. * Passed information to create a WebGLTexture
  28533. * @param urlArg defines a value which contains one of the following:
  28534. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28535. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28536. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28537. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28538. * @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)
  28539. * @param scene needed for loading to the correct scene
  28540. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28541. * @param onLoad optional callback to be called upon successful completion
  28542. * @param onError optional callback to be called upon failure
  28543. * @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
  28544. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28545. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28546. * @param forcedExtension defines the extension to use to pick the right loader
  28547. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28548. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28549. */
  28550. 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;
  28551. private _rescaleTexture;
  28552. /**
  28553. * Update a raw texture
  28554. * @param texture defines the texture to update
  28555. * @param data defines the data to store in the texture
  28556. * @param format defines the format of the data
  28557. * @param invertY defines if data must be stored with Y axis inverted
  28558. * @param compression defines the compression used (null by default)
  28559. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28560. */
  28561. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28562. /**
  28563. * Creates a raw texture
  28564. * @param data defines the data to store in the texture
  28565. * @param width defines the width of the texture
  28566. * @param height defines the height of the texture
  28567. * @param format defines the format of the data
  28568. * @param generateMipMaps defines if the engine should generate the mip levels
  28569. * @param invertY defines if data must be stored with Y axis inverted
  28570. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28571. * @param compression defines the compression used (null by default)
  28572. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28573. * @returns the raw texture inside an InternalTexture
  28574. */
  28575. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28576. private _unpackFlipYCached;
  28577. /**
  28578. * In case you are sharing the context with other applications, it might
  28579. * be interested to not cache the unpack flip y state to ensure a consistent
  28580. * value would be set.
  28581. */
  28582. enableUnpackFlipYCached: boolean;
  28583. /** @hidden */
  28584. _unpackFlipY(value: boolean): void;
  28585. /** @hidden */
  28586. _getUnpackAlignement(): number;
  28587. /**
  28588. * Creates a dynamic texture
  28589. * @param width defines the width of the texture
  28590. * @param height defines the height of the texture
  28591. * @param generateMipMaps defines if the engine should generate the mip levels
  28592. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28593. * @returns the dynamic texture inside an InternalTexture
  28594. */
  28595. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28596. /**
  28597. * Update the sampling mode of a given texture
  28598. * @param samplingMode defines the required sampling mode
  28599. * @param texture defines the texture to update
  28600. */
  28601. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28602. /**
  28603. * Update the content of a dynamic texture
  28604. * @param texture defines the texture to update
  28605. * @param canvas defines the canvas containing the source
  28606. * @param invertY defines if data must be stored with Y axis inverted
  28607. * @param premulAlpha defines if alpha is stored as premultiplied
  28608. * @param format defines the format of the data
  28609. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28610. */
  28611. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28612. /**
  28613. * Update a video texture
  28614. * @param texture defines the texture to update
  28615. * @param video defines the video element to use
  28616. * @param invertY defines if data must be stored with Y axis inverted
  28617. */
  28618. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28619. /**
  28620. * Updates a depth texture Comparison Mode and Function.
  28621. * If the comparison Function is equal to 0, the mode will be set to none.
  28622. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28623. * @param texture The texture to set the comparison function for
  28624. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28625. */
  28626. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28627. private _setupDepthStencilTexture;
  28628. /**
  28629. * Creates a depth stencil texture.
  28630. * This is only available in WebGL 2 or with the depth texture extension available.
  28631. * @param size The size of face edge in the texture.
  28632. * @param options The options defining the texture.
  28633. * @returns The texture
  28634. */
  28635. createDepthStencilTexture(size: number | {
  28636. width: number;
  28637. height: number;
  28638. }, options: DepthTextureCreationOptions): InternalTexture;
  28639. /**
  28640. * Creates a depth stencil texture.
  28641. * This is only available in WebGL 2 or with the depth texture extension available.
  28642. * @param size The size of face edge in the texture.
  28643. * @param options The options defining the texture.
  28644. * @returns The texture
  28645. */
  28646. private _createDepthStencilTexture;
  28647. /**
  28648. * Creates a depth stencil cube texture.
  28649. * This is only available in WebGL 2.
  28650. * @param size The size of face edge in the cube texture.
  28651. * @param options The options defining the cube texture.
  28652. * @returns The cube texture
  28653. */
  28654. private _createDepthStencilCubeTexture;
  28655. /**
  28656. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28657. * @param renderTarget The render target to set the frame buffer for
  28658. */
  28659. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28660. /**
  28661. * Creates a new render target texture
  28662. * @param size defines the size of the texture
  28663. * @param options defines the options used to create the texture
  28664. * @returns a new render target texture stored in an InternalTexture
  28665. */
  28666. createRenderTargetTexture(size: number | {
  28667. width: number;
  28668. height: number;
  28669. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28670. /**
  28671. * Create a multi render target texture
  28672. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28673. * @param size defines the size of the texture
  28674. * @param options defines the creation options
  28675. * @returns the cube texture as an InternalTexture
  28676. */
  28677. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28678. private _setupFramebufferDepthAttachments;
  28679. /**
  28680. * Updates the sample count of a render target texture
  28681. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28682. * @param texture defines the texture to update
  28683. * @param samples defines the sample count to set
  28684. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28685. */
  28686. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28687. /**
  28688. * Update the sample count for a given multiple render target texture
  28689. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28690. * @param textures defines the textures to update
  28691. * @param samples defines the sample count to set
  28692. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28693. */
  28694. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28695. /** @hidden */
  28696. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28697. /** @hidden */
  28698. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28699. /** @hidden */
  28700. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28701. /** @hidden */
  28702. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28703. /**
  28704. * Creates a new render target cube texture
  28705. * @param size defines the size of the texture
  28706. * @param options defines the options used to create the texture
  28707. * @returns a new render target cube texture stored in an InternalTexture
  28708. */
  28709. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28710. /**
  28711. * Creates a cube texture
  28712. * @param rootUrl defines the url where the files to load is located
  28713. * @param scene defines the current scene
  28714. * @param files defines the list of files to load (1 per face)
  28715. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28716. * @param onLoad defines an optional callback raised when the texture is loaded
  28717. * @param onError defines an optional callback raised if there is an issue to load the texture
  28718. * @param format defines the format of the data
  28719. * @param forcedExtension defines the extension to use to pick the right loader
  28720. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28721. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28722. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28723. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28724. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28725. * @returns the cube texture as an InternalTexture
  28726. */
  28727. 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;
  28728. /**
  28729. * @hidden
  28730. */
  28731. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28732. /**
  28733. * Update a raw cube texture
  28734. * @param texture defines the texture to udpdate
  28735. * @param data defines the data to store
  28736. * @param format defines the data format
  28737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28738. * @param invertY defines if data must be stored with Y axis inverted
  28739. * @param compression defines the compression used (null by default)
  28740. * @param level defines which level of the texture to update
  28741. */
  28742. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28743. /**
  28744. * Creates a new raw cube texture
  28745. * @param data defines the array of data to use to create each face
  28746. * @param size defines the size of the textures
  28747. * @param format defines the format of the data
  28748. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28749. * @param generateMipMaps defines if the engine should generate the mip levels
  28750. * @param invertY defines if data must be stored with Y axis inverted
  28751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28752. * @param compression defines the compression used (null by default)
  28753. * @returns the cube texture as an InternalTexture
  28754. */
  28755. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28756. /**
  28757. * Creates a new raw cube texture from a specified url
  28758. * @param url defines the url where the data is located
  28759. * @param scene defines the current scene
  28760. * @param size defines the size of the textures
  28761. * @param format defines the format of the data
  28762. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28763. * @param noMipmap defines if the engine should avoid generating the mip levels
  28764. * @param callback defines a callback used to extract texture data from loaded data
  28765. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28766. * @param onLoad defines a callback called when texture is loaded
  28767. * @param onError defines a callback called if there is an error
  28768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28769. * @param invertY defines if data must be stored with Y axis inverted
  28770. * @returns the cube texture as an InternalTexture
  28771. */
  28772. 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;
  28773. /**
  28774. * Update a raw 3D texture
  28775. * @param texture defines the texture to update
  28776. * @param data defines the data to store
  28777. * @param format defines the data format
  28778. * @param invertY defines if data must be stored with Y axis inverted
  28779. * @param compression defines the used compression (can be null)
  28780. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28781. */
  28782. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28783. /**
  28784. * Creates a new raw 3D texture
  28785. * @param data defines the data used to create the texture
  28786. * @param width defines the width of the texture
  28787. * @param height defines the height of the texture
  28788. * @param depth defines the depth of the texture
  28789. * @param format defines the format of the texture
  28790. * @param generateMipMaps defines if the engine must generate mip levels
  28791. * @param invertY defines if data must be stored with Y axis inverted
  28792. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28793. * @param compression defines the compressed used (can be null)
  28794. * @param textureType defines the compressed used (can be null)
  28795. * @returns a new raw 3D texture (stored in an InternalTexture)
  28796. */
  28797. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28798. private _prepareWebGLTextureContinuation;
  28799. private _prepareWebGLTexture;
  28800. private _convertRGBtoRGBATextureData;
  28801. /** @hidden */
  28802. _releaseFramebufferObjects(texture: InternalTexture): void;
  28803. /** @hidden */
  28804. _releaseTexture(texture: InternalTexture): void;
  28805. private setProgram;
  28806. private _boundUniforms;
  28807. /**
  28808. * Binds an effect to the webGL context
  28809. * @param effect defines the effect to bind
  28810. */
  28811. bindSamplers(effect: Effect): void;
  28812. private _moveBoundTextureOnTop;
  28813. private _getCorrectTextureChannel;
  28814. private _linkTrackers;
  28815. private _removeDesignatedSlot;
  28816. private _activateCurrentTexture;
  28817. /** @hidden */
  28818. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28819. /** @hidden */
  28820. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28821. /**
  28822. * Sets a texture to the webGL context from a postprocess
  28823. * @param channel defines the channel to use
  28824. * @param postProcess defines the source postprocess
  28825. */
  28826. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28827. /**
  28828. * Binds the output of the passed in post process to the texture channel specified
  28829. * @param channel The channel the texture should be bound to
  28830. * @param postProcess The post process which's output should be bound
  28831. */
  28832. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28833. /**
  28834. * Unbind all textures from the webGL context
  28835. */
  28836. unbindAllTextures(): void;
  28837. /**
  28838. * Sets a texture to the according uniform.
  28839. * @param channel The texture channel
  28840. * @param uniform The uniform to set
  28841. * @param texture The texture to apply
  28842. */
  28843. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28844. /**
  28845. * Sets a depth stencil texture from a render target to the according uniform.
  28846. * @param channel The texture channel
  28847. * @param uniform The uniform to set
  28848. * @param texture The render target texture containing the depth stencil texture to apply
  28849. */
  28850. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28851. private _bindSamplerUniformToChannel;
  28852. private _getTextureWrapMode;
  28853. private _setTexture;
  28854. /**
  28855. * Sets an array of texture to the webGL context
  28856. * @param channel defines the channel where the texture array must be set
  28857. * @param uniform defines the associated uniform location
  28858. * @param textures defines the array of textures to bind
  28859. */
  28860. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28861. /** @hidden */
  28862. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28863. private _setTextureParameterFloat;
  28864. private _setTextureParameterInteger;
  28865. /**
  28866. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28867. * @param x defines the x coordinate of the rectangle where pixels must be read
  28868. * @param y defines the y coordinate of the rectangle where pixels must be read
  28869. * @param width defines the width of the rectangle where pixels must be read
  28870. * @param height defines the height of the rectangle where pixels must be read
  28871. * @returns a Uint8Array containing RGBA colors
  28872. */
  28873. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28874. /**
  28875. * Add an externaly attached data from its key.
  28876. * This method call will fail and return false, if such key already exists.
  28877. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28878. * @param key the unique key that identifies the data
  28879. * @param data the data object to associate to the key for this Engine instance
  28880. * @return true if no such key were already present and the data was added successfully, false otherwise
  28881. */
  28882. addExternalData<T>(key: string, data: T): boolean;
  28883. /**
  28884. * Get an externaly attached data from its key
  28885. * @param key the unique key that identifies the data
  28886. * @return the associated data, if present (can be null), or undefined if not present
  28887. */
  28888. getExternalData<T>(key: string): T;
  28889. /**
  28890. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28891. * @param key the unique key that identifies the data
  28892. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28893. * @return the associated data, can be null if the factory returned null.
  28894. */
  28895. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28896. /**
  28897. * Remove an externaly attached data from the Engine instance
  28898. * @param key the unique key that identifies the data
  28899. * @return true if the data was successfully removed, false if it doesn't exist
  28900. */
  28901. removeExternalData(key: string): boolean;
  28902. /**
  28903. * Unbind all vertex attributes from the webGL context
  28904. */
  28905. unbindAllAttributes(): void;
  28906. /**
  28907. * 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
  28908. */
  28909. releaseEffects(): void;
  28910. /**
  28911. * Dispose and release all associated resources
  28912. */
  28913. dispose(): void;
  28914. /**
  28915. * Display the loading screen
  28916. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28917. */
  28918. displayLoadingUI(): void;
  28919. /**
  28920. * Hide the loading screen
  28921. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28922. */
  28923. hideLoadingUI(): void;
  28924. /**
  28925. * Gets the current loading screen object
  28926. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28927. */
  28928. /**
  28929. * Sets the current loading screen object
  28930. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28931. */
  28932. loadingScreen: ILoadingScreen;
  28933. /**
  28934. * Sets the current loading screen text
  28935. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28936. */
  28937. loadingUIText: string;
  28938. /**
  28939. * Sets the current loading screen background color
  28940. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28941. */
  28942. loadingUIBackgroundColor: string;
  28943. /**
  28944. * Attach a new callback raised when context lost event is fired
  28945. * @param callback defines the callback to call
  28946. */
  28947. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28948. /**
  28949. * Attach a new callback raised when context restored event is fired
  28950. * @param callback defines the callback to call
  28951. */
  28952. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28953. /**
  28954. * Gets the source code of the vertex shader associated with a specific webGL program
  28955. * @param program defines the program to use
  28956. * @returns a string containing the source code of the vertex shader associated with the program
  28957. */
  28958. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28959. /**
  28960. * Gets the source code of the fragment shader associated with a specific webGL program
  28961. * @param program defines the program to use
  28962. * @returns a string containing the source code of the fragment shader associated with the program
  28963. */
  28964. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28965. /**
  28966. * Get the current error code of the webGL context
  28967. * @returns the error code
  28968. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28969. */
  28970. getError(): number;
  28971. /**
  28972. * Gets the current framerate
  28973. * @returns a number representing the framerate
  28974. */
  28975. getFps(): number;
  28976. /**
  28977. * Gets the time spent between current and previous frame
  28978. * @returns a number representing the delta time in ms
  28979. */
  28980. getDeltaTime(): number;
  28981. private _measureFps;
  28982. /** @hidden */
  28983. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28984. private _canRenderToFloatFramebuffer;
  28985. private _canRenderToHalfFloatFramebuffer;
  28986. private _canRenderToFramebuffer;
  28987. /** @hidden */
  28988. _getWebGLTextureType(type: number): number;
  28989. private _getInternalFormat;
  28990. /** @hidden */
  28991. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28992. /** @hidden */
  28993. _getRGBAMultiSampleBufferFormat(type: number): number;
  28994. /** @hidden */
  28995. _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;
  28996. /** @hidden */
  28997. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28998. private _partialLoadFile;
  28999. private _cascadeLoadFiles;
  29000. /**
  29001. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29002. * @returns true if the engine can be created
  29003. * @ignorenaming
  29004. */
  29005. static isSupported(): boolean;
  29006. }
  29007. }
  29008. declare module "babylonjs/Materials/effect" {
  29009. import { Observable } from "babylonjs/Misc/observable";
  29010. import { Nullable } from "babylonjs/types";
  29011. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29012. import { Engine } from "babylonjs/Engines/engine";
  29013. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29018. /**
  29019. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29020. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29021. */
  29022. export class EffectFallbacks {
  29023. private _defines;
  29024. private _currentRank;
  29025. private _maxRank;
  29026. private _mesh;
  29027. /**
  29028. * Removes the fallback from the bound mesh.
  29029. */
  29030. unBindMesh(): void;
  29031. /**
  29032. * Adds a fallback on the specified property.
  29033. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29034. * @param define The name of the define in the shader
  29035. */
  29036. addFallback(rank: number, define: string): void;
  29037. /**
  29038. * Sets the mesh to use CPU skinning when needing to fallback.
  29039. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29040. * @param mesh The mesh to use the fallbacks.
  29041. */
  29042. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29043. /**
  29044. * Checks to see if more fallbacks are still availible.
  29045. */
  29046. readonly isMoreFallbacks: boolean;
  29047. /**
  29048. * Removes the defines that shoould be removed when falling back.
  29049. * @param currentDefines defines the current define statements for the shader.
  29050. * @param effect defines the current effect we try to compile
  29051. * @returns The resulting defines with defines of the current rank removed.
  29052. */
  29053. reduce(currentDefines: string, effect: Effect): string;
  29054. }
  29055. /**
  29056. * Options to be used when creating an effect.
  29057. */
  29058. export class EffectCreationOptions {
  29059. /**
  29060. * Atrributes that will be used in the shader.
  29061. */
  29062. attributes: string[];
  29063. /**
  29064. * Uniform varible names that will be set in the shader.
  29065. */
  29066. uniformsNames: string[];
  29067. /**
  29068. * Uniform buffer varible names that will be set in the shader.
  29069. */
  29070. uniformBuffersNames: string[];
  29071. /**
  29072. * Sampler texture variable names that will be set in the shader.
  29073. */
  29074. samplers: string[];
  29075. /**
  29076. * Define statements that will be set in the shader.
  29077. */
  29078. defines: any;
  29079. /**
  29080. * Possible fallbacks for this effect to improve performance when needed.
  29081. */
  29082. fallbacks: Nullable<EffectFallbacks>;
  29083. /**
  29084. * Callback that will be called when the shader is compiled.
  29085. */
  29086. onCompiled: Nullable<(effect: Effect) => void>;
  29087. /**
  29088. * Callback that will be called if an error occurs during shader compilation.
  29089. */
  29090. onError: Nullable<(effect: Effect, errors: string) => void>;
  29091. /**
  29092. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29093. */
  29094. indexParameters: any;
  29095. /**
  29096. * Max number of lights that can be used in the shader.
  29097. */
  29098. maxSimultaneousLights: number;
  29099. /**
  29100. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29101. */
  29102. transformFeedbackVaryings: Nullable<string[]>;
  29103. }
  29104. /**
  29105. * Effect containing vertex and fragment shader that can be executed on an object.
  29106. */
  29107. export class Effect {
  29108. /**
  29109. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29110. */
  29111. static ShadersRepository: string;
  29112. /**
  29113. * Name of the effect.
  29114. */
  29115. name: any;
  29116. /**
  29117. * String container all the define statements that should be set on the shader.
  29118. */
  29119. defines: string;
  29120. /**
  29121. * Callback that will be called when the shader is compiled.
  29122. */
  29123. onCompiled: Nullable<(effect: Effect) => void>;
  29124. /**
  29125. * Callback that will be called if an error occurs during shader compilation.
  29126. */
  29127. onError: Nullable<(effect: Effect, errors: string) => void>;
  29128. /**
  29129. * Callback that will be called when effect is bound.
  29130. */
  29131. onBind: Nullable<(effect: Effect) => void>;
  29132. /**
  29133. * Unique ID of the effect.
  29134. */
  29135. uniqueId: number;
  29136. /**
  29137. * Observable that will be called when the shader is compiled.
  29138. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29139. */
  29140. onCompileObservable: Observable<Effect>;
  29141. /**
  29142. * Observable that will be called if an error occurs during shader compilation.
  29143. */
  29144. onErrorObservable: Observable<Effect>;
  29145. /** @hidden */
  29146. _onBindObservable: Nullable<Observable<Effect>>;
  29147. /**
  29148. * Observable that will be called when effect is bound.
  29149. */
  29150. readonly onBindObservable: Observable<Effect>;
  29151. /** @hidden */
  29152. _bonesComputationForcedToCPU: boolean;
  29153. private static _uniqueIdSeed;
  29154. private _engine;
  29155. private _uniformBuffersNames;
  29156. private _uniformsNames;
  29157. private _samplers;
  29158. private _isReady;
  29159. private _compilationError;
  29160. private _attributesNames;
  29161. private _attributes;
  29162. private _uniforms;
  29163. /**
  29164. * Key for the effect.
  29165. * @hidden
  29166. */
  29167. _key: string;
  29168. private _indexParameters;
  29169. private _fallbacks;
  29170. private _vertexSourceCode;
  29171. private _fragmentSourceCode;
  29172. private _vertexSourceCodeOverride;
  29173. private _fragmentSourceCodeOverride;
  29174. private _transformFeedbackVaryings;
  29175. /**
  29176. * Compiled shader to webGL program.
  29177. * @hidden
  29178. */
  29179. _program: WebGLProgram;
  29180. private _valueCache;
  29181. private static _baseCache;
  29182. /**
  29183. * Instantiates an effect.
  29184. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29185. * @param baseName Name of the effect.
  29186. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29187. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29188. * @param samplers List of sampler variables that will be passed to the shader.
  29189. * @param engine Engine to be used to render the effect
  29190. * @param defines Define statements to be added to the shader.
  29191. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29192. * @param onCompiled Callback that will be called when the shader is compiled.
  29193. * @param onError Callback that will be called if an error occurs during shader compilation.
  29194. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29195. */
  29196. 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);
  29197. /**
  29198. * Unique key for this effect
  29199. */
  29200. readonly key: string;
  29201. /**
  29202. * If the effect has been compiled and prepared.
  29203. * @returns if the effect is compiled and prepared.
  29204. */
  29205. isReady(): boolean;
  29206. /**
  29207. * The engine the effect was initialized with.
  29208. * @returns the engine.
  29209. */
  29210. getEngine(): Engine;
  29211. /**
  29212. * The compiled webGL program for the effect
  29213. * @returns the webGL program.
  29214. */
  29215. getProgram(): WebGLProgram;
  29216. /**
  29217. * The set of names of attribute variables for the shader.
  29218. * @returns An array of attribute names.
  29219. */
  29220. getAttributesNames(): string[];
  29221. /**
  29222. * Returns the attribute at the given index.
  29223. * @param index The index of the attribute.
  29224. * @returns The location of the attribute.
  29225. */
  29226. getAttributeLocation(index: number): number;
  29227. /**
  29228. * Returns the attribute based on the name of the variable.
  29229. * @param name of the attribute to look up.
  29230. * @returns the attribute location.
  29231. */
  29232. getAttributeLocationByName(name: string): number;
  29233. /**
  29234. * The number of attributes.
  29235. * @returns the numnber of attributes.
  29236. */
  29237. getAttributesCount(): number;
  29238. /**
  29239. * Gets the index of a uniform variable.
  29240. * @param uniformName of the uniform to look up.
  29241. * @returns the index.
  29242. */
  29243. getUniformIndex(uniformName: string): number;
  29244. /**
  29245. * Returns the attribute based on the name of the variable.
  29246. * @param uniformName of the uniform to look up.
  29247. * @returns the location of the uniform.
  29248. */
  29249. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29250. /**
  29251. * Returns an array of sampler variable names
  29252. * @returns The array of sampler variable neames.
  29253. */
  29254. getSamplers(): string[];
  29255. /**
  29256. * The error from the last compilation.
  29257. * @returns the error string.
  29258. */
  29259. getCompilationError(): string;
  29260. /**
  29261. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29262. * @param func The callback to be used.
  29263. */
  29264. executeWhenCompiled(func: (effect: Effect) => void): void;
  29265. private _checkIsReady;
  29266. /** @hidden */
  29267. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29268. /** @hidden */
  29269. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29270. /** @hidden */
  29271. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29272. private _processShaderConversion;
  29273. private _processIncludes;
  29274. private _processPrecision;
  29275. /**
  29276. * Recompiles the webGL program
  29277. * @param vertexSourceCode The source code for the vertex shader.
  29278. * @param fragmentSourceCode The source code for the fragment shader.
  29279. * @param onCompiled Callback called when completed.
  29280. * @param onError Callback called on error.
  29281. * @hidden
  29282. */
  29283. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29284. /**
  29285. * Gets the uniform locations of the the specified variable names
  29286. * @param names THe names of the variables to lookup.
  29287. * @returns Array of locations in the same order as variable names.
  29288. */
  29289. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29290. /**
  29291. * Prepares the effect
  29292. * @hidden
  29293. */
  29294. _prepareEffect(): void;
  29295. /**
  29296. * Checks if the effect is supported. (Must be called after compilation)
  29297. */
  29298. readonly isSupported: boolean;
  29299. /**
  29300. * Binds a texture to the engine to be used as output of the shader.
  29301. * @param channel Name of the output variable.
  29302. * @param texture Texture to bind.
  29303. * @hidden
  29304. */
  29305. _bindTexture(channel: string, texture: InternalTexture): void;
  29306. /**
  29307. * Sets a texture on the engine to be used in the shader.
  29308. * @param channel Name of the sampler variable.
  29309. * @param texture Texture to set.
  29310. */
  29311. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29312. /**
  29313. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29314. * @param channel Name of the sampler variable.
  29315. * @param texture Texture to set.
  29316. */
  29317. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29318. /**
  29319. * Sets an array of textures on the engine to be used in the shader.
  29320. * @param channel Name of the variable.
  29321. * @param textures Textures to set.
  29322. */
  29323. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29324. /**
  29325. * 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)
  29326. * @param channel Name of the sampler variable.
  29327. * @param postProcess Post process to get the input texture from.
  29328. */
  29329. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29330. /**
  29331. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29332. * 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)
  29333. * @param channel Name of the sampler variable.
  29334. * @param postProcess Post process to get the output texture from.
  29335. */
  29336. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29337. /** @hidden */
  29338. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29339. /** @hidden */
  29340. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29341. /** @hidden */
  29342. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29343. /** @hidden */
  29344. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29345. /**
  29346. * Binds a buffer to a uniform.
  29347. * @param buffer Buffer to bind.
  29348. * @param name Name of the uniform variable to bind to.
  29349. */
  29350. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29351. /**
  29352. * Binds block to a uniform.
  29353. * @param blockName Name of the block to bind.
  29354. * @param index Index to bind.
  29355. */
  29356. bindUniformBlock(blockName: string, index: number): void;
  29357. /**
  29358. * Sets an interger value on a uniform variable.
  29359. * @param uniformName Name of the variable.
  29360. * @param value Value to be set.
  29361. * @returns this effect.
  29362. */
  29363. setInt(uniformName: string, value: number): Effect;
  29364. /**
  29365. * Sets an int array on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param array array to be set.
  29368. * @returns this effect.
  29369. */
  29370. setIntArray(uniformName: string, array: Int32Array): Effect;
  29371. /**
  29372. * 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)
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29378. /**
  29379. * 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)
  29380. * @param uniformName Name of the variable.
  29381. * @param array array to be set.
  29382. * @returns this effect.
  29383. */
  29384. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param array array to be set.
  29389. * @returns this effect.
  29390. */
  29391. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29392. /**
  29393. * Sets an float array on a uniform variable.
  29394. * @param uniformName Name of the variable.
  29395. * @param array array to be set.
  29396. * @returns this effect.
  29397. */
  29398. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29399. /**
  29400. * 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)
  29401. * @param uniformName Name of the variable.
  29402. * @param array array to be set.
  29403. * @returns this effect.
  29404. */
  29405. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29406. /**
  29407. * 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)
  29408. * @param uniformName Name of the variable.
  29409. * @param array array to be set.
  29410. * @returns this effect.
  29411. */
  29412. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29413. /**
  29414. * 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)
  29415. * @param uniformName Name of the variable.
  29416. * @param array array to be set.
  29417. * @returns this effect.
  29418. */
  29419. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29420. /**
  29421. * Sets an array on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param array array to be set.
  29424. * @returns this effect.
  29425. */
  29426. setArray(uniformName: string, array: number[]): Effect;
  29427. /**
  29428. * 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)
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setArray2(uniformName: string, array: number[]): Effect;
  29434. /**
  29435. * 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)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setArray3(uniformName: string, array: number[]): Effect;
  29441. /**
  29442. * 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)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setArray4(uniformName: string, array: number[]): Effect;
  29448. /**
  29449. * Sets matrices on a uniform variable.
  29450. * @param uniformName Name of the variable.
  29451. * @param matrices matrices to be set.
  29452. * @returns this effect.
  29453. */
  29454. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29455. /**
  29456. * Sets matrix on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param matrix matrix to be set.
  29459. * @returns this effect.
  29460. */
  29461. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29462. /**
  29463. * 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)
  29464. * @param uniformName Name of the variable.
  29465. * @param matrix matrix to be set.
  29466. * @returns this effect.
  29467. */
  29468. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29469. /**
  29470. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29471. * @param uniformName Name of the variable.
  29472. * @param matrix matrix to be set.
  29473. * @returns this effect.
  29474. */
  29475. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29476. /**
  29477. * Sets a float on a uniform variable.
  29478. * @param uniformName Name of the variable.
  29479. * @param value value to be set.
  29480. * @returns this effect.
  29481. */
  29482. setFloat(uniformName: string, value: number): Effect;
  29483. /**
  29484. * Sets a boolean on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param bool value to be set.
  29487. * @returns this effect.
  29488. */
  29489. setBool(uniformName: string, bool: boolean): Effect;
  29490. /**
  29491. * Sets a Vector2 on a uniform variable.
  29492. * @param uniformName Name of the variable.
  29493. * @param vector2 vector2 to be set.
  29494. * @returns this effect.
  29495. */
  29496. setVector2(uniformName: string, vector2: Vector2): Effect;
  29497. /**
  29498. * Sets a float2 on a uniform variable.
  29499. * @param uniformName Name of the variable.
  29500. * @param x First float in float2.
  29501. * @param y Second float in float2.
  29502. * @returns this effect.
  29503. */
  29504. setFloat2(uniformName: string, x: number, y: number): Effect;
  29505. /**
  29506. * Sets a Vector3 on a uniform variable.
  29507. * @param uniformName Name of the variable.
  29508. * @param vector3 Value to be set.
  29509. * @returns this effect.
  29510. */
  29511. setVector3(uniformName: string, vector3: Vector3): Effect;
  29512. /**
  29513. * Sets a float3 on a uniform variable.
  29514. * @param uniformName Name of the variable.
  29515. * @param x First float in float3.
  29516. * @param y Second float in float3.
  29517. * @param z Third float in float3.
  29518. * @returns this effect.
  29519. */
  29520. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29521. /**
  29522. * Sets a Vector4 on a uniform variable.
  29523. * @param uniformName Name of the variable.
  29524. * @param vector4 Value to be set.
  29525. * @returns this effect.
  29526. */
  29527. setVector4(uniformName: string, vector4: Vector4): Effect;
  29528. /**
  29529. * Sets a float4 on a uniform variable.
  29530. * @param uniformName Name of the variable.
  29531. * @param x First float in float4.
  29532. * @param y Second float in float4.
  29533. * @param z Third float in float4.
  29534. * @param w Fourth float in float4.
  29535. * @returns this effect.
  29536. */
  29537. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29538. /**
  29539. * Sets a Color3 on a uniform variable.
  29540. * @param uniformName Name of the variable.
  29541. * @param color3 Value to be set.
  29542. * @returns this effect.
  29543. */
  29544. setColor3(uniformName: string, color3: Color3): Effect;
  29545. /**
  29546. * Sets a Color4 on a uniform variable.
  29547. * @param uniformName Name of the variable.
  29548. * @param color3 Value to be set.
  29549. * @param alpha Alpha value to be set.
  29550. * @returns this effect.
  29551. */
  29552. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29553. /**
  29554. * Sets a Color4 on a uniform variable
  29555. * @param uniformName defines the name of the variable
  29556. * @param color4 defines the value to be set
  29557. * @returns this effect.
  29558. */
  29559. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29560. /**
  29561. * This function will add a new shader to the shader store
  29562. * @param name the name of the shader
  29563. * @param pixelShader optional pixel shader content
  29564. * @param vertexShader optional vertex shader content
  29565. */
  29566. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29567. /**
  29568. * Store of each shader (The can be looked up using effect.key)
  29569. */
  29570. static ShadersStore: {
  29571. [key: string]: string;
  29572. };
  29573. /**
  29574. * Store of each included file for a shader (The can be looked up using effect.key)
  29575. */
  29576. static IncludesShadersStore: {
  29577. [key: string]: string;
  29578. };
  29579. /**
  29580. * Resets the cache of effects.
  29581. */
  29582. static ResetCache(): void;
  29583. }
  29584. }
  29585. declare module "babylonjs/Materials/colorCurves" {
  29586. import { Effect } from "babylonjs/Materials/effect";
  29587. /**
  29588. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29589. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29590. * 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;
  29591. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29592. */
  29593. export class ColorCurves {
  29594. private _dirty;
  29595. private _tempColor;
  29596. private _globalCurve;
  29597. private _highlightsCurve;
  29598. private _midtonesCurve;
  29599. private _shadowsCurve;
  29600. private _positiveCurve;
  29601. private _negativeCurve;
  29602. private _globalHue;
  29603. private _globalDensity;
  29604. private _globalSaturation;
  29605. private _globalExposure;
  29606. /**
  29607. * Gets the global Hue value.
  29608. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29609. */
  29610. /**
  29611. * Sets the global Hue value.
  29612. * 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).
  29613. */
  29614. globalHue: number;
  29615. /**
  29616. * Gets the global Density value.
  29617. * 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.
  29618. * Values less than zero provide a filter of opposite hue.
  29619. */
  29620. /**
  29621. * Sets the global Density value.
  29622. * 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.
  29623. * Values less than zero provide a filter of opposite hue.
  29624. */
  29625. globalDensity: number;
  29626. /**
  29627. * Gets the global Saturation value.
  29628. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29629. */
  29630. /**
  29631. * Sets the global Saturation value.
  29632. * 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.
  29633. */
  29634. globalSaturation: number;
  29635. /**
  29636. * Gets the global Exposure value.
  29637. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29638. */
  29639. /**
  29640. * Sets the global Exposure value.
  29641. * 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.
  29642. */
  29643. globalExposure: number;
  29644. private _highlightsHue;
  29645. private _highlightsDensity;
  29646. private _highlightsSaturation;
  29647. private _highlightsExposure;
  29648. /**
  29649. * Gets the highlights Hue value.
  29650. * 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).
  29651. */
  29652. /**
  29653. * Sets the highlights Hue value.
  29654. * 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).
  29655. */
  29656. highlightsHue: number;
  29657. /**
  29658. * Gets the highlights Density value.
  29659. * 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.
  29660. * Values less than zero provide a filter of opposite hue.
  29661. */
  29662. /**
  29663. * Sets the highlights Density value.
  29664. * 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.
  29665. * Values less than zero provide a filter of opposite hue.
  29666. */
  29667. highlightsDensity: number;
  29668. /**
  29669. * Gets the highlights Saturation value.
  29670. * 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.
  29671. */
  29672. /**
  29673. * Sets the highlights Saturation value.
  29674. * 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.
  29675. */
  29676. highlightsSaturation: number;
  29677. /**
  29678. * Gets the highlights Exposure value.
  29679. * 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.
  29680. */
  29681. /**
  29682. * Sets the highlights Exposure value.
  29683. * 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.
  29684. */
  29685. highlightsExposure: number;
  29686. private _midtonesHue;
  29687. private _midtonesDensity;
  29688. private _midtonesSaturation;
  29689. private _midtonesExposure;
  29690. /**
  29691. * Gets the midtones Hue value.
  29692. * 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).
  29693. */
  29694. /**
  29695. * Sets the midtones Hue value.
  29696. * 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).
  29697. */
  29698. midtonesHue: number;
  29699. /**
  29700. * Gets the midtones Density value.
  29701. * 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.
  29702. * Values less than zero provide a filter of opposite hue.
  29703. */
  29704. /**
  29705. * Sets the midtones Density value.
  29706. * 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.
  29707. * Values less than zero provide a filter of opposite hue.
  29708. */
  29709. midtonesDensity: number;
  29710. /**
  29711. * Gets the midtones Saturation value.
  29712. * 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.
  29713. */
  29714. /**
  29715. * Sets the midtones Saturation value.
  29716. * 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.
  29717. */
  29718. midtonesSaturation: number;
  29719. /**
  29720. * Gets the midtones Exposure value.
  29721. * 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.
  29722. */
  29723. /**
  29724. * Sets the midtones Exposure value.
  29725. * 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.
  29726. */
  29727. midtonesExposure: number;
  29728. private _shadowsHue;
  29729. private _shadowsDensity;
  29730. private _shadowsSaturation;
  29731. private _shadowsExposure;
  29732. /**
  29733. * Gets the shadows Hue value.
  29734. * 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).
  29735. */
  29736. /**
  29737. * Sets the shadows Hue value.
  29738. * 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).
  29739. */
  29740. shadowsHue: number;
  29741. /**
  29742. * Gets the shadows Density value.
  29743. * 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.
  29744. * Values less than zero provide a filter of opposite hue.
  29745. */
  29746. /**
  29747. * Sets the shadows Density value.
  29748. * 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.
  29749. * Values less than zero provide a filter of opposite hue.
  29750. */
  29751. shadowsDensity: number;
  29752. /**
  29753. * Gets the shadows Saturation value.
  29754. * 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.
  29755. */
  29756. /**
  29757. * Sets the shadows Saturation value.
  29758. * 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.
  29759. */
  29760. shadowsSaturation: number;
  29761. /**
  29762. * Gets the shadows Exposure value.
  29763. * 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.
  29764. */
  29765. /**
  29766. * Sets the shadows Exposure value.
  29767. * 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.
  29768. */
  29769. shadowsExposure: number;
  29770. /**
  29771. * Returns the class name
  29772. * @returns The class name
  29773. */
  29774. getClassName(): string;
  29775. /**
  29776. * Binds the color curves to the shader.
  29777. * @param colorCurves The color curve to bind
  29778. * @param effect The effect to bind to
  29779. * @param positiveUniform The positive uniform shader parameter
  29780. * @param neutralUniform The neutral uniform shader parameter
  29781. * @param negativeUniform The negative uniform shader parameter
  29782. */
  29783. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29784. /**
  29785. * Prepare the list of uniforms associated with the ColorCurves effects.
  29786. * @param uniformsList The list of uniforms used in the effect
  29787. */
  29788. static PrepareUniforms(uniformsList: string[]): void;
  29789. /**
  29790. * Returns color grading data based on a hue, density, saturation and exposure value.
  29791. * @param filterHue The hue of the color filter.
  29792. * @param filterDensity The density of the color filter.
  29793. * @param saturation The saturation.
  29794. * @param exposure The exposure.
  29795. * @param result The result data container.
  29796. */
  29797. private getColorGradingDataToRef;
  29798. /**
  29799. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29800. * @param value The input slider value in range [-100,100].
  29801. * @returns Adjusted value.
  29802. */
  29803. private static applyColorGradingSliderNonlinear;
  29804. /**
  29805. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29806. * @param hue The hue (H) input.
  29807. * @param saturation The saturation (S) input.
  29808. * @param brightness The brightness (B) input.
  29809. * @result An RGBA color represented as Vector4.
  29810. */
  29811. private static fromHSBToRef;
  29812. /**
  29813. * Returns a value clamped between min and max
  29814. * @param value The value to clamp
  29815. * @param min The minimum of value
  29816. * @param max The maximum of value
  29817. * @returns The clamped value.
  29818. */
  29819. private static clamp;
  29820. /**
  29821. * Clones the current color curve instance.
  29822. * @return The cloned curves
  29823. */
  29824. clone(): ColorCurves;
  29825. /**
  29826. * Serializes the current color curve instance to a json representation.
  29827. * @return a JSON representation
  29828. */
  29829. serialize(): any;
  29830. /**
  29831. * Parses the color curve from a json representation.
  29832. * @param source the JSON source to parse
  29833. * @return The parsed curves
  29834. */
  29835. static Parse(source: any): ColorCurves;
  29836. }
  29837. }
  29838. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29839. import { Observable } from "babylonjs/Misc/observable";
  29840. import { Nullable } from "babylonjs/types";
  29841. import { Color4 } from "babylonjs/Maths/math";
  29842. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29843. import { Effect } from "babylonjs/Materials/effect";
  29844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29845. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29846. /**
  29847. * Interface to follow in your material defines to integrate easily the
  29848. * Image proccessing functions.
  29849. * @hidden
  29850. */
  29851. export interface IImageProcessingConfigurationDefines {
  29852. IMAGEPROCESSING: boolean;
  29853. VIGNETTE: boolean;
  29854. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29855. VIGNETTEBLENDMODEOPAQUE: boolean;
  29856. TONEMAPPING: boolean;
  29857. TONEMAPPING_ACES: boolean;
  29858. CONTRAST: boolean;
  29859. EXPOSURE: boolean;
  29860. COLORCURVES: boolean;
  29861. COLORGRADING: boolean;
  29862. COLORGRADING3D: boolean;
  29863. SAMPLER3DGREENDEPTH: boolean;
  29864. SAMPLER3DBGRMAP: boolean;
  29865. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29866. }
  29867. /**
  29868. * @hidden
  29869. */
  29870. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29871. IMAGEPROCESSING: boolean;
  29872. VIGNETTE: boolean;
  29873. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29874. VIGNETTEBLENDMODEOPAQUE: boolean;
  29875. TONEMAPPING: boolean;
  29876. TONEMAPPING_ACES: boolean;
  29877. CONTRAST: boolean;
  29878. COLORCURVES: boolean;
  29879. COLORGRADING: boolean;
  29880. COLORGRADING3D: boolean;
  29881. SAMPLER3DGREENDEPTH: boolean;
  29882. SAMPLER3DBGRMAP: boolean;
  29883. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29884. EXPOSURE: boolean;
  29885. constructor();
  29886. }
  29887. /**
  29888. * This groups together the common properties used for image processing either in direct forward pass
  29889. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29890. * or not.
  29891. */
  29892. export class ImageProcessingConfiguration {
  29893. /**
  29894. * Default tone mapping applied in BabylonJS.
  29895. */
  29896. static readonly TONEMAPPING_STANDARD: number;
  29897. /**
  29898. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29899. * to other engines rendering to increase portability.
  29900. */
  29901. static readonly TONEMAPPING_ACES: number;
  29902. /**
  29903. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29904. */
  29905. colorCurves: Nullable<ColorCurves>;
  29906. private _colorCurvesEnabled;
  29907. /**
  29908. * Gets wether the color curves effect is enabled.
  29909. */
  29910. /**
  29911. * Sets wether the color curves effect is enabled.
  29912. */
  29913. colorCurvesEnabled: boolean;
  29914. private _colorGradingTexture;
  29915. /**
  29916. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29917. */
  29918. /**
  29919. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29920. */
  29921. colorGradingTexture: Nullable<BaseTexture>;
  29922. private _colorGradingEnabled;
  29923. /**
  29924. * Gets wether the color grading effect is enabled.
  29925. */
  29926. /**
  29927. * Sets wether the color grading effect is enabled.
  29928. */
  29929. colorGradingEnabled: boolean;
  29930. private _colorGradingWithGreenDepth;
  29931. /**
  29932. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29933. */
  29934. /**
  29935. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29936. */
  29937. colorGradingWithGreenDepth: boolean;
  29938. private _colorGradingBGR;
  29939. /**
  29940. * Gets wether the color grading texture contains BGR values.
  29941. */
  29942. /**
  29943. * Sets wether the color grading texture contains BGR values.
  29944. */
  29945. colorGradingBGR: boolean;
  29946. /** @hidden */
  29947. _exposure: number;
  29948. /**
  29949. * Gets the Exposure used in the effect.
  29950. */
  29951. /**
  29952. * Sets the Exposure used in the effect.
  29953. */
  29954. exposure: number;
  29955. private _toneMappingEnabled;
  29956. /**
  29957. * Gets wether the tone mapping effect is enabled.
  29958. */
  29959. /**
  29960. * Sets wether the tone mapping effect is enabled.
  29961. */
  29962. toneMappingEnabled: boolean;
  29963. private _toneMappingType;
  29964. /**
  29965. * Gets the type of tone mapping effect.
  29966. */
  29967. /**
  29968. * Sets the type of tone mapping effect used in BabylonJS.
  29969. */
  29970. toneMappingType: number;
  29971. protected _contrast: number;
  29972. /**
  29973. * Gets the contrast used in the effect.
  29974. */
  29975. /**
  29976. * Sets the contrast used in the effect.
  29977. */
  29978. contrast: number;
  29979. /**
  29980. * Vignette stretch size.
  29981. */
  29982. vignetteStretch: number;
  29983. /**
  29984. * Vignette centre X Offset.
  29985. */
  29986. vignetteCentreX: number;
  29987. /**
  29988. * Vignette centre Y Offset.
  29989. */
  29990. vignetteCentreY: number;
  29991. /**
  29992. * Vignette weight or intensity of the vignette effect.
  29993. */
  29994. vignetteWeight: number;
  29995. /**
  29996. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29997. * if vignetteEnabled is set to true.
  29998. */
  29999. vignetteColor: Color4;
  30000. /**
  30001. * Camera field of view used by the Vignette effect.
  30002. */
  30003. vignetteCameraFov: number;
  30004. private _vignetteBlendMode;
  30005. /**
  30006. * Gets the vignette blend mode allowing different kind of effect.
  30007. */
  30008. /**
  30009. * Sets the vignette blend mode allowing different kind of effect.
  30010. */
  30011. vignetteBlendMode: number;
  30012. private _vignetteEnabled;
  30013. /**
  30014. * Gets wether the vignette effect is enabled.
  30015. */
  30016. /**
  30017. * Sets wether the vignette effect is enabled.
  30018. */
  30019. vignetteEnabled: boolean;
  30020. private _applyByPostProcess;
  30021. /**
  30022. * Gets wether the image processing is applied through a post process or not.
  30023. */
  30024. /**
  30025. * Sets wether the image processing is applied through a post process or not.
  30026. */
  30027. applyByPostProcess: boolean;
  30028. private _isEnabled;
  30029. /**
  30030. * Gets wether the image processing is enabled or not.
  30031. */
  30032. /**
  30033. * Sets wether the image processing is enabled or not.
  30034. */
  30035. isEnabled: boolean;
  30036. /**
  30037. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30038. */
  30039. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30040. /**
  30041. * Method called each time the image processing information changes requires to recompile the effect.
  30042. */
  30043. protected _updateParameters(): void;
  30044. /**
  30045. * Gets the current class name.
  30046. * @return "ImageProcessingConfiguration"
  30047. */
  30048. getClassName(): string;
  30049. /**
  30050. * Prepare the list of uniforms associated with the Image Processing effects.
  30051. * @param uniforms The list of uniforms used in the effect
  30052. * @param defines the list of defines currently in use
  30053. */
  30054. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30055. /**
  30056. * Prepare the list of samplers associated with the Image Processing effects.
  30057. * @param samplersList The list of uniforms used in the effect
  30058. * @param defines the list of defines currently in use
  30059. */
  30060. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30061. /**
  30062. * Prepare the list of defines associated to the shader.
  30063. * @param defines the list of defines to complete
  30064. * @param forPostProcess Define if we are currently in post process mode or not
  30065. */
  30066. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30067. /**
  30068. * Returns true if all the image processing information are ready.
  30069. * @returns True if ready, otherwise, false
  30070. */
  30071. isReady(): boolean;
  30072. /**
  30073. * Binds the image processing to the shader.
  30074. * @param effect The effect to bind to
  30075. * @param aspectRatio Define the current aspect ratio of the effect
  30076. */
  30077. bind(effect: Effect, aspectRatio?: number): void;
  30078. /**
  30079. * Clones the current image processing instance.
  30080. * @return The cloned image processing
  30081. */
  30082. clone(): ImageProcessingConfiguration;
  30083. /**
  30084. * Serializes the current image processing instance to a json representation.
  30085. * @return a JSON representation
  30086. */
  30087. serialize(): any;
  30088. /**
  30089. * Parses the image processing from a json representation.
  30090. * @param source the JSON source to parse
  30091. * @return The parsed image processing
  30092. */
  30093. static Parse(source: any): ImageProcessingConfiguration;
  30094. private static _VIGNETTEMODE_MULTIPLY;
  30095. private static _VIGNETTEMODE_OPAQUE;
  30096. /**
  30097. * Used to apply the vignette as a mix with the pixel color.
  30098. */
  30099. static readonly VIGNETTEMODE_MULTIPLY: number;
  30100. /**
  30101. * Used to apply the vignette as a replacement of the pixel color.
  30102. */
  30103. static readonly VIGNETTEMODE_OPAQUE: number;
  30104. }
  30105. }
  30106. declare module "babylonjs/Materials/fresnelParameters" {
  30107. import { Color3 } from "babylonjs/Maths/math";
  30108. /**
  30109. * This represents all the required information to add a fresnel effect on a material:
  30110. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30111. */
  30112. export class FresnelParameters {
  30113. private _isEnabled;
  30114. /**
  30115. * Define if the fresnel effect is enable or not.
  30116. */
  30117. isEnabled: boolean;
  30118. /**
  30119. * Define the color used on edges (grazing angle)
  30120. */
  30121. leftColor: Color3;
  30122. /**
  30123. * Define the color used on center
  30124. */
  30125. rightColor: Color3;
  30126. /**
  30127. * Define bias applied to computed fresnel term
  30128. */
  30129. bias: number;
  30130. /**
  30131. * Defined the power exponent applied to fresnel term
  30132. */
  30133. power: number;
  30134. /**
  30135. * Clones the current fresnel and its valuues
  30136. * @returns a clone fresnel configuration
  30137. */
  30138. clone(): FresnelParameters;
  30139. /**
  30140. * Serializes the current fresnel parameters to a JSON representation.
  30141. * @return the JSON serialization
  30142. */
  30143. serialize(): any;
  30144. /**
  30145. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30146. * @param parsedFresnelParameters Define the JSON representation
  30147. * @returns the parsed parameters
  30148. */
  30149. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30150. }
  30151. }
  30152. declare module "babylonjs/Misc/decorators" {
  30153. import { Nullable } from "babylonjs/types";
  30154. import { Scene } from "babylonjs/scene";
  30155. import { IAnimatable } from "babylonjs/Misc/tools";
  30156. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30157. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30158. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30159. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30160. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30161. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30162. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30164. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. /**
  30169. * Decorator used to define property that can be serialized as reference to a camera
  30170. * @param sourceName defines the name of the property to decorate
  30171. */
  30172. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30173. /**
  30174. * Class used to help serialization objects
  30175. */
  30176. export class SerializationHelper {
  30177. /** hidden */
  30178. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30179. /** hidden */
  30180. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30181. /** hidden */
  30182. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30183. /** hidden */
  30184. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30185. /**
  30186. * Appends the serialized animations from the source animations
  30187. * @param source Source containing the animations
  30188. * @param destination Target to store the animations
  30189. */
  30190. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30191. /**
  30192. * Static function used to serialized a specific entity
  30193. * @param entity defines the entity to serialize
  30194. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30195. * @returns a JSON compatible object representing the serialization of the entity
  30196. */
  30197. static Serialize<T>(entity: T, serializationObject?: any): any;
  30198. /**
  30199. * Creates a new entity from a serialization data object
  30200. * @param creationFunction defines a function used to instanciated the new entity
  30201. * @param source defines the source serialization data
  30202. * @param scene defines the hosting scene
  30203. * @param rootUrl defines the root url for resources
  30204. * @returns a new entity
  30205. */
  30206. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30207. /**
  30208. * Clones an object
  30209. * @param creationFunction defines the function used to instanciate the new object
  30210. * @param source defines the source object
  30211. * @returns the cloned object
  30212. */
  30213. static Clone<T>(creationFunction: () => T, source: T): T;
  30214. /**
  30215. * Instanciates a new object based on a source one (some data will be shared between both object)
  30216. * @param creationFunction defines the function used to instanciate the new object
  30217. * @param source defines the source object
  30218. * @returns the new object
  30219. */
  30220. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30221. }
  30222. }
  30223. declare module "babylonjs/Cameras/camera" {
  30224. import { SmartArray } from "babylonjs/Misc/smartArray";
  30225. import { Observable } from "babylonjs/Misc/observable";
  30226. import { Nullable } from "babylonjs/types";
  30227. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30228. import { Scene } from "babylonjs/scene";
  30229. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30230. import { Node } from "babylonjs/node";
  30231. import { Mesh } from "babylonjs/Meshes/mesh";
  30232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30233. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30234. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30235. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30236. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30237. import { Ray } from "babylonjs/Culling/ray";
  30238. /**
  30239. * This is the base class of all the camera used in the application.
  30240. * @see http://doc.babylonjs.com/features/cameras
  30241. */
  30242. export class Camera extends Node {
  30243. /** @hidden */
  30244. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30245. /**
  30246. * This is the default projection mode used by the cameras.
  30247. * It helps recreating a feeling of perspective and better appreciate depth.
  30248. * This is the best way to simulate real life cameras.
  30249. */
  30250. static readonly PERSPECTIVE_CAMERA: number;
  30251. /**
  30252. * This helps creating camera with an orthographic mode.
  30253. * 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.
  30254. */
  30255. static readonly ORTHOGRAPHIC_CAMERA: number;
  30256. /**
  30257. * This is the default FOV mode for perspective cameras.
  30258. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30259. */
  30260. static readonly FOVMODE_VERTICAL_FIXED: number;
  30261. /**
  30262. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30263. */
  30264. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30265. /**
  30266. * This specifies ther is no need for a camera rig.
  30267. * Basically only one eye is rendered corresponding to the camera.
  30268. */
  30269. static readonly RIG_MODE_NONE: number;
  30270. /**
  30271. * Simulates a camera Rig with one blue eye and one red eye.
  30272. * This can be use with 3d blue and red glasses.
  30273. */
  30274. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30275. /**
  30276. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30277. */
  30278. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30279. /**
  30280. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30281. */
  30282. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30283. /**
  30284. * Defines that both eyes of the camera will be rendered over under each other.
  30285. */
  30286. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30287. /**
  30288. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30289. */
  30290. static readonly RIG_MODE_VR: number;
  30291. /**
  30292. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30293. */
  30294. static readonly RIG_MODE_WEBVR: number;
  30295. /**
  30296. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30297. */
  30298. static readonly RIG_MODE_CUSTOM: number;
  30299. /**
  30300. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30301. */
  30302. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30303. /**
  30304. * @hidden
  30305. * Might be removed once multiview will be a thing
  30306. */
  30307. static UseAlternateWebVRRendering: boolean;
  30308. /**
  30309. * Define the input manager associated with the camera.
  30310. */
  30311. inputs: CameraInputsManager<Camera>;
  30312. /** @hidden */
  30313. _position: Vector3;
  30314. /**
  30315. * Define the current local position of the camera in the scene
  30316. */
  30317. position: Vector3;
  30318. /**
  30319. * The vector the camera should consider as up.
  30320. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30321. */
  30322. upVector: Vector3;
  30323. /**
  30324. * Define the current limit on the left side for an orthographic camera
  30325. * In scene unit
  30326. */
  30327. orthoLeft: Nullable<number>;
  30328. /**
  30329. * Define the current limit on the right side for an orthographic camera
  30330. * In scene unit
  30331. */
  30332. orthoRight: Nullable<number>;
  30333. /**
  30334. * Define the current limit on the bottom side for an orthographic camera
  30335. * In scene unit
  30336. */
  30337. orthoBottom: Nullable<number>;
  30338. /**
  30339. * Define the current limit on the top side for an orthographic camera
  30340. * In scene unit
  30341. */
  30342. orthoTop: Nullable<number>;
  30343. /**
  30344. * Field Of View is set in Radians. (default is 0.8)
  30345. */
  30346. fov: number;
  30347. /**
  30348. * Define the minimum distance the camera can see from.
  30349. * This is important to note that the depth buffer are not infinite and the closer it starts
  30350. * the more your scene might encounter depth fighting issue.
  30351. */
  30352. minZ: number;
  30353. /**
  30354. * Define the maximum distance the camera can see to.
  30355. * This is important to note that the depth buffer are not infinite and the further it end
  30356. * the more your scene might encounter depth fighting issue.
  30357. */
  30358. maxZ: number;
  30359. /**
  30360. * Define the default inertia of the camera.
  30361. * This helps giving a smooth feeling to the camera movement.
  30362. */
  30363. inertia: number;
  30364. /**
  30365. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30366. */
  30367. mode: number;
  30368. /**
  30369. * Define wether the camera is intermediate.
  30370. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30371. */
  30372. isIntermediate: boolean;
  30373. /**
  30374. * Define the viewport of the camera.
  30375. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30376. */
  30377. viewport: Viewport;
  30378. /**
  30379. * Restricts the camera to viewing objects with the same layerMask.
  30380. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30381. */
  30382. layerMask: number;
  30383. /**
  30384. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30385. */
  30386. fovMode: number;
  30387. /**
  30388. * Rig mode of the camera.
  30389. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30390. * This is normally controlled byt the camera themselves as internal use.
  30391. */
  30392. cameraRigMode: number;
  30393. /**
  30394. * Defines the distance between both "eyes" in case of a RIG
  30395. */
  30396. interaxialDistance: number;
  30397. /**
  30398. * Defines if stereoscopic rendering is done side by side or over under.
  30399. */
  30400. isStereoscopicSideBySide: boolean;
  30401. /**
  30402. * 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
  30403. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30404. * else in the scene.
  30405. */
  30406. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30407. /**
  30408. * When set, the camera will render to this render target instead of the default canvas
  30409. */
  30410. outputRenderTarget: Nullable<RenderTargetTexture>;
  30411. /**
  30412. * Observable triggered when the camera view matrix has changed.
  30413. */
  30414. onViewMatrixChangedObservable: Observable<Camera>;
  30415. /**
  30416. * Observable triggered when the camera Projection matrix has changed.
  30417. */
  30418. onProjectionMatrixChangedObservable: Observable<Camera>;
  30419. /**
  30420. * Observable triggered when the inputs have been processed.
  30421. */
  30422. onAfterCheckInputsObservable: Observable<Camera>;
  30423. /**
  30424. * Observable triggered when reset has been called and applied to the camera.
  30425. */
  30426. onRestoreStateObservable: Observable<Camera>;
  30427. /** @hidden */
  30428. _cameraRigParams: any;
  30429. /** @hidden */
  30430. _rigCameras: Camera[];
  30431. /** @hidden */
  30432. _rigPostProcess: Nullable<PostProcess>;
  30433. protected _webvrViewMatrix: Matrix;
  30434. /** @hidden */
  30435. _skipRendering: boolean;
  30436. /** @hidden */
  30437. _alternateCamera: Camera;
  30438. /** @hidden */
  30439. _projectionMatrix: Matrix;
  30440. /** @hidden */
  30441. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30442. /** @hidden */
  30443. _activeMeshes: SmartArray<AbstractMesh>;
  30444. protected _globalPosition: Vector3;
  30445. /** hidden */
  30446. _computedViewMatrix: Matrix;
  30447. private _doNotComputeProjectionMatrix;
  30448. private _transformMatrix;
  30449. private _frustumPlanes;
  30450. private _refreshFrustumPlanes;
  30451. private _storedFov;
  30452. private _stateStored;
  30453. /**
  30454. * Instantiates a new camera object.
  30455. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30456. * @see http://doc.babylonjs.com/features/cameras
  30457. * @param name Defines the name of the camera in the scene
  30458. * @param position Defines the position of the camera
  30459. * @param scene Defines the scene the camera belongs too
  30460. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30461. */
  30462. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30463. /**
  30464. * Store current camera state (fov, position, etc..)
  30465. * @returns the camera
  30466. */
  30467. storeState(): Camera;
  30468. /**
  30469. * Restores the camera state values if it has been stored. You must call storeState() first
  30470. */
  30471. protected _restoreStateValues(): boolean;
  30472. /**
  30473. * Restored camera state. You must call storeState() first.
  30474. * @returns true if restored and false otherwise
  30475. */
  30476. restoreState(): boolean;
  30477. /**
  30478. * Gets the class name of the camera.
  30479. * @returns the class name
  30480. */
  30481. getClassName(): string;
  30482. /** @hidden */
  30483. readonly _isCamera: boolean;
  30484. /**
  30485. * Gets a string representation of the camera useful for debug purpose.
  30486. * @param fullDetails Defines that a more verboe level of logging is required
  30487. * @returns the string representation
  30488. */
  30489. toString(fullDetails?: boolean): string;
  30490. /**
  30491. * Gets the current world space position of the camera.
  30492. */
  30493. readonly globalPosition: Vector3;
  30494. /**
  30495. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30496. * @returns the active meshe list
  30497. */
  30498. getActiveMeshes(): SmartArray<AbstractMesh>;
  30499. /**
  30500. * Check wether a mesh is part of the current active mesh list of the camera
  30501. * @param mesh Defines the mesh to check
  30502. * @returns true if active, false otherwise
  30503. */
  30504. isActiveMesh(mesh: Mesh): boolean;
  30505. /**
  30506. * Is this camera ready to be used/rendered
  30507. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30508. * @return true if the camera is ready
  30509. */
  30510. isReady(completeCheck?: boolean): boolean;
  30511. /** @hidden */
  30512. _initCache(): void;
  30513. /** @hidden */
  30514. _updateCache(ignoreParentClass?: boolean): void;
  30515. /** @hidden */
  30516. _isSynchronized(): boolean;
  30517. /** @hidden */
  30518. _isSynchronizedViewMatrix(): boolean;
  30519. /** @hidden */
  30520. _isSynchronizedProjectionMatrix(): boolean;
  30521. /**
  30522. * Attach the input controls to a specific dom element to get the input from.
  30523. * @param element Defines the element the controls should be listened from
  30524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30525. */
  30526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30527. /**
  30528. * Detach the current controls from the specified dom element.
  30529. * @param element Defines the element to stop listening the inputs from
  30530. */
  30531. detachControl(element: HTMLElement): void;
  30532. /**
  30533. * Update the camera state according to the different inputs gathered during the frame.
  30534. */
  30535. update(): void;
  30536. /** @hidden */
  30537. _checkInputs(): void;
  30538. /** @hidden */
  30539. readonly rigCameras: Camera[];
  30540. /**
  30541. * Gets the post process used by the rig cameras
  30542. */
  30543. readonly rigPostProcess: Nullable<PostProcess>;
  30544. /**
  30545. * Internal, gets the first post proces.
  30546. * @returns the first post process to be run on this camera.
  30547. */
  30548. _getFirstPostProcess(): Nullable<PostProcess>;
  30549. private _cascadePostProcessesToRigCams;
  30550. /**
  30551. * Attach a post process to the camera.
  30552. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30553. * @param postProcess The post process to attach to the camera
  30554. * @param insertAt The position of the post process in case several of them are in use in the scene
  30555. * @returns the position the post process has been inserted at
  30556. */
  30557. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30558. /**
  30559. * Detach a post process to the camera.
  30560. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30561. * @param postProcess The post process to detach from the camera
  30562. */
  30563. detachPostProcess(postProcess: PostProcess): void;
  30564. /**
  30565. * Gets the current world matrix of the camera
  30566. */
  30567. getWorldMatrix(): Matrix;
  30568. /** @hidden */
  30569. _getViewMatrix(): Matrix;
  30570. /**
  30571. * Gets the current view matrix of the camera.
  30572. * @param force forces the camera to recompute the matrix without looking at the cached state
  30573. * @returns the view matrix
  30574. */
  30575. getViewMatrix(force?: boolean): Matrix;
  30576. /**
  30577. * Freeze the projection matrix.
  30578. * It will prevent the cache check of the camera projection compute and can speed up perf
  30579. * if no parameter of the camera are meant to change
  30580. * @param projection Defines manually a projection if necessary
  30581. */
  30582. freezeProjectionMatrix(projection?: Matrix): void;
  30583. /**
  30584. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30585. */
  30586. unfreezeProjectionMatrix(): void;
  30587. /**
  30588. * Gets the current projection matrix of the camera.
  30589. * @param force forces the camera to recompute the matrix without looking at the cached state
  30590. * @returns the projection matrix
  30591. */
  30592. getProjectionMatrix(force?: boolean): Matrix;
  30593. /**
  30594. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30595. * @returns a Matrix
  30596. */
  30597. getTransformationMatrix(): Matrix;
  30598. private _updateFrustumPlanes;
  30599. /**
  30600. * Checks if a cullable object (mesh...) is in the camera frustum
  30601. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30602. * @param target The object to check
  30603. * @returns true if the object is in frustum otherwise false
  30604. */
  30605. isInFrustum(target: ICullable): boolean;
  30606. /**
  30607. * Checks if a cullable object (mesh...) is in the camera frustum
  30608. * Unlike isInFrustum this cheks the full bounding box
  30609. * @param target The object to check
  30610. * @returns true if the object is in frustum otherwise false
  30611. */
  30612. isCompletelyInFrustum(target: ICullable): boolean;
  30613. /**
  30614. * Gets a ray in the forward direction from the camera.
  30615. * @param length Defines the length of the ray to create
  30616. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30617. * @param origin Defines the start point of the ray which defaults to the camera position
  30618. * @returns the forward ray
  30619. */
  30620. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30621. /**
  30622. * Releases resources associated with this node.
  30623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30625. */
  30626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30627. /** @hidden */
  30628. _isLeftCamera: boolean;
  30629. /**
  30630. * Gets the left camera of a rig setup in case of Rigged Camera
  30631. */
  30632. readonly isLeftCamera: boolean;
  30633. /** @hidden */
  30634. _isRightCamera: boolean;
  30635. /**
  30636. * Gets the right camera of a rig setup in case of Rigged Camera
  30637. */
  30638. readonly isRightCamera: boolean;
  30639. /**
  30640. * Gets the left camera of a rig setup in case of Rigged Camera
  30641. */
  30642. readonly leftCamera: Nullable<FreeCamera>;
  30643. /**
  30644. * Gets the right camera of a rig setup in case of Rigged Camera
  30645. */
  30646. readonly rightCamera: Nullable<FreeCamera>;
  30647. /**
  30648. * Gets the left camera target of a rig setup in case of Rigged Camera
  30649. * @returns the target position
  30650. */
  30651. getLeftTarget(): Nullable<Vector3>;
  30652. /**
  30653. * Gets the right camera target of a rig setup in case of Rigged Camera
  30654. * @returns the target position
  30655. */
  30656. getRightTarget(): Nullable<Vector3>;
  30657. /**
  30658. * @hidden
  30659. */
  30660. setCameraRigMode(mode: number, rigParams: any): void;
  30661. /** @hidden */
  30662. static _setStereoscopicRigMode(camera: Camera): void;
  30663. /** @hidden */
  30664. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30665. /** @hidden */
  30666. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30667. /** @hidden */
  30668. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30669. /** @hidden */
  30670. _getVRProjectionMatrix(): Matrix;
  30671. protected _updateCameraRotationMatrix(): void;
  30672. protected _updateWebVRCameraRotationMatrix(): void;
  30673. /**
  30674. * This function MUST be overwritten by the different WebVR cameras available.
  30675. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30676. * @hidden
  30677. */
  30678. _getWebVRProjectionMatrix(): Matrix;
  30679. /**
  30680. * This function MUST be overwritten by the different WebVR cameras available.
  30681. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30682. * @hidden
  30683. */
  30684. _getWebVRViewMatrix(): Matrix;
  30685. /** @hidden */
  30686. setCameraRigParameter(name: string, value: any): void;
  30687. /**
  30688. * needs to be overridden by children so sub has required properties to be copied
  30689. * @hidden
  30690. */
  30691. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30692. /**
  30693. * May need to be overridden by children
  30694. * @hidden
  30695. */
  30696. _updateRigCameras(): void;
  30697. /** @hidden */
  30698. _setupInputs(): void;
  30699. /**
  30700. * Serialiaze the camera setup to a json represention
  30701. * @returns the JSON representation
  30702. */
  30703. serialize(): any;
  30704. /**
  30705. * Clones the current camera.
  30706. * @param name The cloned camera name
  30707. * @returns the cloned camera
  30708. */
  30709. clone(name: string): Camera;
  30710. /**
  30711. * Gets the direction of the camera relative to a given local axis.
  30712. * @param localAxis Defines the reference axis to provide a relative direction.
  30713. * @return the direction
  30714. */
  30715. getDirection(localAxis: Vector3): Vector3;
  30716. /**
  30717. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30718. * @param localAxis Defines the reference axis to provide a relative direction.
  30719. * @param result Defines the vector to store the result in
  30720. */
  30721. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30722. /**
  30723. * Gets a camera constructor for a given camera type
  30724. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30725. * @param name The name of the camera the result will be able to instantiate
  30726. * @param scene The scene the result will construct the camera in
  30727. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30728. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30729. * @returns a factory method to construc the camera
  30730. */
  30731. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30732. /**
  30733. * Compute the world matrix of the camera.
  30734. * @returns the camera workd matrix
  30735. */
  30736. computeWorldMatrix(): Matrix;
  30737. /**
  30738. * Parse a JSON and creates the camera from the parsed information
  30739. * @param parsedCamera The JSON to parse
  30740. * @param scene The scene to instantiate the camera in
  30741. * @returns the newly constructed camera
  30742. */
  30743. static Parse(parsedCamera: any, scene: Scene): Camera;
  30744. }
  30745. }
  30746. declare module "babylonjs/Misc/tools" {
  30747. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30748. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30749. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30750. import { Observable } from "babylonjs/Misc/observable";
  30751. import { DomManagement } from "babylonjs/Misc/domManagement";
  30752. import { WebRequest } from "babylonjs/Misc/webRequest";
  30753. import { Camera } from "babylonjs/Cameras/camera";
  30754. import { Engine } from "babylonjs/Engines/engine";
  30755. import { Animation } from "babylonjs/Animations/animation";
  30756. /**
  30757. * Interface for any object that can request an animation frame
  30758. */
  30759. export interface ICustomAnimationFrameRequester {
  30760. /**
  30761. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30762. */
  30763. renderFunction?: Function;
  30764. /**
  30765. * Called to request the next frame to render to
  30766. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30767. */
  30768. requestAnimationFrame: Function;
  30769. /**
  30770. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30771. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30772. */
  30773. requestID?: number;
  30774. }
  30775. /**
  30776. * Interface containing an array of animations
  30777. */
  30778. export interface IAnimatable {
  30779. /**
  30780. * Array of animations
  30781. */
  30782. animations: Array<Animation>;
  30783. }
  30784. /** Interface used by value gradients (color, factor, ...) */
  30785. export interface IValueGradient {
  30786. /**
  30787. * Gets or sets the gradient value (between 0 and 1)
  30788. */
  30789. gradient: number;
  30790. }
  30791. /** Class used to store color4 gradient */
  30792. export class ColorGradient implements IValueGradient {
  30793. /**
  30794. * Gets or sets the gradient value (between 0 and 1)
  30795. */
  30796. gradient: number;
  30797. /**
  30798. * Gets or sets first associated color
  30799. */
  30800. color1: Color4;
  30801. /**
  30802. * Gets or sets second associated color
  30803. */
  30804. color2?: Color4;
  30805. /**
  30806. * Will get a color picked randomly between color1 and color2.
  30807. * If color2 is undefined then color1 will be used
  30808. * @param result defines the target Color4 to store the result in
  30809. */
  30810. getColorToRef(result: Color4): void;
  30811. }
  30812. /** Class used to store color 3 gradient */
  30813. export class Color3Gradient implements IValueGradient {
  30814. /**
  30815. * Gets or sets the gradient value (between 0 and 1)
  30816. */
  30817. gradient: number;
  30818. /**
  30819. * Gets or sets the associated color
  30820. */
  30821. color: Color3;
  30822. }
  30823. /** Class used to store factor gradient */
  30824. export class FactorGradient implements IValueGradient {
  30825. /**
  30826. * Gets or sets the gradient value (between 0 and 1)
  30827. */
  30828. gradient: number;
  30829. /**
  30830. * Gets or sets first associated factor
  30831. */
  30832. factor1: number;
  30833. /**
  30834. * Gets or sets second associated factor
  30835. */
  30836. factor2?: number;
  30837. /**
  30838. * Will get a number picked randomly between factor1 and factor2.
  30839. * If factor2 is undefined then factor1 will be used
  30840. * @returns the picked number
  30841. */
  30842. getFactor(): number;
  30843. }
  30844. /**
  30845. * @ignore
  30846. * Application error to support additional information when loading a file
  30847. */
  30848. export class LoadFileError extends Error {
  30849. /** defines the optional web request */
  30850. request?: WebRequest | undefined;
  30851. private static _setPrototypeOf;
  30852. /**
  30853. * Creates a new LoadFileError
  30854. * @param message defines the message of the error
  30855. * @param request defines the optional web request
  30856. */
  30857. constructor(message: string,
  30858. /** defines the optional web request */
  30859. request?: WebRequest | undefined);
  30860. }
  30861. /**
  30862. * Class used to define a retry strategy when error happens while loading assets
  30863. */
  30864. export class RetryStrategy {
  30865. /**
  30866. * Function used to defines an exponential back off strategy
  30867. * @param maxRetries defines the maximum number of retries (3 by default)
  30868. * @param baseInterval defines the interval between retries
  30869. * @returns the strategy function to use
  30870. */
  30871. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30872. }
  30873. /**
  30874. * File request interface
  30875. */
  30876. export interface IFileRequest {
  30877. /**
  30878. * Raised when the request is complete (success or error).
  30879. */
  30880. onCompleteObservable: Observable<IFileRequest>;
  30881. /**
  30882. * Aborts the request for a file.
  30883. */
  30884. abort: () => void;
  30885. }
  30886. /**
  30887. * Class containing a set of static utilities functions
  30888. */
  30889. export class Tools {
  30890. /**
  30891. * Gets or sets the base URL to use to load assets
  30892. */
  30893. static BaseUrl: string;
  30894. /**
  30895. * Enable/Disable Custom HTTP Request Headers globally.
  30896. * default = false
  30897. * @see CustomRequestHeaders
  30898. */
  30899. static UseCustomRequestHeaders: boolean;
  30900. /**
  30901. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30902. * i.e. when loading files, where the server/service expects an Authorization header
  30903. */
  30904. static CustomRequestHeaders: {
  30905. [key: string]: string;
  30906. };
  30907. /**
  30908. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30909. */
  30910. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30911. /**
  30912. * Default behaviour for cors in the application.
  30913. * It can be a string if the expected behavior is identical in the entire app.
  30914. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30915. */
  30916. static CorsBehavior: string | ((url: string | string[]) => string);
  30917. /**
  30918. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30919. * @ignorenaming
  30920. */
  30921. static UseFallbackTexture: boolean;
  30922. /**
  30923. * Use this object to register external classes like custom textures or material
  30924. * to allow the laoders to instantiate them
  30925. */
  30926. static RegisteredExternalClasses: {
  30927. [key: string]: Object;
  30928. };
  30929. /**
  30930. * Texture content used if a texture cannot loaded
  30931. * @ignorenaming
  30932. */
  30933. static fallbackTexture: string;
  30934. /**
  30935. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30936. * @param u defines the coordinate on X axis
  30937. * @param v defines the coordinate on Y axis
  30938. * @param width defines the width of the source data
  30939. * @param height defines the height of the source data
  30940. * @param pixels defines the source byte array
  30941. * @param color defines the output color
  30942. */
  30943. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30944. /**
  30945. * Interpolates between a and b via alpha
  30946. * @param a The lower value (returned when alpha = 0)
  30947. * @param b The upper value (returned when alpha = 1)
  30948. * @param alpha The interpolation-factor
  30949. * @return The mixed value
  30950. */
  30951. static Mix(a: number, b: number, alpha: number): number;
  30952. /**
  30953. * Tries to instantiate a new object from a given class name
  30954. * @param className defines the class name to instantiate
  30955. * @returns the new object or null if the system was not able to do the instantiation
  30956. */
  30957. static Instantiate(className: string): any;
  30958. /**
  30959. * Provides a slice function that will work even on IE
  30960. * @param data defines the array to slice
  30961. * @param start defines the start of the data (optional)
  30962. * @param end defines the end of the data (optional)
  30963. * @returns the new sliced array
  30964. */
  30965. static Slice<T>(data: T, start?: number, end?: number): T;
  30966. /**
  30967. * Polyfill for setImmediate
  30968. * @param action defines the action to execute after the current execution block
  30969. */
  30970. static SetImmediate(action: () => void): void;
  30971. /**
  30972. * Function indicating if a number is an exponent of 2
  30973. * @param value defines the value to test
  30974. * @returns true if the value is an exponent of 2
  30975. */
  30976. static IsExponentOfTwo(value: number): boolean;
  30977. private static _tmpFloatArray;
  30978. /**
  30979. * Returns the nearest 32-bit single precision float representation of a Number
  30980. * @param value A Number. If the parameter is of a different type, it will get converted
  30981. * to a number or to NaN if it cannot be converted
  30982. * @returns number
  30983. */
  30984. static FloatRound(value: number): number;
  30985. /**
  30986. * Find the next highest power of two.
  30987. * @param x Number to start search from.
  30988. * @return Next highest power of two.
  30989. */
  30990. static CeilingPOT(x: number): number;
  30991. /**
  30992. * Find the next lowest power of two.
  30993. * @param x Number to start search from.
  30994. * @return Next lowest power of two.
  30995. */
  30996. static FloorPOT(x: number): number;
  30997. /**
  30998. * Find the nearest power of two.
  30999. * @param x Number to start search from.
  31000. * @return Next nearest power of two.
  31001. */
  31002. static NearestPOT(x: number): number;
  31003. /**
  31004. * Get the closest exponent of two
  31005. * @param value defines the value to approximate
  31006. * @param max defines the maximum value to return
  31007. * @param mode defines how to define the closest value
  31008. * @returns closest exponent of two of the given value
  31009. */
  31010. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31011. /**
  31012. * Extracts the filename from a path
  31013. * @param path defines the path to use
  31014. * @returns the filename
  31015. */
  31016. static GetFilename(path: string): string;
  31017. /**
  31018. * Extracts the "folder" part of a path (everything before the filename).
  31019. * @param uri The URI to extract the info from
  31020. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31021. * @returns The "folder" part of the path
  31022. */
  31023. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31024. /**
  31025. * Extracts text content from a DOM element hierarchy
  31026. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31027. */
  31028. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31029. /**
  31030. * Convert an angle in radians to degrees
  31031. * @param angle defines the angle to convert
  31032. * @returns the angle in degrees
  31033. */
  31034. static ToDegrees(angle: number): number;
  31035. /**
  31036. * Convert an angle in degrees to radians
  31037. * @param angle defines the angle to convert
  31038. * @returns the angle in radians
  31039. */
  31040. static ToRadians(angle: number): number;
  31041. /**
  31042. * Encode a buffer to a base64 string
  31043. * @param buffer defines the buffer to encode
  31044. * @returns the encoded string
  31045. */
  31046. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31047. /**
  31048. * Extracts minimum and maximum values from a list of indexed positions
  31049. * @param positions defines the positions to use
  31050. * @param indices defines the indices to the positions
  31051. * @param indexStart defines the start index
  31052. * @param indexCount defines the end index
  31053. * @param bias defines bias value to add to the result
  31054. * @return minimum and maximum values
  31055. */
  31056. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31057. minimum: Vector3;
  31058. maximum: Vector3;
  31059. };
  31060. /**
  31061. * Extracts minimum and maximum values from a list of positions
  31062. * @param positions defines the positions to use
  31063. * @param start defines the start index in the positions array
  31064. * @param count defines the number of positions to handle
  31065. * @param bias defines bias value to add to the result
  31066. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31067. * @return minimum and maximum values
  31068. */
  31069. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31070. minimum: Vector3;
  31071. maximum: Vector3;
  31072. };
  31073. /**
  31074. * Returns an array if obj is not an array
  31075. * @param obj defines the object to evaluate as an array
  31076. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31077. * @returns either obj directly if obj is an array or a new array containing obj
  31078. */
  31079. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31080. /**
  31081. * Gets the pointer prefix to use
  31082. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31083. */
  31084. static GetPointerPrefix(): string;
  31085. /**
  31086. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31087. * @param func - the function to be called
  31088. * @param requester - the object that will request the next frame. Falls back to window.
  31089. * @returns frame number
  31090. */
  31091. static QueueNewFrame(func: () => void, requester?: any): number;
  31092. /**
  31093. * Ask the browser to promote the current element to fullscreen rendering mode
  31094. * @param element defines the DOM element to promote
  31095. */
  31096. static RequestFullscreen(element: HTMLElement): void;
  31097. /**
  31098. * Asks the browser to exit fullscreen mode
  31099. */
  31100. static ExitFullscreen(): void;
  31101. /**
  31102. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31103. * @param url define the url we are trying
  31104. * @param element define the dom element where to configure the cors policy
  31105. */
  31106. static SetCorsBehavior(url: string | string[], element: {
  31107. crossOrigin: string | null;
  31108. }): void;
  31109. /**
  31110. * Removes unwanted characters from an url
  31111. * @param url defines the url to clean
  31112. * @returns the cleaned url
  31113. */
  31114. static CleanUrl(url: string): string;
  31115. /**
  31116. * Gets or sets a function used to pre-process url before using them to load assets
  31117. */
  31118. static PreprocessUrl: (url: string) => string;
  31119. /**
  31120. * Loads an image as an HTMLImageElement.
  31121. * @param input url string, ArrayBuffer, or Blob to load
  31122. * @param onLoad callback called when the image successfully loads
  31123. * @param onError callback called when the image fails to load
  31124. * @param offlineProvider offline provider for caching
  31125. * @returns the HTMLImageElement of the loaded image
  31126. */
  31127. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31128. /**
  31129. * Loads a file
  31130. * @param url url string, ArrayBuffer, or Blob to load
  31131. * @param onSuccess callback called when the file successfully loads
  31132. * @param onProgress callback called while file is loading (if the server supports this mode)
  31133. * @param offlineProvider defines the offline provider for caching
  31134. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31135. * @param onError callback called when the file fails to load
  31136. * @returns a file request object
  31137. */
  31138. 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;
  31139. /**
  31140. * Load a script (identified by an url). When the url returns, the
  31141. * content of this file is added into a new script element, attached to the DOM (body element)
  31142. * @param scriptUrl defines the url of the script to laod
  31143. * @param onSuccess defines the callback called when the script is loaded
  31144. * @param onError defines the callback to call if an error occurs
  31145. */
  31146. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31147. /**
  31148. * Loads a file from a blob
  31149. * @param fileToLoad defines the blob to use
  31150. * @param callback defines the callback to call when data is loaded
  31151. * @param progressCallback defines the callback to call during loading process
  31152. * @returns a file request object
  31153. */
  31154. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31155. /**
  31156. * Loads a file
  31157. * @param fileToLoad defines the file to load
  31158. * @param callback defines the callback to call when data is loaded
  31159. * @param progressCallBack defines the callback to call during loading process
  31160. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31161. * @returns a file request object
  31162. */
  31163. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31164. /**
  31165. * Creates a data url from a given string content
  31166. * @param content defines the content to convert
  31167. * @returns the new data url link
  31168. */
  31169. static FileAsURL(content: string): string;
  31170. /**
  31171. * Format the given number to a specific decimal format
  31172. * @param value defines the number to format
  31173. * @param decimals defines the number of decimals to use
  31174. * @returns the formatted string
  31175. */
  31176. static Format(value: number, decimals?: number): string;
  31177. /**
  31178. * Checks if a given vector is inside a specific range
  31179. * @param v defines the vector to test
  31180. * @param min defines the minimum range
  31181. * @param max defines the maximum range
  31182. */
  31183. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31184. /**
  31185. * Tries to copy an object by duplicating every property
  31186. * @param source defines the source object
  31187. * @param destination defines the target object
  31188. * @param doNotCopyList defines a list of properties to avoid
  31189. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31190. */
  31191. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31192. /**
  31193. * Gets a boolean indicating if the given object has no own property
  31194. * @param obj defines the object to test
  31195. * @returns true if object has no own property
  31196. */
  31197. static IsEmpty(obj: any): boolean;
  31198. /**
  31199. * Function used to register events at window level
  31200. * @param events defines the events to register
  31201. */
  31202. static RegisterTopRootEvents(events: {
  31203. name: string;
  31204. handler: Nullable<(e: FocusEvent) => any>;
  31205. }[]): void;
  31206. /**
  31207. * Function used to unregister events from window level
  31208. * @param events defines the events to unregister
  31209. */
  31210. static UnregisterTopRootEvents(events: {
  31211. name: string;
  31212. handler: Nullable<(e: FocusEvent) => any>;
  31213. }[]): void;
  31214. /**
  31215. * @ignore
  31216. */
  31217. static _ScreenshotCanvas: HTMLCanvasElement;
  31218. /**
  31219. * Dumps the current bound framebuffer
  31220. * @param width defines the rendering width
  31221. * @param height defines the rendering height
  31222. * @param engine defines the hosting engine
  31223. * @param successCallback defines the callback triggered once the data are available
  31224. * @param mimeType defines the mime type of the result
  31225. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31226. */
  31227. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31228. /**
  31229. * Converts the canvas data to blob.
  31230. * This acts as a polyfill for browsers not supporting the to blob function.
  31231. * @param canvas Defines the canvas to extract the data from
  31232. * @param successCallback Defines the callback triggered once the data are available
  31233. * @param mimeType Defines the mime type of the result
  31234. */
  31235. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31236. /**
  31237. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31238. * @param successCallback defines the callback triggered once the data are available
  31239. * @param mimeType defines the mime type of the result
  31240. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31241. */
  31242. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31243. /**
  31244. * Downloads a blob in the browser
  31245. * @param blob defines the blob to download
  31246. * @param fileName defines the name of the downloaded file
  31247. */
  31248. static Download(blob: Blob, fileName: string): void;
  31249. /**
  31250. * Captures a screenshot of the current rendering
  31251. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31252. * @param engine defines the rendering engine
  31253. * @param camera defines the source camera
  31254. * @param size This parameter can be set to a single number or to an object with the
  31255. * following (optional) properties: precision, width, height. If a single number is passed,
  31256. * it will be used for both width and height. If an object is passed, the screenshot size
  31257. * will be derived from the parameters. The precision property is a multiplier allowing
  31258. * rendering at a higher or lower resolution
  31259. * @param successCallback defines the callback receives a single parameter which contains the
  31260. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31261. * src parameter of an <img> to display it
  31262. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31263. * Check your browser for supported MIME types
  31264. */
  31265. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31266. /**
  31267. * Generates an image screenshot from the specified camera.
  31268. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31269. * @param engine The engine to use for rendering
  31270. * @param camera The camera to use for rendering
  31271. * @param size This parameter can be set to a single number or to an object with the
  31272. * following (optional) properties: precision, width, height. If a single number is passed,
  31273. * it will be used for both width and height. If an object is passed, the screenshot size
  31274. * will be derived from the parameters. The precision property is a multiplier allowing
  31275. * rendering at a higher or lower resolution
  31276. * @param successCallback The callback receives a single parameter which contains the
  31277. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31278. * src parameter of an <img> to display it
  31279. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31280. * Check your browser for supported MIME types
  31281. * @param samples Texture samples (default: 1)
  31282. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31283. * @param fileName A name for for the downloaded file.
  31284. */
  31285. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31286. /**
  31287. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31288. * Be aware Math.random() could cause collisions, but:
  31289. * "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"
  31290. * @returns a pseudo random id
  31291. */
  31292. static RandomId(): string;
  31293. /**
  31294. * Test if the given uri is a base64 string
  31295. * @param uri The uri to test
  31296. * @return True if the uri is a base64 string or false otherwise
  31297. */
  31298. static IsBase64(uri: string): boolean;
  31299. /**
  31300. * Decode the given base64 uri.
  31301. * @param uri The uri to decode
  31302. * @return The decoded base64 data.
  31303. */
  31304. static DecodeBase64(uri: string): ArrayBuffer;
  31305. /**
  31306. * No log
  31307. */
  31308. static readonly NoneLogLevel: number;
  31309. /**
  31310. * Only message logs
  31311. */
  31312. static readonly MessageLogLevel: number;
  31313. /**
  31314. * Only warning logs
  31315. */
  31316. static readonly WarningLogLevel: number;
  31317. /**
  31318. * Only error logs
  31319. */
  31320. static readonly ErrorLogLevel: number;
  31321. /**
  31322. * All logs
  31323. */
  31324. static readonly AllLogLevel: number;
  31325. /**
  31326. * Gets a value indicating the number of loading errors
  31327. * @ignorenaming
  31328. */
  31329. static readonly errorsCount: number;
  31330. /**
  31331. * Callback called when a new log is added
  31332. */
  31333. static OnNewCacheEntry: (entry: string) => void;
  31334. /**
  31335. * Log a message to the console
  31336. * @param message defines the message to log
  31337. */
  31338. static Log(message: string): void;
  31339. /**
  31340. * Write a warning message to the console
  31341. * @param message defines the message to log
  31342. */
  31343. static Warn(message: string): void;
  31344. /**
  31345. * Write an error message to the console
  31346. * @param message defines the message to log
  31347. */
  31348. static Error(message: string): void;
  31349. /**
  31350. * Gets current log cache (list of logs)
  31351. */
  31352. static readonly LogCache: string;
  31353. /**
  31354. * Clears the log cache
  31355. */
  31356. static ClearLogCache(): void;
  31357. /**
  31358. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31359. */
  31360. static LogLevels: number;
  31361. /**
  31362. * Checks if the loaded document was accessed via `file:`-Protocol.
  31363. * @returns boolean
  31364. */
  31365. static IsFileURL(): boolean;
  31366. /**
  31367. * Checks if the window object exists
  31368. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31369. */
  31370. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31371. /**
  31372. * No performance log
  31373. */
  31374. static readonly PerformanceNoneLogLevel: number;
  31375. /**
  31376. * Use user marks to log performance
  31377. */
  31378. static readonly PerformanceUserMarkLogLevel: number;
  31379. /**
  31380. * Log performance to the console
  31381. */
  31382. static readonly PerformanceConsoleLogLevel: number;
  31383. private static _performance;
  31384. /**
  31385. * Sets the current performance log level
  31386. */
  31387. static PerformanceLogLevel: number;
  31388. private static _StartPerformanceCounterDisabled;
  31389. private static _EndPerformanceCounterDisabled;
  31390. private static _StartUserMark;
  31391. private static _EndUserMark;
  31392. private static _StartPerformanceConsole;
  31393. private static _EndPerformanceConsole;
  31394. /**
  31395. * Starts a performance counter
  31396. */
  31397. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31398. /**
  31399. * Ends a specific performance coutner
  31400. */
  31401. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31402. /**
  31403. * Gets either window.performance.now() if supported or Date.now() else
  31404. */
  31405. static readonly Now: number;
  31406. /**
  31407. * This method will return the name of the class used to create the instance of the given object.
  31408. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31409. * @param object the object to get the class name from
  31410. * @param isType defines if the object is actually a type
  31411. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31412. */
  31413. static GetClassName(object: any, isType?: boolean): string;
  31414. /**
  31415. * Gets the first element of an array satisfying a given predicate
  31416. * @param array defines the array to browse
  31417. * @param predicate defines the predicate to use
  31418. * @returns null if not found or the element
  31419. */
  31420. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31421. /**
  31422. * This method will return the name of the full name of the class, including its owning module (if any).
  31423. * 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).
  31424. * @param object the object to get the class name from
  31425. * @param isType defines if the object is actually a type
  31426. * @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.
  31427. * @ignorenaming
  31428. */
  31429. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31430. /**
  31431. * Returns a promise that resolves after the given amount of time.
  31432. * @param delay Number of milliseconds to delay
  31433. * @returns Promise that resolves after the given amount of time
  31434. */
  31435. static DelayAsync(delay: number): Promise<void>;
  31436. /**
  31437. * Gets the current gradient from an array of IValueGradient
  31438. * @param ratio defines the current ratio to get
  31439. * @param gradients defines the array of IValueGradient
  31440. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31441. */
  31442. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31443. }
  31444. /**
  31445. * This class is used to track a performance counter which is number based.
  31446. * The user has access to many properties which give statistics of different nature.
  31447. *
  31448. * The implementer can track two kinds of Performance Counter: time and count.
  31449. * 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.
  31450. * 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.
  31451. */
  31452. export class PerfCounter {
  31453. /**
  31454. * Gets or sets a global boolean to turn on and off all the counters
  31455. */
  31456. static Enabled: boolean;
  31457. /**
  31458. * Returns the smallest value ever
  31459. */
  31460. readonly min: number;
  31461. /**
  31462. * Returns the biggest value ever
  31463. */
  31464. readonly max: number;
  31465. /**
  31466. * Returns the average value since the performance counter is running
  31467. */
  31468. readonly average: number;
  31469. /**
  31470. * Returns the average value of the last second the counter was monitored
  31471. */
  31472. readonly lastSecAverage: number;
  31473. /**
  31474. * Returns the current value
  31475. */
  31476. readonly current: number;
  31477. /**
  31478. * Gets the accumulated total
  31479. */
  31480. readonly total: number;
  31481. /**
  31482. * Gets the total value count
  31483. */
  31484. readonly count: number;
  31485. /**
  31486. * Creates a new counter
  31487. */
  31488. constructor();
  31489. /**
  31490. * Call this method to start monitoring a new frame.
  31491. * 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.
  31492. */
  31493. fetchNewFrame(): void;
  31494. /**
  31495. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31496. * @param newCount the count value to add to the monitored count
  31497. * @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.
  31498. */
  31499. addCount(newCount: number, fetchResult: boolean): void;
  31500. /**
  31501. * Start monitoring this performance counter
  31502. */
  31503. beginMonitoring(): void;
  31504. /**
  31505. * Compute the time lapsed since the previous beginMonitoring() call.
  31506. * @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
  31507. */
  31508. endMonitoring(newFrame?: boolean): void;
  31509. private _fetchResult;
  31510. private _startMonitoringTime;
  31511. private _min;
  31512. private _max;
  31513. private _average;
  31514. private _current;
  31515. private _totalValueCount;
  31516. private _totalAccumulated;
  31517. private _lastSecAverage;
  31518. private _lastSecAccumulated;
  31519. private _lastSecTime;
  31520. private _lastSecValueCount;
  31521. }
  31522. /**
  31523. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31524. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31525. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31526. * @param name The name of the class, case should be preserved
  31527. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31528. */
  31529. export function className(name: string, module?: string): (target: Object) => void;
  31530. /**
  31531. * An implementation of a loop for asynchronous functions.
  31532. */
  31533. export class AsyncLoop {
  31534. /**
  31535. * Defines the number of iterations for the loop
  31536. */
  31537. iterations: number;
  31538. /**
  31539. * Defines the current index of the loop.
  31540. */
  31541. index: number;
  31542. private _done;
  31543. private _fn;
  31544. private _successCallback;
  31545. /**
  31546. * Constructor.
  31547. * @param iterations the number of iterations.
  31548. * @param func the function to run each iteration
  31549. * @param successCallback the callback that will be called upon succesful execution
  31550. * @param offset starting offset.
  31551. */
  31552. constructor(
  31553. /**
  31554. * Defines the number of iterations for the loop
  31555. */
  31556. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31557. /**
  31558. * Execute the next iteration. Must be called after the last iteration was finished.
  31559. */
  31560. executeNext(): void;
  31561. /**
  31562. * Break the loop and run the success callback.
  31563. */
  31564. breakLoop(): void;
  31565. /**
  31566. * Create and run an async loop.
  31567. * @param iterations the number of iterations.
  31568. * @param fn the function to run each iteration
  31569. * @param successCallback the callback that will be called upon succesful execution
  31570. * @param offset starting offset.
  31571. * @returns the created async loop object
  31572. */
  31573. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31574. /**
  31575. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31576. * @param iterations total number of iterations
  31577. * @param syncedIterations number of synchronous iterations in each async iteration.
  31578. * @param fn the function to call each iteration.
  31579. * @param callback a success call back that will be called when iterating stops.
  31580. * @param breakFunction a break condition (optional)
  31581. * @param timeout timeout settings for the setTimeout function. default - 0.
  31582. * @returns the created async loop object
  31583. */
  31584. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31585. }
  31586. }
  31587. declare module "babylonjs/Collisions/collisionCoordinator" {
  31588. import { Nullable } from "babylonjs/types";
  31589. import { Scene } from "babylonjs/scene";
  31590. import { Vector3 } from "babylonjs/Maths/math";
  31591. import { Collider } from "babylonjs/Collisions/collider";
  31592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31593. /** @hidden */
  31594. export interface ICollisionCoordinator {
  31595. createCollider(): Collider;
  31596. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31597. init(scene: Scene): void;
  31598. }
  31599. /** @hidden */
  31600. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31601. private _scene;
  31602. private _scaledPosition;
  31603. private _scaledVelocity;
  31604. private _finalPosition;
  31605. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31606. createCollider(): Collider;
  31607. init(scene: Scene): void;
  31608. private _collideWithWorld;
  31609. }
  31610. }
  31611. declare module "babylonjs/Animations/animationGroup" {
  31612. import { Animatable } from "babylonjs/Animations/animatable";
  31613. import { Animation } from "babylonjs/Animations/animation";
  31614. import { Scene, IDisposable } from "babylonjs/scene";
  31615. import { Observable } from "babylonjs/Misc/observable";
  31616. import { Nullable } from "babylonjs/types";
  31617. /**
  31618. * This class defines the direct association between an animation and a target
  31619. */
  31620. export class TargetedAnimation {
  31621. /**
  31622. * Animation to perform
  31623. */
  31624. animation: Animation;
  31625. /**
  31626. * Target to animate
  31627. */
  31628. target: any;
  31629. }
  31630. /**
  31631. * Use this class to create coordinated animations on multiple targets
  31632. */
  31633. export class AnimationGroup implements IDisposable {
  31634. /** The name of the animation group */
  31635. name: string;
  31636. private _scene;
  31637. private _targetedAnimations;
  31638. private _animatables;
  31639. private _from;
  31640. private _to;
  31641. private _isStarted;
  31642. private _isPaused;
  31643. private _speedRatio;
  31644. /**
  31645. * Gets or sets the unique id of the node
  31646. */
  31647. uniqueId: number;
  31648. /**
  31649. * This observable will notify when one animation have ended
  31650. */
  31651. onAnimationEndObservable: Observable<TargetedAnimation>;
  31652. /**
  31653. * Observer raised when one animation loops
  31654. */
  31655. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31656. /**
  31657. * This observable will notify when all animations have ended.
  31658. */
  31659. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31660. /**
  31661. * This observable will notify when all animations have paused.
  31662. */
  31663. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31664. /**
  31665. * This observable will notify when all animations are playing.
  31666. */
  31667. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31668. /**
  31669. * Gets the first frame
  31670. */
  31671. readonly from: number;
  31672. /**
  31673. * Gets the last frame
  31674. */
  31675. readonly to: number;
  31676. /**
  31677. * Define if the animations are started
  31678. */
  31679. readonly isStarted: boolean;
  31680. /**
  31681. * Gets a value indicating that the current group is playing
  31682. */
  31683. readonly isPlaying: boolean;
  31684. /**
  31685. * Gets or sets the speed ratio to use for all animations
  31686. */
  31687. /**
  31688. * Gets or sets the speed ratio to use for all animations
  31689. */
  31690. speedRatio: number;
  31691. /**
  31692. * Gets the targeted animations for this animation group
  31693. */
  31694. readonly targetedAnimations: Array<TargetedAnimation>;
  31695. /**
  31696. * returning the list of animatables controlled by this animation group.
  31697. */
  31698. readonly animatables: Array<Animatable>;
  31699. /**
  31700. * Instantiates a new Animation Group.
  31701. * This helps managing several animations at once.
  31702. * @see http://doc.babylonjs.com/how_to/group
  31703. * @param name Defines the name of the group
  31704. * @param scene Defines the scene the group belongs to
  31705. */
  31706. constructor(
  31707. /** The name of the animation group */
  31708. name: string, scene?: Nullable<Scene>);
  31709. /**
  31710. * Add an animation (with its target) in the group
  31711. * @param animation defines the animation we want to add
  31712. * @param target defines the target of the animation
  31713. * @returns the TargetedAnimation object
  31714. */
  31715. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31716. /**
  31717. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31718. * It can add constant keys at begin or end
  31719. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31720. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31721. * @returns the animation group
  31722. */
  31723. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31724. /**
  31725. * Start all animations on given targets
  31726. * @param loop defines if animations must loop
  31727. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31728. * @param from defines the from key (optional)
  31729. * @param to defines the to key (optional)
  31730. * @returns the current animation group
  31731. */
  31732. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31733. /**
  31734. * Pause all animations
  31735. * @returns the animation group
  31736. */
  31737. pause(): AnimationGroup;
  31738. /**
  31739. * Play all animations to initial state
  31740. * This function will start() the animations if they were not started or will restart() them if they were paused
  31741. * @param loop defines if animations must loop
  31742. * @returns the animation group
  31743. */
  31744. play(loop?: boolean): AnimationGroup;
  31745. /**
  31746. * Reset all animations to initial state
  31747. * @returns the animation group
  31748. */
  31749. reset(): AnimationGroup;
  31750. /**
  31751. * Restart animations from key 0
  31752. * @returns the animation group
  31753. */
  31754. restart(): AnimationGroup;
  31755. /**
  31756. * Stop all animations
  31757. * @returns the animation group
  31758. */
  31759. stop(): AnimationGroup;
  31760. /**
  31761. * Set animation weight for all animatables
  31762. * @param weight defines the weight to use
  31763. * @return the animationGroup
  31764. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31765. */
  31766. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31767. /**
  31768. * Synchronize and normalize all animatables with a source animatable
  31769. * @param root defines the root animatable to synchronize with
  31770. * @return the animationGroup
  31771. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31772. */
  31773. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31774. /**
  31775. * Goes to a specific frame in this animation group
  31776. * @param frame the frame number to go to
  31777. * @return the animationGroup
  31778. */
  31779. goToFrame(frame: number): AnimationGroup;
  31780. /**
  31781. * Dispose all associated resources
  31782. */
  31783. dispose(): void;
  31784. private _checkAnimationGroupEnded;
  31785. /**
  31786. * Clone the current animation group and returns a copy
  31787. * @param newName defines the name of the new group
  31788. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31789. * @returns the new aniamtion group
  31790. */
  31791. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31792. /**
  31793. * Returns a new AnimationGroup object parsed from the source provided.
  31794. * @param parsedAnimationGroup defines the source
  31795. * @param scene defines the scene that will receive the animationGroup
  31796. * @returns a new AnimationGroup
  31797. */
  31798. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31799. /**
  31800. * Returns the string "AnimationGroup"
  31801. * @returns "AnimationGroup"
  31802. */
  31803. getClassName(): string;
  31804. /**
  31805. * Creates a detailled string about the object
  31806. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31807. * @returns a string representing the object
  31808. */
  31809. toString(fullDetails?: boolean): string;
  31810. }
  31811. }
  31812. declare module "babylonjs/scene" {
  31813. import { Nullable } from "babylonjs/types";
  31814. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31815. import { Observable } from "babylonjs/Misc/observable";
  31816. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31817. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31818. import { Geometry } from "babylonjs/Meshes/geometry";
  31819. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31820. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31822. import { Mesh } from "babylonjs/Meshes/mesh";
  31823. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31824. import { Bone } from "babylonjs/Bones/bone";
  31825. import { Skeleton } from "babylonjs/Bones/skeleton";
  31826. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31827. import { Camera } from "babylonjs/Cameras/camera";
  31828. import { AbstractScene } from "babylonjs/abstractScene";
  31829. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31831. import { Material } from "babylonjs/Materials/material";
  31832. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31833. import { Effect } from "babylonjs/Materials/effect";
  31834. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31835. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31836. import { Light } from "babylonjs/Lights/light";
  31837. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31838. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31839. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31840. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31842. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31843. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31844. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31845. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31846. import { Engine } from "babylonjs/Engines/engine";
  31847. import { Node } from "babylonjs/node";
  31848. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31849. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31850. import { WebRequest } from "babylonjs/Misc/webRequest";
  31851. import { Ray } from "babylonjs/Culling/ray";
  31852. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31853. import { Animation } from "babylonjs/Animations/animation";
  31854. import { Animatable } from "babylonjs/Animations/animatable";
  31855. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31856. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31857. import { Collider } from "babylonjs/Collisions/collider";
  31858. /**
  31859. * Define an interface for all classes that will hold resources
  31860. */
  31861. export interface IDisposable {
  31862. /**
  31863. * Releases all held resources
  31864. */
  31865. dispose(): void;
  31866. }
  31867. /** Interface defining initialization parameters for Scene class */
  31868. export interface SceneOptions {
  31869. /**
  31870. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31871. * It will improve performance when the number of geometries becomes important.
  31872. */
  31873. useGeometryUniqueIdsMap?: boolean;
  31874. /**
  31875. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31876. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31877. */
  31878. useMaterialMeshMap?: boolean;
  31879. /**
  31880. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31881. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31882. */
  31883. useClonedMeshhMap?: boolean;
  31884. }
  31885. /**
  31886. * Represents a scene to be rendered by the engine.
  31887. * @see http://doc.babylonjs.com/features/scene
  31888. */
  31889. export class Scene extends AbstractScene implements IAnimatable {
  31890. private static _uniqueIdCounter;
  31891. /** The fog is deactivated */
  31892. static readonly FOGMODE_NONE: number;
  31893. /** The fog density is following an exponential function */
  31894. static readonly FOGMODE_EXP: number;
  31895. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31896. static readonly FOGMODE_EXP2: number;
  31897. /** The fog density is following a linear function. */
  31898. static readonly FOGMODE_LINEAR: number;
  31899. /**
  31900. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31902. */
  31903. static MinDeltaTime: number;
  31904. /**
  31905. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31906. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31907. */
  31908. static MaxDeltaTime: number;
  31909. /**
  31910. * Factory used to create the default material.
  31911. * @param name The name of the material to create
  31912. * @param scene The scene to create the material for
  31913. * @returns The default material
  31914. */
  31915. static DefaultMaterialFactory(scene: Scene): Material;
  31916. /**
  31917. * Factory used to create the a collision coordinator.
  31918. * @returns The collision coordinator
  31919. */
  31920. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31921. /** @hidden */
  31922. readonly _isScene: boolean;
  31923. /**
  31924. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31925. */
  31926. autoClear: boolean;
  31927. /**
  31928. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31929. */
  31930. autoClearDepthAndStencil: boolean;
  31931. /**
  31932. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31933. */
  31934. clearColor: Color4;
  31935. /**
  31936. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31937. */
  31938. ambientColor: Color3;
  31939. /** @hidden */
  31940. _environmentBRDFTexture: BaseTexture;
  31941. /** @hidden */
  31942. protected _environmentTexture: Nullable<BaseTexture>;
  31943. /**
  31944. * Texture used in all pbr material as the reflection texture.
  31945. * As in the majority of the scene they are the same (exception for multi room and so on),
  31946. * this is easier to reference from here than from all the materials.
  31947. */
  31948. /**
  31949. * Texture used in all pbr material as the reflection texture.
  31950. * As in the majority of the scene they are the same (exception for multi room and so on),
  31951. * this is easier to set here than in all the materials.
  31952. */
  31953. environmentTexture: Nullable<BaseTexture>;
  31954. /** @hidden */
  31955. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31956. /**
  31957. * Default image processing configuration used either in the rendering
  31958. * Forward main pass or through the imageProcessingPostProcess if present.
  31959. * As in the majority of the scene they are the same (exception for multi camera),
  31960. * this is easier to reference from here than from all the materials and post process.
  31961. *
  31962. * No setter as we it is a shared configuration, you can set the values instead.
  31963. */
  31964. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31965. private _forceWireframe;
  31966. /**
  31967. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31968. */
  31969. forceWireframe: boolean;
  31970. private _forcePointsCloud;
  31971. /**
  31972. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31973. */
  31974. forcePointsCloud: boolean;
  31975. /**
  31976. * Gets or sets the active clipplane 1
  31977. */
  31978. clipPlane: Nullable<Plane>;
  31979. /**
  31980. * Gets or sets the active clipplane 2
  31981. */
  31982. clipPlane2: Nullable<Plane>;
  31983. /**
  31984. * Gets or sets the active clipplane 3
  31985. */
  31986. clipPlane3: Nullable<Plane>;
  31987. /**
  31988. * Gets or sets the active clipplane 4
  31989. */
  31990. clipPlane4: Nullable<Plane>;
  31991. /**
  31992. * Gets or sets a boolean indicating if animations are enabled
  31993. */
  31994. animationsEnabled: boolean;
  31995. private _animationPropertiesOverride;
  31996. /**
  31997. * Gets or sets the animation properties override
  31998. */
  31999. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32000. /**
  32001. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32002. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32003. */
  32004. useConstantAnimationDeltaTime: boolean;
  32005. /**
  32006. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32007. * Please note that it requires to run a ray cast through the scene on every frame
  32008. */
  32009. constantlyUpdateMeshUnderPointer: boolean;
  32010. /**
  32011. * Defines the HTML cursor to use when hovering over interactive elements
  32012. */
  32013. hoverCursor: string;
  32014. /**
  32015. * Defines the HTML default cursor to use (empty by default)
  32016. */
  32017. defaultCursor: string;
  32018. /**
  32019. * This is used to call preventDefault() on pointer down
  32020. * in order to block unwanted artifacts like system double clicks
  32021. */
  32022. preventDefaultOnPointerDown: boolean;
  32023. /**
  32024. * This is used to call preventDefault() on pointer up
  32025. * in order to block unwanted artifacts like system double clicks
  32026. */
  32027. preventDefaultOnPointerUp: boolean;
  32028. /**
  32029. * Gets or sets user defined metadata
  32030. */
  32031. metadata: any;
  32032. /**
  32033. * For internal use only. Please do not use.
  32034. */
  32035. reservedDataStore: any;
  32036. /**
  32037. * Gets the name of the plugin used to load this scene (null by default)
  32038. */
  32039. loadingPluginName: string;
  32040. /**
  32041. * Use this array to add regular expressions used to disable offline support for specific urls
  32042. */
  32043. disableOfflineSupportExceptionRules: RegExp[];
  32044. /**
  32045. * An event triggered when the scene is disposed.
  32046. */
  32047. onDisposeObservable: Observable<Scene>;
  32048. private _onDisposeObserver;
  32049. /** Sets a function to be executed when this scene is disposed. */
  32050. onDispose: () => void;
  32051. /**
  32052. * An event triggered before rendering the scene (right after animations and physics)
  32053. */
  32054. onBeforeRenderObservable: Observable<Scene>;
  32055. private _onBeforeRenderObserver;
  32056. /** Sets a function to be executed before rendering this scene */
  32057. beforeRender: Nullable<() => void>;
  32058. /**
  32059. * An event triggered after rendering the scene
  32060. */
  32061. onAfterRenderObservable: Observable<Scene>;
  32062. private _onAfterRenderObserver;
  32063. /** Sets a function to be executed after rendering this scene */
  32064. afterRender: Nullable<() => void>;
  32065. /**
  32066. * An event triggered before animating the scene
  32067. */
  32068. onBeforeAnimationsObservable: Observable<Scene>;
  32069. /**
  32070. * An event triggered after animations processing
  32071. */
  32072. onAfterAnimationsObservable: Observable<Scene>;
  32073. /**
  32074. * An event triggered before draw calls are ready to be sent
  32075. */
  32076. onBeforeDrawPhaseObservable: Observable<Scene>;
  32077. /**
  32078. * An event triggered after draw calls have been sent
  32079. */
  32080. onAfterDrawPhaseObservable: Observable<Scene>;
  32081. /**
  32082. * An event triggered when the scene is ready
  32083. */
  32084. onReadyObservable: Observable<Scene>;
  32085. /**
  32086. * An event triggered before rendering a camera
  32087. */
  32088. onBeforeCameraRenderObservable: Observable<Camera>;
  32089. private _onBeforeCameraRenderObserver;
  32090. /** Sets a function to be executed before rendering a camera*/
  32091. beforeCameraRender: () => void;
  32092. /**
  32093. * An event triggered after rendering a camera
  32094. */
  32095. onAfterCameraRenderObservable: Observable<Camera>;
  32096. private _onAfterCameraRenderObserver;
  32097. /** Sets a function to be executed after rendering a camera*/
  32098. afterCameraRender: () => void;
  32099. /**
  32100. * An event triggered when active meshes evaluation is about to start
  32101. */
  32102. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32103. /**
  32104. * An event triggered when active meshes evaluation is done
  32105. */
  32106. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32107. /**
  32108. * An event triggered when particles rendering is about to start
  32109. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32110. */
  32111. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32112. /**
  32113. * An event triggered when particles rendering is done
  32114. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32115. */
  32116. onAfterParticlesRenderingObservable: Observable<Scene>;
  32117. /**
  32118. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32119. */
  32120. onDataLoadedObservable: Observable<Scene>;
  32121. /**
  32122. * An event triggered when a camera is created
  32123. */
  32124. onNewCameraAddedObservable: Observable<Camera>;
  32125. /**
  32126. * An event triggered when a camera is removed
  32127. */
  32128. onCameraRemovedObservable: Observable<Camera>;
  32129. /**
  32130. * An event triggered when a light is created
  32131. */
  32132. onNewLightAddedObservable: Observable<Light>;
  32133. /**
  32134. * An event triggered when a light is removed
  32135. */
  32136. onLightRemovedObservable: Observable<Light>;
  32137. /**
  32138. * An event triggered when a geometry is created
  32139. */
  32140. onNewGeometryAddedObservable: Observable<Geometry>;
  32141. /**
  32142. * An event triggered when a geometry is removed
  32143. */
  32144. onGeometryRemovedObservable: Observable<Geometry>;
  32145. /**
  32146. * An event triggered when a transform node is created
  32147. */
  32148. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32149. /**
  32150. * An event triggered when a transform node is removed
  32151. */
  32152. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32153. /**
  32154. * An event triggered when a mesh is created
  32155. */
  32156. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32157. /**
  32158. * An event triggered when a mesh is removed
  32159. */
  32160. onMeshRemovedObservable: Observable<AbstractMesh>;
  32161. /**
  32162. * An event triggered when a skeleton is created
  32163. */
  32164. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32165. /**
  32166. * An event triggered when a skeleton is removed
  32167. */
  32168. onSkeletonRemovedObservable: Observable<Skeleton>;
  32169. /**
  32170. * An event triggered when a material is created
  32171. */
  32172. onNewMaterialAddedObservable: Observable<Material>;
  32173. /**
  32174. * An event triggered when a material is removed
  32175. */
  32176. onMaterialRemovedObservable: Observable<Material>;
  32177. /**
  32178. * An event triggered when a texture is created
  32179. */
  32180. onNewTextureAddedObservable: Observable<BaseTexture>;
  32181. /**
  32182. * An event triggered when a texture is removed
  32183. */
  32184. onTextureRemovedObservable: Observable<BaseTexture>;
  32185. /**
  32186. * An event triggered when render targets are about to be rendered
  32187. * Can happen multiple times per frame.
  32188. */
  32189. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32190. /**
  32191. * An event triggered when render targets were rendered.
  32192. * Can happen multiple times per frame.
  32193. */
  32194. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32195. /**
  32196. * An event triggered before calculating deterministic simulation step
  32197. */
  32198. onBeforeStepObservable: Observable<Scene>;
  32199. /**
  32200. * An event triggered after calculating deterministic simulation step
  32201. */
  32202. onAfterStepObservable: Observable<Scene>;
  32203. /**
  32204. * An event triggered when the activeCamera property is updated
  32205. */
  32206. onActiveCameraChanged: Observable<Scene>;
  32207. /**
  32208. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32209. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32210. * 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)
  32211. */
  32212. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32213. /**
  32214. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32215. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32216. * 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)
  32217. */
  32218. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32219. /**
  32220. * This Observable will when a mesh has been imported into the scene.
  32221. */
  32222. onMeshImportedObservable: Observable<AbstractMesh>;
  32223. /**
  32224. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32225. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32226. */
  32227. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32228. /** @hidden */
  32229. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32230. /**
  32231. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32232. */
  32233. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32234. /**
  32235. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32236. */
  32237. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32238. /**
  32239. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32240. */
  32241. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32242. private _onPointerMove;
  32243. private _onPointerDown;
  32244. private _onPointerUp;
  32245. /** Callback called when a pointer move is detected */
  32246. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32247. /** Callback called when a pointer down is detected */
  32248. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32249. /** Callback called when a pointer up is detected */
  32250. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32251. /** Callback called when a pointer pick is detected */
  32252. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32253. /**
  32254. * 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).
  32255. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32256. */
  32257. onPrePointerObservable: Observable<PointerInfoPre>;
  32258. /**
  32259. * Observable event triggered each time an input event is received from the rendering canvas
  32260. */
  32261. onPointerObservable: Observable<PointerInfo>;
  32262. /**
  32263. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32264. */
  32265. readonly unTranslatedPointer: Vector2;
  32266. /** The distance in pixel that you have to move to prevent some events */
  32267. static DragMovementThreshold: number;
  32268. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32269. static LongPressDelay: number;
  32270. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32271. static DoubleClickDelay: number;
  32272. /** If you need to check double click without raising a single click at first click, enable this flag */
  32273. static ExclusiveDoubleClickMode: boolean;
  32274. private _initClickEvent;
  32275. private _initActionManager;
  32276. private _delayedSimpleClick;
  32277. private _delayedSimpleClickTimeout;
  32278. private _previousDelayedSimpleClickTimeout;
  32279. private _meshPickProceed;
  32280. private _previousButtonPressed;
  32281. private _currentPickResult;
  32282. private _previousPickResult;
  32283. private _totalPointersPressed;
  32284. private _doubleClickOccured;
  32285. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32286. cameraToUseForPointers: Nullable<Camera>;
  32287. private _pointerX;
  32288. private _pointerY;
  32289. private _unTranslatedPointerX;
  32290. private _unTranslatedPointerY;
  32291. private _startingPointerPosition;
  32292. private _previousStartingPointerPosition;
  32293. private _startingPointerTime;
  32294. private _previousStartingPointerTime;
  32295. private _pointerCaptures;
  32296. private _timeAccumulator;
  32297. private _currentStepId;
  32298. private _currentInternalStep;
  32299. /** @hidden */
  32300. _mirroredCameraPosition: Nullable<Vector3>;
  32301. /**
  32302. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32303. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32304. */
  32305. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32306. /**
  32307. * Observable event triggered each time an keyboard event is received from the hosting window
  32308. */
  32309. onKeyboardObservable: Observable<KeyboardInfo>;
  32310. private _onKeyDown;
  32311. private _onKeyUp;
  32312. private _onCanvasFocusObserver;
  32313. private _onCanvasBlurObserver;
  32314. private _useRightHandedSystem;
  32315. /**
  32316. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32317. */
  32318. useRightHandedSystem: boolean;
  32319. /**
  32320. * Sets the step Id used by deterministic lock step
  32321. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32322. * @param newStepId defines the step Id
  32323. */
  32324. setStepId(newStepId: number): void;
  32325. /**
  32326. * Gets the step Id used by deterministic lock step
  32327. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32328. * @returns the step Id
  32329. */
  32330. getStepId(): number;
  32331. /**
  32332. * Gets the internal step used by deterministic lock step
  32333. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32334. * @returns the internal step
  32335. */
  32336. getInternalStep(): number;
  32337. private _fogEnabled;
  32338. /**
  32339. * Gets or sets a boolean indicating if fog is enabled on this scene
  32340. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32341. * (Default is true)
  32342. */
  32343. fogEnabled: boolean;
  32344. private _fogMode;
  32345. /**
  32346. * Gets or sets the fog mode to use
  32347. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32348. * | mode | value |
  32349. * | --- | --- |
  32350. * | FOGMODE_NONE | 0 |
  32351. * | FOGMODE_EXP | 1 |
  32352. * | FOGMODE_EXP2 | 2 |
  32353. * | FOGMODE_LINEAR | 3 |
  32354. */
  32355. fogMode: number;
  32356. /**
  32357. * Gets or sets the fog color to use
  32358. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32359. * (Default is Color3(0.2, 0.2, 0.3))
  32360. */
  32361. fogColor: Color3;
  32362. /**
  32363. * Gets or sets the fog density to use
  32364. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32365. * (Default is 0.1)
  32366. */
  32367. fogDensity: number;
  32368. /**
  32369. * Gets or sets the fog start distance to use
  32370. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32371. * (Default is 0)
  32372. */
  32373. fogStart: number;
  32374. /**
  32375. * Gets or sets the fog end distance to use
  32376. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32377. * (Default is 1000)
  32378. */
  32379. fogEnd: number;
  32380. private _shadowsEnabled;
  32381. /**
  32382. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32383. */
  32384. shadowsEnabled: boolean;
  32385. private _lightsEnabled;
  32386. /**
  32387. * Gets or sets a boolean indicating if lights are enabled on this scene
  32388. */
  32389. lightsEnabled: boolean;
  32390. /** All of the active cameras added to this scene. */
  32391. activeCameras: Camera[];
  32392. private _activeCamera;
  32393. /** Gets or sets the current active camera */
  32394. activeCamera: Nullable<Camera>;
  32395. private _defaultMaterial;
  32396. /** The default material used on meshes when no material is affected */
  32397. /** The default material used on meshes when no material is affected */
  32398. defaultMaterial: Material;
  32399. private _texturesEnabled;
  32400. /**
  32401. * Gets or sets a boolean indicating if textures are enabled on this scene
  32402. */
  32403. texturesEnabled: boolean;
  32404. /**
  32405. * Gets or sets a boolean indicating if particles are enabled on this scene
  32406. */
  32407. particlesEnabled: boolean;
  32408. /**
  32409. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32410. */
  32411. spritesEnabled: boolean;
  32412. private _skeletonsEnabled;
  32413. /**
  32414. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32415. */
  32416. skeletonsEnabled: boolean;
  32417. /**
  32418. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32419. */
  32420. lensFlaresEnabled: boolean;
  32421. /**
  32422. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32424. */
  32425. collisionsEnabled: boolean;
  32426. private _collisionCoordinator;
  32427. /** @hidden */
  32428. readonly collisionCoordinator: ICollisionCoordinator;
  32429. /**
  32430. * Defines the gravity applied to this scene (used only for collisions)
  32431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32432. */
  32433. gravity: Vector3;
  32434. /**
  32435. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32436. */
  32437. postProcessesEnabled: boolean;
  32438. /**
  32439. * The list of postprocesses added to the scene
  32440. */
  32441. postProcesses: PostProcess[];
  32442. /**
  32443. * Gets the current postprocess manager
  32444. */
  32445. postProcessManager: PostProcessManager;
  32446. /**
  32447. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32448. */
  32449. renderTargetsEnabled: boolean;
  32450. /**
  32451. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32452. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32453. */
  32454. dumpNextRenderTargets: boolean;
  32455. /**
  32456. * The list of user defined render targets added to the scene
  32457. */
  32458. customRenderTargets: RenderTargetTexture[];
  32459. /**
  32460. * Defines if texture loading must be delayed
  32461. * If true, textures will only be loaded when they need to be rendered
  32462. */
  32463. useDelayedTextureLoading: boolean;
  32464. /**
  32465. * Gets the list of meshes imported to the scene through SceneLoader
  32466. */
  32467. importedMeshesFiles: String[];
  32468. /**
  32469. * Gets or sets a boolean indicating if probes are enabled on this scene
  32470. */
  32471. probesEnabled: boolean;
  32472. /**
  32473. * Gets or sets the current offline provider to use to store scene data
  32474. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32475. */
  32476. offlineProvider: IOfflineProvider;
  32477. /**
  32478. * Gets or sets the action manager associated with the scene
  32479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32480. */
  32481. actionManager: AbstractActionManager;
  32482. private _meshesForIntersections;
  32483. /**
  32484. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32485. */
  32486. proceduralTexturesEnabled: boolean;
  32487. private _engine;
  32488. private _totalVertices;
  32489. /** @hidden */
  32490. _activeIndices: PerfCounter;
  32491. /** @hidden */
  32492. _activeParticles: PerfCounter;
  32493. /** @hidden */
  32494. _activeBones: PerfCounter;
  32495. private _animationRatio;
  32496. /** @hidden */
  32497. _animationTimeLast: number;
  32498. /** @hidden */
  32499. _animationTime: number;
  32500. /**
  32501. * Gets or sets a general scale for animation speed
  32502. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32503. */
  32504. animationTimeScale: number;
  32505. /** @hidden */
  32506. _cachedMaterial: Nullable<Material>;
  32507. /** @hidden */
  32508. _cachedEffect: Nullable<Effect>;
  32509. /** @hidden */
  32510. _cachedVisibility: Nullable<number>;
  32511. private _renderId;
  32512. private _frameId;
  32513. private _executeWhenReadyTimeoutId;
  32514. private _intermediateRendering;
  32515. private _viewUpdateFlag;
  32516. private _projectionUpdateFlag;
  32517. private _alternateViewUpdateFlag;
  32518. private _alternateProjectionUpdateFlag;
  32519. /** @hidden */
  32520. _toBeDisposed: Nullable<IDisposable>[];
  32521. private _activeRequests;
  32522. /** @hidden */
  32523. _pendingData: any[];
  32524. private _isDisposed;
  32525. /**
  32526. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32527. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32528. */
  32529. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32530. private _activeMeshes;
  32531. private _processedMaterials;
  32532. private _renderTargets;
  32533. /** @hidden */
  32534. _activeParticleSystems: SmartArray<IParticleSystem>;
  32535. private _activeSkeletons;
  32536. private _softwareSkinnedMeshes;
  32537. private _renderingManager;
  32538. /** @hidden */
  32539. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32540. private _transformMatrix;
  32541. private _sceneUbo;
  32542. private _alternateSceneUbo;
  32543. private _viewMatrix;
  32544. private _projectionMatrix;
  32545. private _alternateViewMatrix;
  32546. private _alternateProjectionMatrix;
  32547. private _alternateTransformMatrix;
  32548. private _useAlternateCameraConfiguration;
  32549. private _alternateRendering;
  32550. private _wheelEventName;
  32551. /** @hidden */
  32552. _forcedViewPosition: Nullable<Vector3>;
  32553. /** @hidden */
  32554. readonly _isAlternateRenderingEnabled: boolean;
  32555. private _frustumPlanes;
  32556. /**
  32557. * Gets the list of frustum planes (built from the active camera)
  32558. */
  32559. readonly frustumPlanes: Plane[];
  32560. /**
  32561. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32562. * This is useful if there are more lights that the maximum simulteanous authorized
  32563. */
  32564. requireLightSorting: boolean;
  32565. /** @hidden */
  32566. readonly useMaterialMeshMap: boolean;
  32567. /** @hidden */
  32568. readonly useClonedMeshhMap: boolean;
  32569. private _pointerOverMesh;
  32570. private _pickedDownMesh;
  32571. private _pickedUpMesh;
  32572. private _externalData;
  32573. private _uid;
  32574. /**
  32575. * @hidden
  32576. * Backing store of defined scene components.
  32577. */
  32578. _components: ISceneComponent[];
  32579. /**
  32580. * @hidden
  32581. * Backing store of defined scene components.
  32582. */
  32583. _serializableComponents: ISceneSerializableComponent[];
  32584. /**
  32585. * List of components to register on the next registration step.
  32586. */
  32587. private _transientComponents;
  32588. /**
  32589. * Registers the transient components if needed.
  32590. */
  32591. private _registerTransientComponents;
  32592. /**
  32593. * @hidden
  32594. * Add a component to the scene.
  32595. * Note that the ccomponent could be registered on th next frame if this is called after
  32596. * the register component stage.
  32597. * @param component Defines the component to add to the scene
  32598. */
  32599. _addComponent(component: ISceneComponent): void;
  32600. /**
  32601. * @hidden
  32602. * Gets a component from the scene.
  32603. * @param name defines the name of the component to retrieve
  32604. * @returns the component or null if not present
  32605. */
  32606. _getComponent(name: string): Nullable<ISceneComponent>;
  32607. /**
  32608. * @hidden
  32609. * Defines the actions happening before camera updates.
  32610. */
  32611. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32612. /**
  32613. * @hidden
  32614. * Defines the actions happening before clear the canvas.
  32615. */
  32616. _beforeClearStage: Stage<SimpleStageAction>;
  32617. /**
  32618. * @hidden
  32619. * Defines the actions when collecting render targets for the frame.
  32620. */
  32621. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32622. /**
  32623. * @hidden
  32624. * Defines the actions happening for one camera in the frame.
  32625. */
  32626. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32627. /**
  32628. * @hidden
  32629. * Defines the actions happening during the per mesh ready checks.
  32630. */
  32631. _isReadyForMeshStage: Stage<MeshStageAction>;
  32632. /**
  32633. * @hidden
  32634. * Defines the actions happening before evaluate active mesh checks.
  32635. */
  32636. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32637. /**
  32638. * @hidden
  32639. * Defines the actions happening during the evaluate sub mesh checks.
  32640. */
  32641. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32642. /**
  32643. * @hidden
  32644. * Defines the actions happening during the active mesh stage.
  32645. */
  32646. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32647. /**
  32648. * @hidden
  32649. * Defines the actions happening during the per camera render target step.
  32650. */
  32651. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32652. /**
  32653. * @hidden
  32654. * Defines the actions happening just before the active camera is drawing.
  32655. */
  32656. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32657. /**
  32658. * @hidden
  32659. * Defines the actions happening just before a render target is drawing.
  32660. */
  32661. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32662. /**
  32663. * @hidden
  32664. * Defines the actions happening just before a rendering group is drawing.
  32665. */
  32666. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32667. /**
  32668. * @hidden
  32669. * Defines the actions happening just before a mesh is drawing.
  32670. */
  32671. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32672. /**
  32673. * @hidden
  32674. * Defines the actions happening just after a mesh has been drawn.
  32675. */
  32676. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32677. /**
  32678. * @hidden
  32679. * Defines the actions happening just after a rendering group has been drawn.
  32680. */
  32681. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32682. /**
  32683. * @hidden
  32684. * Defines the actions happening just after the active camera has been drawn.
  32685. */
  32686. _afterCameraDrawStage: Stage<CameraStageAction>;
  32687. /**
  32688. * @hidden
  32689. * Defines the actions happening just after a render target has been drawn.
  32690. */
  32691. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32692. /**
  32693. * @hidden
  32694. * Defines the actions happening just after rendering all cameras and computing intersections.
  32695. */
  32696. _afterRenderStage: Stage<SimpleStageAction>;
  32697. /**
  32698. * @hidden
  32699. * Defines the actions happening when a pointer move event happens.
  32700. */
  32701. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32702. /**
  32703. * @hidden
  32704. * Defines the actions happening when a pointer down event happens.
  32705. */
  32706. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32707. /**
  32708. * @hidden
  32709. * Defines the actions happening when a pointer up event happens.
  32710. */
  32711. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32712. /**
  32713. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32714. */
  32715. private geometriesByUniqueId;
  32716. /**
  32717. * Creates a new Scene
  32718. * @param engine defines the engine to use to render this scene
  32719. * @param options defines the scene options
  32720. */
  32721. constructor(engine: Engine, options?: SceneOptions);
  32722. private _defaultMeshCandidates;
  32723. /**
  32724. * @hidden
  32725. */
  32726. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32727. private _defaultSubMeshCandidates;
  32728. /**
  32729. * @hidden
  32730. */
  32731. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32732. /**
  32733. * Sets the default candidate providers for the scene.
  32734. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32735. * and getCollidingSubMeshCandidates to their default function
  32736. */
  32737. setDefaultCandidateProviders(): void;
  32738. /**
  32739. * Gets the mesh that is currently under the pointer
  32740. */
  32741. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32742. /**
  32743. * Gets or sets the current on-screen X position of the pointer
  32744. */
  32745. pointerX: number;
  32746. /**
  32747. * Gets or sets the current on-screen Y position of the pointer
  32748. */
  32749. pointerY: number;
  32750. /**
  32751. * Gets the cached material (ie. the latest rendered one)
  32752. * @returns the cached material
  32753. */
  32754. getCachedMaterial(): Nullable<Material>;
  32755. /**
  32756. * Gets the cached effect (ie. the latest rendered one)
  32757. * @returns the cached effect
  32758. */
  32759. getCachedEffect(): Nullable<Effect>;
  32760. /**
  32761. * Gets the cached visibility state (ie. the latest rendered one)
  32762. * @returns the cached visibility state
  32763. */
  32764. getCachedVisibility(): Nullable<number>;
  32765. /**
  32766. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32767. * @param material defines the current material
  32768. * @param effect defines the current effect
  32769. * @param visibility defines the current visibility state
  32770. * @returns true if one parameter is not cached
  32771. */
  32772. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32773. /**
  32774. * Gets the engine associated with the scene
  32775. * @returns an Engine
  32776. */
  32777. getEngine(): Engine;
  32778. /**
  32779. * Gets the total number of vertices rendered per frame
  32780. * @returns the total number of vertices rendered per frame
  32781. */
  32782. getTotalVertices(): number;
  32783. /**
  32784. * Gets the performance counter for total vertices
  32785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32786. */
  32787. readonly totalVerticesPerfCounter: PerfCounter;
  32788. /**
  32789. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32790. * @returns the total number of active indices rendered per frame
  32791. */
  32792. getActiveIndices(): number;
  32793. /**
  32794. * Gets the performance counter for active indices
  32795. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32796. */
  32797. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32798. /**
  32799. * Gets the total number of active particles rendered per frame
  32800. * @returns the total number of active particles rendered per frame
  32801. */
  32802. getActiveParticles(): number;
  32803. /**
  32804. * Gets the performance counter for active particles
  32805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32806. */
  32807. readonly activeParticlesPerfCounter: PerfCounter;
  32808. /**
  32809. * Gets the total number of active bones rendered per frame
  32810. * @returns the total number of active bones rendered per frame
  32811. */
  32812. getActiveBones(): number;
  32813. /**
  32814. * Gets the performance counter for active bones
  32815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32816. */
  32817. readonly activeBonesPerfCounter: PerfCounter;
  32818. /**
  32819. * Gets the array of active meshes
  32820. * @returns an array of AbstractMesh
  32821. */
  32822. getActiveMeshes(): SmartArray<AbstractMesh>;
  32823. /**
  32824. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32825. * @returns a number
  32826. */
  32827. getAnimationRatio(): number;
  32828. /**
  32829. * Gets an unique Id for the current render phase
  32830. * @returns a number
  32831. */
  32832. getRenderId(): number;
  32833. /**
  32834. * Gets an unique Id for the current frame
  32835. * @returns a number
  32836. */
  32837. getFrameId(): number;
  32838. /** Call this function if you want to manually increment the render Id*/
  32839. incrementRenderId(): void;
  32840. private _updatePointerPosition;
  32841. private _createUbo;
  32842. private _createAlternateUbo;
  32843. private _setRayOnPointerInfo;
  32844. /**
  32845. * Use this method to simulate a pointer move on a mesh
  32846. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32847. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32848. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32849. * @returns the current scene
  32850. */
  32851. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32852. private _processPointerMove;
  32853. private _checkPrePointerObservable;
  32854. /**
  32855. * Use this method to simulate a pointer down on a mesh
  32856. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32857. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32858. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32859. * @returns the current scene
  32860. */
  32861. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32862. private _processPointerDown;
  32863. /**
  32864. * Use this method to simulate a pointer up on a mesh
  32865. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32866. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32867. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32868. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32869. * @returns the current scene
  32870. */
  32871. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32872. private _processPointerUp;
  32873. /**
  32874. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32875. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32876. * @returns true if the pointer was captured
  32877. */
  32878. isPointerCaptured(pointerId?: number): boolean;
  32879. /** @hidden */
  32880. _isPointerSwiping(): boolean;
  32881. /**
  32882. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32883. * @param attachUp defines if you want to attach events to pointerup
  32884. * @param attachDown defines if you want to attach events to pointerdown
  32885. * @param attachMove defines if you want to attach events to pointermove
  32886. */
  32887. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32888. /** Detaches all event handlers*/
  32889. detachControl(): void;
  32890. /**
  32891. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32892. * Delay loaded resources are not taking in account
  32893. * @return true if all required resources are ready
  32894. */
  32895. isReady(): boolean;
  32896. /** Resets all cached information relative to material (including effect and visibility) */
  32897. resetCachedMaterial(): void;
  32898. /**
  32899. * Registers a function to be called before every frame render
  32900. * @param func defines the function to register
  32901. */
  32902. registerBeforeRender(func: () => void): void;
  32903. /**
  32904. * Unregisters a function called before every frame render
  32905. * @param func defines the function to unregister
  32906. */
  32907. unregisterBeforeRender(func: () => void): void;
  32908. /**
  32909. * Registers a function to be called after every frame render
  32910. * @param func defines the function to register
  32911. */
  32912. registerAfterRender(func: () => void): void;
  32913. /**
  32914. * Unregisters a function called after every frame render
  32915. * @param func defines the function to unregister
  32916. */
  32917. unregisterAfterRender(func: () => void): void;
  32918. private _executeOnceBeforeRender;
  32919. /**
  32920. * The provided function will run before render once and will be disposed afterwards.
  32921. * A timeout delay can be provided so that the function will be executed in N ms.
  32922. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32923. * @param func The function to be executed.
  32924. * @param timeout optional delay in ms
  32925. */
  32926. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32927. /** @hidden */
  32928. _addPendingData(data: any): void;
  32929. /** @hidden */
  32930. _removePendingData(data: any): void;
  32931. /**
  32932. * Returns the number of items waiting to be loaded
  32933. * @returns the number of items waiting to be loaded
  32934. */
  32935. getWaitingItemsCount(): number;
  32936. /**
  32937. * Returns a boolean indicating if the scene is still loading data
  32938. */
  32939. readonly isLoading: boolean;
  32940. /**
  32941. * Registers a function to be executed when the scene is ready
  32942. * @param {Function} func - the function to be executed
  32943. */
  32944. executeWhenReady(func: () => void): void;
  32945. /**
  32946. * Returns a promise that resolves when the scene is ready
  32947. * @returns A promise that resolves when the scene is ready
  32948. */
  32949. whenReadyAsync(): Promise<void>;
  32950. /** @hidden */
  32951. _checkIsReady(): void;
  32952. /**
  32953. * Gets all animatable attached to the scene
  32954. */
  32955. readonly animatables: Animatable[];
  32956. /**
  32957. * Resets the last animation time frame.
  32958. * Useful to override when animations start running when loading a scene for the first time.
  32959. */
  32960. resetLastAnimationTimeFrame(): void;
  32961. /** @hidden */
  32962. _switchToAlternateCameraConfiguration(active: boolean): void;
  32963. /**
  32964. * Gets the current view matrix
  32965. * @returns a Matrix
  32966. */
  32967. getViewMatrix(): Matrix;
  32968. /**
  32969. * Gets the current projection matrix
  32970. * @returns a Matrix
  32971. */
  32972. getProjectionMatrix(): Matrix;
  32973. /**
  32974. * Gets the current transform matrix
  32975. * @returns a Matrix made of View * Projection
  32976. */
  32977. getTransformMatrix(): Matrix;
  32978. /**
  32979. * Sets the current transform matrix
  32980. * @param view defines the View matrix to use
  32981. * @param projection defines the Projection matrix to use
  32982. */
  32983. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32984. /** @hidden */
  32985. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32986. /**
  32987. * Gets the uniform buffer used to store scene data
  32988. * @returns a UniformBuffer
  32989. */
  32990. getSceneUniformBuffer(): UniformBuffer;
  32991. /**
  32992. * Gets an unique (relatively to the current scene) Id
  32993. * @returns an unique number for the scene
  32994. */
  32995. getUniqueId(): number;
  32996. /**
  32997. * Add a mesh to the list of scene's meshes
  32998. * @param newMesh defines the mesh to add
  32999. * @param recursive if all child meshes should also be added to the scene
  33000. */
  33001. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33002. /**
  33003. * Remove a mesh for the list of scene's meshes
  33004. * @param toRemove defines the mesh to remove
  33005. * @param recursive if all child meshes should also be removed from the scene
  33006. * @returns the index where the mesh was in the mesh list
  33007. */
  33008. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33009. /**
  33010. * Add a transform node to the list of scene's transform nodes
  33011. * @param newTransformNode defines the transform node to add
  33012. */
  33013. addTransformNode(newTransformNode: TransformNode): void;
  33014. /**
  33015. * Remove a transform node for the list of scene's transform nodes
  33016. * @param toRemove defines the transform node to remove
  33017. * @returns the index where the transform node was in the transform node list
  33018. */
  33019. removeTransformNode(toRemove: TransformNode): number;
  33020. /**
  33021. * Remove a skeleton for the list of scene's skeletons
  33022. * @param toRemove defines the skeleton to remove
  33023. * @returns the index where the skeleton was in the skeleton list
  33024. */
  33025. removeSkeleton(toRemove: Skeleton): number;
  33026. /**
  33027. * Remove a morph target for the list of scene's morph targets
  33028. * @param toRemove defines the morph target to remove
  33029. * @returns the index where the morph target was in the morph target list
  33030. */
  33031. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33032. /**
  33033. * Remove a light for the list of scene's lights
  33034. * @param toRemove defines the light to remove
  33035. * @returns the index where the light was in the light list
  33036. */
  33037. removeLight(toRemove: Light): number;
  33038. /**
  33039. * Remove a camera for the list of scene's cameras
  33040. * @param toRemove defines the camera to remove
  33041. * @returns the index where the camera was in the camera list
  33042. */
  33043. removeCamera(toRemove: Camera): number;
  33044. /**
  33045. * Remove a particle system for the list of scene's particle systems
  33046. * @param toRemove defines the particle system to remove
  33047. * @returns the index where the particle system was in the particle system list
  33048. */
  33049. removeParticleSystem(toRemove: IParticleSystem): number;
  33050. /**
  33051. * Remove a animation for the list of scene's animations
  33052. * @param toRemove defines the animation to remove
  33053. * @returns the index where the animation was in the animation list
  33054. */
  33055. removeAnimation(toRemove: Animation): number;
  33056. /**
  33057. * Removes the given animation group from this scene.
  33058. * @param toRemove The animation group to remove
  33059. * @returns The index of the removed animation group
  33060. */
  33061. removeAnimationGroup(toRemove: AnimationGroup): number;
  33062. /**
  33063. * Removes the given multi-material from this scene.
  33064. * @param toRemove The multi-material to remove
  33065. * @returns The index of the removed multi-material
  33066. */
  33067. removeMultiMaterial(toRemove: MultiMaterial): number;
  33068. /**
  33069. * Removes the given material from this scene.
  33070. * @param toRemove The material to remove
  33071. * @returns The index of the removed material
  33072. */
  33073. removeMaterial(toRemove: Material): number;
  33074. /**
  33075. * Removes the given action manager from this scene.
  33076. * @param toRemove The action manager to remove
  33077. * @returns The index of the removed action manager
  33078. */
  33079. removeActionManager(toRemove: AbstractActionManager): number;
  33080. /**
  33081. * Removes the given texture from this scene.
  33082. * @param toRemove The texture to remove
  33083. * @returns The index of the removed texture
  33084. */
  33085. removeTexture(toRemove: BaseTexture): number;
  33086. /**
  33087. * Adds the given light to this scene
  33088. * @param newLight The light to add
  33089. */
  33090. addLight(newLight: Light): void;
  33091. /**
  33092. * Sorts the list list based on light priorities
  33093. */
  33094. sortLightsByPriority(): void;
  33095. /**
  33096. * Adds the given camera to this scene
  33097. * @param newCamera The camera to add
  33098. */
  33099. addCamera(newCamera: Camera): void;
  33100. /**
  33101. * Adds the given skeleton to this scene
  33102. * @param newSkeleton The skeleton to add
  33103. */
  33104. addSkeleton(newSkeleton: Skeleton): void;
  33105. /**
  33106. * Adds the given particle system to this scene
  33107. * @param newParticleSystem The particle system to add
  33108. */
  33109. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33110. /**
  33111. * Adds the given animation to this scene
  33112. * @param newAnimation The animation to add
  33113. */
  33114. addAnimation(newAnimation: Animation): void;
  33115. /**
  33116. * Adds the given animation group to this scene.
  33117. * @param newAnimationGroup The animation group to add
  33118. */
  33119. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33120. /**
  33121. * Adds the given multi-material to this scene
  33122. * @param newMultiMaterial The multi-material to add
  33123. */
  33124. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33125. /**
  33126. * Adds the given material to this scene
  33127. * @param newMaterial The material to add
  33128. */
  33129. addMaterial(newMaterial: Material): void;
  33130. /**
  33131. * Adds the given morph target to this scene
  33132. * @param newMorphTargetManager The morph target to add
  33133. */
  33134. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33135. /**
  33136. * Adds the given geometry to this scene
  33137. * @param newGeometry The geometry to add
  33138. */
  33139. addGeometry(newGeometry: Geometry): void;
  33140. /**
  33141. * Adds the given action manager to this scene
  33142. * @param newActionManager The action manager to add
  33143. */
  33144. addActionManager(newActionManager: AbstractActionManager): void;
  33145. /**
  33146. * Adds the given texture to this scene.
  33147. * @param newTexture The texture to add
  33148. */
  33149. addTexture(newTexture: BaseTexture): void;
  33150. /**
  33151. * Switch active camera
  33152. * @param newCamera defines the new active camera
  33153. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33154. */
  33155. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33156. /**
  33157. * sets the active camera of the scene using its ID
  33158. * @param id defines the camera's ID
  33159. * @return the new active camera or null if none found.
  33160. */
  33161. setActiveCameraByID(id: string): Nullable<Camera>;
  33162. /**
  33163. * sets the active camera of the scene using its name
  33164. * @param name defines the camera's name
  33165. * @returns the new active camera or null if none found.
  33166. */
  33167. setActiveCameraByName(name: string): Nullable<Camera>;
  33168. /**
  33169. * get an animation group using its name
  33170. * @param name defines the material's name
  33171. * @return the animation group or null if none found.
  33172. */
  33173. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33174. /**
  33175. * get a material using its id
  33176. * @param id defines the material's ID
  33177. * @return the material or null if none found.
  33178. */
  33179. getMaterialByID(id: string): Nullable<Material>;
  33180. /**
  33181. * Gets a material using its name
  33182. * @param name defines the material's name
  33183. * @return the material or null if none found.
  33184. */
  33185. getMaterialByName(name: string): Nullable<Material>;
  33186. /**
  33187. * Gets a camera using its id
  33188. * @param id defines the id to look for
  33189. * @returns the camera or null if not found
  33190. */
  33191. getCameraByID(id: string): Nullable<Camera>;
  33192. /**
  33193. * Gets a camera using its unique id
  33194. * @param uniqueId defines the unique id to look for
  33195. * @returns the camera or null if not found
  33196. */
  33197. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33198. /**
  33199. * Gets a camera using its name
  33200. * @param name defines the camera's name
  33201. * @return the camera or null if none found.
  33202. */
  33203. getCameraByName(name: string): Nullable<Camera>;
  33204. /**
  33205. * Gets a bone using its id
  33206. * @param id defines the bone's id
  33207. * @return the bone or null if not found
  33208. */
  33209. getBoneByID(id: string): Nullable<Bone>;
  33210. /**
  33211. * Gets a bone using its id
  33212. * @param name defines the bone's name
  33213. * @return the bone or null if not found
  33214. */
  33215. getBoneByName(name: string): Nullable<Bone>;
  33216. /**
  33217. * Gets a light node using its name
  33218. * @param name defines the the light's name
  33219. * @return the light or null if none found.
  33220. */
  33221. getLightByName(name: string): Nullable<Light>;
  33222. /**
  33223. * Gets a light node using its id
  33224. * @param id defines the light's id
  33225. * @return the light or null if none found.
  33226. */
  33227. getLightByID(id: string): Nullable<Light>;
  33228. /**
  33229. * Gets a light node using its scene-generated unique ID
  33230. * @param uniqueId defines the light's unique id
  33231. * @return the light or null if none found.
  33232. */
  33233. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33234. /**
  33235. * Gets a particle system by id
  33236. * @param id defines the particle system id
  33237. * @return the corresponding system or null if none found
  33238. */
  33239. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33240. /**
  33241. * Gets a geometry using its ID
  33242. * @param id defines the geometry's id
  33243. * @return the geometry or null if none found.
  33244. */
  33245. getGeometryByID(id: string): Nullable<Geometry>;
  33246. private _getGeometryByUniqueID;
  33247. /**
  33248. * Add a new geometry to this scene
  33249. * @param geometry defines the geometry to be added to the scene.
  33250. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33251. * @return a boolean defining if the geometry was added or not
  33252. */
  33253. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33254. /**
  33255. * Removes an existing geometry
  33256. * @param geometry defines the geometry to be removed from the scene
  33257. * @return a boolean defining if the geometry was removed or not
  33258. */
  33259. removeGeometry(geometry: Geometry): boolean;
  33260. /**
  33261. * Gets the list of geometries attached to the scene
  33262. * @returns an array of Geometry
  33263. */
  33264. getGeometries(): Geometry[];
  33265. /**
  33266. * Gets the first added mesh found of a given ID
  33267. * @param id defines the id to search for
  33268. * @return the mesh found or null if not found at all
  33269. */
  33270. getMeshByID(id: string): Nullable<AbstractMesh>;
  33271. /**
  33272. * Gets a list of meshes using their id
  33273. * @param id defines the id to search for
  33274. * @returns a list of meshes
  33275. */
  33276. getMeshesByID(id: string): Array<AbstractMesh>;
  33277. /**
  33278. * Gets the first added transform node found of a given ID
  33279. * @param id defines the id to search for
  33280. * @return the found transform node or null if not found at all.
  33281. */
  33282. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33283. /**
  33284. * Gets a list of transform nodes using their id
  33285. * @param id defines the id to search for
  33286. * @returns a list of transform nodes
  33287. */
  33288. getTransformNodesByID(id: string): Array<TransformNode>;
  33289. /**
  33290. * Gets a mesh with its auto-generated unique id
  33291. * @param uniqueId defines the unique id to search for
  33292. * @return the found mesh or null if not found at all.
  33293. */
  33294. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33295. /**
  33296. * Gets a the last added mesh using a given id
  33297. * @param id defines the id to search for
  33298. * @return the found mesh or null if not found at all.
  33299. */
  33300. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33301. /**
  33302. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33303. * @param id defines the id to search for
  33304. * @return the found node or null if not found at all
  33305. */
  33306. getLastEntryByID(id: string): Nullable<Node>;
  33307. /**
  33308. * Gets a node (Mesh, Camera, Light) using a given id
  33309. * @param id defines the id to search for
  33310. * @return the found node or null if not found at all
  33311. */
  33312. getNodeByID(id: string): Nullable<Node>;
  33313. /**
  33314. * Gets a node (Mesh, Camera, Light) using a given name
  33315. * @param name defines the name to search for
  33316. * @return the found node or null if not found at all.
  33317. */
  33318. getNodeByName(name: string): Nullable<Node>;
  33319. /**
  33320. * Gets a mesh using a given name
  33321. * @param name defines the name to search for
  33322. * @return the found mesh or null if not found at all.
  33323. */
  33324. getMeshByName(name: string): Nullable<AbstractMesh>;
  33325. /**
  33326. * Gets a transform node using a given name
  33327. * @param name defines the name to search for
  33328. * @return the found transform node or null if not found at all.
  33329. */
  33330. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33331. /**
  33332. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33333. * @param id defines the id to search for
  33334. * @return the found skeleton or null if not found at all.
  33335. */
  33336. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33337. /**
  33338. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33339. * @param id defines the id to search for
  33340. * @return the found skeleton or null if not found at all.
  33341. */
  33342. getSkeletonById(id: string): Nullable<Skeleton>;
  33343. /**
  33344. * Gets a skeleton using a given name
  33345. * @param name defines the name to search for
  33346. * @return the found skeleton or null if not found at all.
  33347. */
  33348. getSkeletonByName(name: string): Nullable<Skeleton>;
  33349. /**
  33350. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33351. * @param id defines the id to search for
  33352. * @return the found morph target manager or null if not found at all.
  33353. */
  33354. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33355. /**
  33356. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33357. * @param id defines the id to search for
  33358. * @return the found morph target or null if not found at all.
  33359. */
  33360. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33361. /**
  33362. * Gets a boolean indicating if the given mesh is active
  33363. * @param mesh defines the mesh to look for
  33364. * @returns true if the mesh is in the active list
  33365. */
  33366. isActiveMesh(mesh: AbstractMesh): boolean;
  33367. /**
  33368. * Return a unique id as a string which can serve as an identifier for the scene
  33369. */
  33370. readonly uid: string;
  33371. /**
  33372. * Add an externaly attached data from its key.
  33373. * This method call will fail and return false, if such key already exists.
  33374. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33375. * @param key the unique key that identifies the data
  33376. * @param data the data object to associate to the key for this Engine instance
  33377. * @return true if no such key were already present and the data was added successfully, false otherwise
  33378. */
  33379. addExternalData<T>(key: string, data: T): boolean;
  33380. /**
  33381. * Get an externaly attached data from its key
  33382. * @param key the unique key that identifies the data
  33383. * @return the associated data, if present (can be null), or undefined if not present
  33384. */
  33385. getExternalData<T>(key: string): Nullable<T>;
  33386. /**
  33387. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33388. * @param key the unique key that identifies the data
  33389. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33390. * @return the associated data, can be null if the factory returned null.
  33391. */
  33392. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33393. /**
  33394. * Remove an externaly attached data from the Engine instance
  33395. * @param key the unique key that identifies the data
  33396. * @return true if the data was successfully removed, false if it doesn't exist
  33397. */
  33398. removeExternalData(key: string): boolean;
  33399. private _evaluateSubMesh;
  33400. /**
  33401. * Clear the processed materials smart array preventing retention point in material dispose.
  33402. */
  33403. freeProcessedMaterials(): void;
  33404. private _preventFreeActiveMeshesAndRenderingGroups;
  33405. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33406. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33407. * when disposing several meshes in a row or a hierarchy of meshes.
  33408. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33409. */
  33410. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33411. /**
  33412. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33413. */
  33414. freeActiveMeshes(): void;
  33415. /**
  33416. * Clear the info related to rendering groups preventing retention points during dispose.
  33417. */
  33418. freeRenderingGroups(): void;
  33419. /** @hidden */
  33420. _isInIntermediateRendering(): boolean;
  33421. /**
  33422. * Lambda returning the list of potentially active meshes.
  33423. */
  33424. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33425. /**
  33426. * Lambda returning the list of potentially active sub meshes.
  33427. */
  33428. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33429. /**
  33430. * Lambda returning the list of potentially intersecting sub meshes.
  33431. */
  33432. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33433. /**
  33434. * Lambda returning the list of potentially colliding sub meshes.
  33435. */
  33436. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33437. private _activeMeshesFrozen;
  33438. /**
  33439. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33440. * @returns the current scene
  33441. */
  33442. freezeActiveMeshes(): Scene;
  33443. /**
  33444. * Use this function to restart evaluating active meshes on every frame
  33445. * @returns the current scene
  33446. */
  33447. unfreezeActiveMeshes(): Scene;
  33448. private _evaluateActiveMeshes;
  33449. private _activeMesh;
  33450. /**
  33451. * Update the transform matrix to update from the current active camera
  33452. * @param force defines a boolean used to force the update even if cache is up to date
  33453. */
  33454. updateTransformMatrix(force?: boolean): void;
  33455. /**
  33456. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33457. * @param alternateCamera defines the camera to use
  33458. */
  33459. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33460. /** @hidden */
  33461. _allowPostProcessClearColor: boolean;
  33462. private _renderForCamera;
  33463. private _processSubCameras;
  33464. private _checkIntersections;
  33465. /** @hidden */
  33466. _advancePhysicsEngineStep(step: number): void;
  33467. /**
  33468. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33469. */
  33470. getDeterministicFrameTime: () => number;
  33471. /** @hidden */
  33472. _animate(): void;
  33473. /**
  33474. * Render the scene
  33475. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33476. */
  33477. render(updateCameras?: boolean): void;
  33478. /**
  33479. * Freeze all materials
  33480. * A frozen material will not be updatable but should be faster to render
  33481. */
  33482. freezeMaterials(): void;
  33483. /**
  33484. * Unfreeze all materials
  33485. * A frozen material will not be updatable but should be faster to render
  33486. */
  33487. unfreezeMaterials(): void;
  33488. /**
  33489. * Releases all held ressources
  33490. */
  33491. dispose(): void;
  33492. /**
  33493. * Gets if the scene is already disposed
  33494. */
  33495. readonly isDisposed: boolean;
  33496. /**
  33497. * Call this function to reduce memory footprint of the scene.
  33498. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33499. */
  33500. clearCachedVertexData(): void;
  33501. /**
  33502. * This function will remove the local cached buffer data from texture.
  33503. * It will save memory but will prevent the texture from being rebuilt
  33504. */
  33505. cleanCachedTextureBuffer(): void;
  33506. /**
  33507. * Get the world extend vectors with an optional filter
  33508. *
  33509. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33510. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33511. */
  33512. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33513. min: Vector3;
  33514. max: Vector3;
  33515. };
  33516. /**
  33517. * Creates a ray that can be used to pick in the scene
  33518. * @param x defines the x coordinate of the origin (on-screen)
  33519. * @param y defines the y coordinate of the origin (on-screen)
  33520. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33521. * @param camera defines the camera to use for the picking
  33522. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33523. * @returns a Ray
  33524. */
  33525. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33526. /**
  33527. * Creates a ray that can be used to pick in the scene
  33528. * @param x defines the x coordinate of the origin (on-screen)
  33529. * @param y defines the y coordinate of the origin (on-screen)
  33530. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33531. * @param result defines the ray where to store the picking ray
  33532. * @param camera defines the camera to use for the picking
  33533. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33534. * @returns the current scene
  33535. */
  33536. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33537. /**
  33538. * Creates a ray that can be used to pick in the scene
  33539. * @param x defines the x coordinate of the origin (on-screen)
  33540. * @param y defines the y coordinate of the origin (on-screen)
  33541. * @param camera defines the camera to use for the picking
  33542. * @returns a Ray
  33543. */
  33544. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33545. /**
  33546. * Creates a ray that can be used to pick in the scene
  33547. * @param x defines the x coordinate of the origin (on-screen)
  33548. * @param y defines the y coordinate of the origin (on-screen)
  33549. * @param result defines the ray where to store the picking ray
  33550. * @param camera defines the camera to use for the picking
  33551. * @returns the current scene
  33552. */
  33553. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33554. /** Launch a ray to try to pick a mesh in the scene
  33555. * @param x position on screen
  33556. * @param y position on screen
  33557. * @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
  33558. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33559. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33560. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33561. * @returns a PickingInfo
  33562. */
  33563. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33564. /** Use the given ray to pick a mesh in the scene
  33565. * @param ray The ray to use to pick meshes
  33566. * @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
  33567. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33568. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33569. * @returns a PickingInfo
  33570. */
  33571. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33572. /**
  33573. * Launch a ray to try to pick a mesh in the scene
  33574. * @param x X position on screen
  33575. * @param y Y position on screen
  33576. * @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
  33577. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33578. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33579. * @returns an array of PickingInfo
  33580. */
  33581. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33582. /**
  33583. * Launch a ray to try to pick a mesh in the scene
  33584. * @param ray Ray to use
  33585. * @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
  33586. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33587. * @returns an array of PickingInfo
  33588. */
  33589. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33590. /**
  33591. * Force the value of meshUnderPointer
  33592. * @param mesh defines the mesh to use
  33593. */
  33594. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33595. /**
  33596. * Gets the mesh under the pointer
  33597. * @returns a Mesh or null if no mesh is under the pointer
  33598. */
  33599. getPointerOverMesh(): Nullable<AbstractMesh>;
  33600. /** @hidden */
  33601. _rebuildGeometries(): void;
  33602. /** @hidden */
  33603. _rebuildTextures(): void;
  33604. private _getByTags;
  33605. /**
  33606. * Get a list of meshes by tags
  33607. * @param tagsQuery defines the tags query to use
  33608. * @param forEach defines a predicate used to filter results
  33609. * @returns an array of Mesh
  33610. */
  33611. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33612. /**
  33613. * Get a list of cameras by tags
  33614. * @param tagsQuery defines the tags query to use
  33615. * @param forEach defines a predicate used to filter results
  33616. * @returns an array of Camera
  33617. */
  33618. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33619. /**
  33620. * Get a list of lights by tags
  33621. * @param tagsQuery defines the tags query to use
  33622. * @param forEach defines a predicate used to filter results
  33623. * @returns an array of Light
  33624. */
  33625. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33626. /**
  33627. * Get a list of materials by tags
  33628. * @param tagsQuery defines the tags query to use
  33629. * @param forEach defines a predicate used to filter results
  33630. * @returns an array of Material
  33631. */
  33632. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33633. /**
  33634. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33635. * This allowed control for front to back rendering or reversly depending of the special needs.
  33636. *
  33637. * @param renderingGroupId The rendering group id corresponding to its index
  33638. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33639. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33640. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33641. */
  33642. 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;
  33643. /**
  33644. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33645. *
  33646. * @param renderingGroupId The rendering group id corresponding to its index
  33647. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33648. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33649. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33650. */
  33651. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33652. /**
  33653. * Gets the current auto clear configuration for one rendering group of the rendering
  33654. * manager.
  33655. * @param index the rendering group index to get the information for
  33656. * @returns The auto clear setup for the requested rendering group
  33657. */
  33658. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33659. private _blockMaterialDirtyMechanism;
  33660. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33661. blockMaterialDirtyMechanism: boolean;
  33662. /**
  33663. * Will flag all materials as dirty to trigger new shader compilation
  33664. * @param flag defines the flag used to specify which material part must be marked as dirty
  33665. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33666. */
  33667. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33668. /** @hidden */
  33669. _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;
  33670. /** @hidden */
  33671. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33672. }
  33673. }
  33674. declare module "babylonjs/assetContainer" {
  33675. import { AbstractScene } from "babylonjs/abstractScene";
  33676. import { Scene } from "babylonjs/scene";
  33677. import { Mesh } from "babylonjs/Meshes/mesh";
  33678. /**
  33679. * Set of assets to keep when moving a scene into an asset container.
  33680. */
  33681. export class KeepAssets extends AbstractScene {
  33682. }
  33683. /**
  33684. * Container with a set of assets that can be added or removed from a scene.
  33685. */
  33686. export class AssetContainer extends AbstractScene {
  33687. /**
  33688. * The scene the AssetContainer belongs to.
  33689. */
  33690. scene: Scene;
  33691. /**
  33692. * Instantiates an AssetContainer.
  33693. * @param scene The scene the AssetContainer belongs to.
  33694. */
  33695. constructor(scene: Scene);
  33696. /**
  33697. * Adds all the assets from the container to the scene.
  33698. */
  33699. addAllToScene(): void;
  33700. /**
  33701. * Removes all the assets in the container from the scene
  33702. */
  33703. removeAllFromScene(): void;
  33704. /**
  33705. * Disposes all the assets in the container
  33706. */
  33707. dispose(): void;
  33708. private _moveAssets;
  33709. /**
  33710. * Removes all the assets contained in the scene and adds them to the container.
  33711. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33712. */
  33713. moveAllFromScene(keepAssets?: KeepAssets): void;
  33714. /**
  33715. * 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.
  33716. * @returns the root mesh
  33717. */
  33718. createRootMesh(): Mesh;
  33719. }
  33720. }
  33721. declare module "babylonjs/abstractScene" {
  33722. import { Scene } from "babylonjs/scene";
  33723. import { Nullable } from "babylonjs/types";
  33724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33725. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33726. import { Geometry } from "babylonjs/Meshes/geometry";
  33727. import { Skeleton } from "babylonjs/Bones/skeleton";
  33728. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33729. import { AssetContainer } from "babylonjs/assetContainer";
  33730. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33731. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33733. import { Material } from "babylonjs/Materials/material";
  33734. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33735. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33736. import { Camera } from "babylonjs/Cameras/camera";
  33737. import { Light } from "babylonjs/Lights/light";
  33738. import { Node } from "babylonjs/node";
  33739. import { Animation } from "babylonjs/Animations/animation";
  33740. /**
  33741. * Defines how the parser contract is defined.
  33742. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33743. */
  33744. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33745. /**
  33746. * Defines how the individual parser contract is defined.
  33747. * These parser can parse an individual asset
  33748. */
  33749. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33750. /**
  33751. * Base class of the scene acting as a container for the different elements composing a scene.
  33752. * This class is dynamically extended by the different components of the scene increasing
  33753. * flexibility and reducing coupling
  33754. */
  33755. export abstract class AbstractScene {
  33756. /**
  33757. * Stores the list of available parsers in the application.
  33758. */
  33759. private static _BabylonFileParsers;
  33760. /**
  33761. * Stores the list of available individual parsers in the application.
  33762. */
  33763. private static _IndividualBabylonFileParsers;
  33764. /**
  33765. * Adds a parser in the list of available ones
  33766. * @param name Defines the name of the parser
  33767. * @param parser Defines the parser to add
  33768. */
  33769. static AddParser(name: string, parser: BabylonFileParser): void;
  33770. /**
  33771. * Gets a general parser from the list of avaialble ones
  33772. * @param name Defines the name of the parser
  33773. * @returns the requested parser or null
  33774. */
  33775. static GetParser(name: string): Nullable<BabylonFileParser>;
  33776. /**
  33777. * Adds n individual parser in the list of available ones
  33778. * @param name Defines the name of the parser
  33779. * @param parser Defines the parser to add
  33780. */
  33781. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33782. /**
  33783. * Gets an individual parser from the list of avaialble ones
  33784. * @param name Defines the name of the parser
  33785. * @returns the requested parser or null
  33786. */
  33787. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33788. /**
  33789. * Parser json data and populate both a scene and its associated container object
  33790. * @param jsonData Defines the data to parse
  33791. * @param scene Defines the scene to parse the data for
  33792. * @param container Defines the container attached to the parsing sequence
  33793. * @param rootUrl Defines the root url of the data
  33794. */
  33795. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33796. /**
  33797. * Gets the list of root nodes (ie. nodes with no parent)
  33798. */
  33799. rootNodes: Node[];
  33800. /** All of the cameras added to this scene
  33801. * @see http://doc.babylonjs.com/babylon101/cameras
  33802. */
  33803. cameras: Camera[];
  33804. /**
  33805. * All of the lights added to this scene
  33806. * @see http://doc.babylonjs.com/babylon101/lights
  33807. */
  33808. lights: Light[];
  33809. /**
  33810. * All of the (abstract) meshes added to this scene
  33811. */
  33812. meshes: AbstractMesh[];
  33813. /**
  33814. * The list of skeletons added to the scene
  33815. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33816. */
  33817. skeletons: Skeleton[];
  33818. /**
  33819. * All of the particle systems added to this scene
  33820. * @see http://doc.babylonjs.com/babylon101/particles
  33821. */
  33822. particleSystems: IParticleSystem[];
  33823. /**
  33824. * Gets a list of Animations associated with the scene
  33825. */
  33826. animations: Animation[];
  33827. /**
  33828. * All of the animation groups added to this scene
  33829. * @see http://doc.babylonjs.com/how_to/group
  33830. */
  33831. animationGroups: AnimationGroup[];
  33832. /**
  33833. * All of the multi-materials added to this scene
  33834. * @see http://doc.babylonjs.com/how_to/multi_materials
  33835. */
  33836. multiMaterials: MultiMaterial[];
  33837. /**
  33838. * All of the materials added to this scene
  33839. * In the context of a Scene, it is not supposed to be modified manually.
  33840. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33841. * Note also that the order of the Material wihin the array is not significant and might change.
  33842. * @see http://doc.babylonjs.com/babylon101/materials
  33843. */
  33844. materials: Material[];
  33845. /**
  33846. * The list of morph target managers added to the scene
  33847. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33848. */
  33849. morphTargetManagers: MorphTargetManager[];
  33850. /**
  33851. * The list of geometries used in the scene.
  33852. */
  33853. geometries: Geometry[];
  33854. /**
  33855. * All of the tranform nodes added to this scene
  33856. * In the context of a Scene, it is not supposed to be modified manually.
  33857. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33858. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33859. * @see http://doc.babylonjs.com/how_to/transformnode
  33860. */
  33861. transformNodes: TransformNode[];
  33862. /**
  33863. * ActionManagers available on the scene.
  33864. */
  33865. actionManagers: AbstractActionManager[];
  33866. /**
  33867. * Textures to keep.
  33868. */
  33869. textures: BaseTexture[];
  33870. }
  33871. }
  33872. declare module "babylonjs/Audio/sound" {
  33873. import { Observable } from "babylonjs/Misc/observable";
  33874. import { Vector3 } from "babylonjs/Maths/math";
  33875. import { Nullable } from "babylonjs/types";
  33876. import { Scene } from "babylonjs/scene";
  33877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33878. /**
  33879. * Defines a sound that can be played in the application.
  33880. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33882. */
  33883. export class Sound {
  33884. /**
  33885. * The name of the sound in the scene.
  33886. */
  33887. name: string;
  33888. /**
  33889. * Does the sound autoplay once loaded.
  33890. */
  33891. autoplay: boolean;
  33892. /**
  33893. * Does the sound loop after it finishes playing once.
  33894. */
  33895. loop: boolean;
  33896. /**
  33897. * Does the sound use a custom attenuation curve to simulate the falloff
  33898. * happening when the source gets further away from the camera.
  33899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33900. */
  33901. useCustomAttenuation: boolean;
  33902. /**
  33903. * The sound track id this sound belongs to.
  33904. */
  33905. soundTrackId: number;
  33906. /**
  33907. * Is this sound currently played.
  33908. */
  33909. isPlaying: boolean;
  33910. /**
  33911. * Is this sound currently paused.
  33912. */
  33913. isPaused: boolean;
  33914. /**
  33915. * Does this sound enables spatial sound.
  33916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33917. */
  33918. spatialSound: boolean;
  33919. /**
  33920. * Define the reference distance the sound should be heard perfectly.
  33921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33922. */
  33923. refDistance: number;
  33924. /**
  33925. * Define the roll off factor of spatial sounds.
  33926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33927. */
  33928. rolloffFactor: number;
  33929. /**
  33930. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33932. */
  33933. maxDistance: number;
  33934. /**
  33935. * Define the distance attenuation model the sound will follow.
  33936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33937. */
  33938. distanceModel: string;
  33939. /**
  33940. * @hidden
  33941. * Back Compat
  33942. **/
  33943. onended: () => any;
  33944. /**
  33945. * Observable event when the current playing sound finishes.
  33946. */
  33947. onEndedObservable: Observable<Sound>;
  33948. private _panningModel;
  33949. private _playbackRate;
  33950. private _streaming;
  33951. private _startTime;
  33952. private _startOffset;
  33953. private _position;
  33954. /** @hidden */
  33955. _positionInEmitterSpace: boolean;
  33956. private _localDirection;
  33957. private _volume;
  33958. private _isReadyToPlay;
  33959. private _isDirectional;
  33960. private _readyToPlayCallback;
  33961. private _audioBuffer;
  33962. private _soundSource;
  33963. private _streamingSource;
  33964. private _soundPanner;
  33965. private _soundGain;
  33966. private _inputAudioNode;
  33967. private _outputAudioNode;
  33968. private _coneInnerAngle;
  33969. private _coneOuterAngle;
  33970. private _coneOuterGain;
  33971. private _scene;
  33972. private _connectedTransformNode;
  33973. private _customAttenuationFunction;
  33974. private _registerFunc;
  33975. private _isOutputConnected;
  33976. private _htmlAudioElement;
  33977. private _urlType;
  33978. /** @hidden */
  33979. static _SceneComponentInitialization: (scene: Scene) => void;
  33980. /**
  33981. * Create a sound and attach it to a scene
  33982. * @param name Name of your sound
  33983. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33984. * @param scene defines the scene the sound belongs to
  33985. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33986. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33987. */
  33988. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33989. /**
  33990. * Release the sound and its associated resources
  33991. */
  33992. dispose(): void;
  33993. /**
  33994. * Gets if the sounds is ready to be played or not.
  33995. * @returns true if ready, otherwise false
  33996. */
  33997. isReady(): boolean;
  33998. private _soundLoaded;
  33999. /**
  34000. * Sets the data of the sound from an audiobuffer
  34001. * @param audioBuffer The audioBuffer containing the data
  34002. */
  34003. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34004. /**
  34005. * Updates the current sounds options such as maxdistance, loop...
  34006. * @param options A JSON object containing values named as the object properties
  34007. */
  34008. updateOptions(options: any): void;
  34009. private _createSpatialParameters;
  34010. private _updateSpatialParameters;
  34011. /**
  34012. * Switch the panning model to HRTF:
  34013. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34015. */
  34016. switchPanningModelToHRTF(): void;
  34017. /**
  34018. * Switch the panning model to Equal Power:
  34019. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34021. */
  34022. switchPanningModelToEqualPower(): void;
  34023. private _switchPanningModel;
  34024. /**
  34025. * Connect this sound to a sound track audio node like gain...
  34026. * @param soundTrackAudioNode the sound track audio node to connect to
  34027. */
  34028. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34029. /**
  34030. * Transform this sound into a directional source
  34031. * @param coneInnerAngle Size of the inner cone in degree
  34032. * @param coneOuterAngle Size of the outer cone in degree
  34033. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34034. */
  34035. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34036. /**
  34037. * Gets or sets the inner angle for the directional cone.
  34038. */
  34039. /**
  34040. * Gets or sets the inner angle for the directional cone.
  34041. */
  34042. directionalConeInnerAngle: number;
  34043. /**
  34044. * Gets or sets the outer angle for the directional cone.
  34045. */
  34046. /**
  34047. * Gets or sets the outer angle for the directional cone.
  34048. */
  34049. directionalConeOuterAngle: number;
  34050. /**
  34051. * Sets the position of the emitter if spatial sound is enabled
  34052. * @param newPosition Defines the new posisiton
  34053. */
  34054. setPosition(newPosition: Vector3): void;
  34055. /**
  34056. * Sets the local direction of the emitter if spatial sound is enabled
  34057. * @param newLocalDirection Defines the new local direction
  34058. */
  34059. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34060. private _updateDirection;
  34061. /** @hidden */
  34062. updateDistanceFromListener(): void;
  34063. /**
  34064. * Sets a new custom attenuation function for the sound.
  34065. * @param callback Defines the function used for the attenuation
  34066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34067. */
  34068. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34069. /**
  34070. * Play the sound
  34071. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34072. * @param offset (optional) Start the sound setting it at a specific time
  34073. */
  34074. play(time?: number, offset?: number): void;
  34075. private _onended;
  34076. /**
  34077. * Stop the sound
  34078. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34079. */
  34080. stop(time?: number): void;
  34081. /**
  34082. * Put the sound in pause
  34083. */
  34084. pause(): void;
  34085. /**
  34086. * Sets a dedicated volume for this sounds
  34087. * @param newVolume Define the new volume of the sound
  34088. * @param time Define in how long the sound should be at this value
  34089. */
  34090. setVolume(newVolume: number, time?: number): void;
  34091. /**
  34092. * Set the sound play back rate
  34093. * @param newPlaybackRate Define the playback rate the sound should be played at
  34094. */
  34095. setPlaybackRate(newPlaybackRate: number): void;
  34096. /**
  34097. * Gets the volume of the sound.
  34098. * @returns the volume of the sound
  34099. */
  34100. getVolume(): number;
  34101. /**
  34102. * Attach the sound to a dedicated mesh
  34103. * @param transformNode The transform node to connect the sound with
  34104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34105. */
  34106. attachToMesh(transformNode: TransformNode): void;
  34107. /**
  34108. * Detach the sound from the previously attached mesh
  34109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34110. */
  34111. detachFromMesh(): void;
  34112. private _onRegisterAfterWorldMatrixUpdate;
  34113. /**
  34114. * Clone the current sound in the scene.
  34115. * @returns the new sound clone
  34116. */
  34117. clone(): Nullable<Sound>;
  34118. /**
  34119. * Gets the current underlying audio buffer containing the data
  34120. * @returns the audio buffer
  34121. */
  34122. getAudioBuffer(): Nullable<AudioBuffer>;
  34123. /**
  34124. * Serializes the Sound in a JSON representation
  34125. * @returns the JSON representation of the sound
  34126. */
  34127. serialize(): any;
  34128. /**
  34129. * Parse a JSON representation of a sound to innstantiate in a given scene
  34130. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34131. * @param scene Define the scene the new parsed sound should be created in
  34132. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34133. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34134. * @returns the newly parsed sound
  34135. */
  34136. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34137. }
  34138. }
  34139. declare module "babylonjs/Actions/directAudioActions" {
  34140. import { Action } from "babylonjs/Actions/action";
  34141. import { Condition } from "babylonjs/Actions/condition";
  34142. import { Sound } from "babylonjs/Audio/sound";
  34143. /**
  34144. * This defines an action helpful to play a defined sound on a triggered action.
  34145. */
  34146. export class PlaySoundAction extends Action {
  34147. private _sound;
  34148. /**
  34149. * Instantiate the action
  34150. * @param triggerOptions defines the trigger options
  34151. * @param sound defines the sound to play
  34152. * @param condition defines the trigger related conditions
  34153. */
  34154. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34155. /** @hidden */
  34156. _prepare(): void;
  34157. /**
  34158. * Execute the action and play the sound.
  34159. */
  34160. execute(): void;
  34161. /**
  34162. * Serializes the actions and its related information.
  34163. * @param parent defines the object to serialize in
  34164. * @returns the serialized object
  34165. */
  34166. serialize(parent: any): any;
  34167. }
  34168. /**
  34169. * This defines an action helpful to stop a defined sound on a triggered action.
  34170. */
  34171. export class StopSoundAction extends Action {
  34172. private _sound;
  34173. /**
  34174. * Instantiate the action
  34175. * @param triggerOptions defines the trigger options
  34176. * @param sound defines the sound to stop
  34177. * @param condition defines the trigger related conditions
  34178. */
  34179. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34180. /** @hidden */
  34181. _prepare(): void;
  34182. /**
  34183. * Execute the action and stop the sound.
  34184. */
  34185. execute(): void;
  34186. /**
  34187. * Serializes the actions and its related information.
  34188. * @param parent defines the object to serialize in
  34189. * @returns the serialized object
  34190. */
  34191. serialize(parent: any): any;
  34192. }
  34193. }
  34194. declare module "babylonjs/Actions/interpolateValueAction" {
  34195. import { Action } from "babylonjs/Actions/action";
  34196. import { Condition } from "babylonjs/Actions/condition";
  34197. import { Observable } from "babylonjs/Misc/observable";
  34198. /**
  34199. * This defines an action responsible to change the value of a property
  34200. * by interpolating between its current value and the newly set one once triggered.
  34201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34202. */
  34203. export class InterpolateValueAction extends Action {
  34204. /**
  34205. * Defines the path of the property where the value should be interpolated
  34206. */
  34207. propertyPath: string;
  34208. /**
  34209. * Defines the target value at the end of the interpolation.
  34210. */
  34211. value: any;
  34212. /**
  34213. * Defines the time it will take for the property to interpolate to the value.
  34214. */
  34215. duration: number;
  34216. /**
  34217. * Defines if the other scene animations should be stopped when the action has been triggered
  34218. */
  34219. stopOtherAnimations?: boolean;
  34220. /**
  34221. * Defines a callback raised once the interpolation animation has been done.
  34222. */
  34223. onInterpolationDone?: () => void;
  34224. /**
  34225. * Observable triggered once the interpolation animation has been done.
  34226. */
  34227. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34228. private _target;
  34229. private _effectiveTarget;
  34230. private _property;
  34231. /**
  34232. * Instantiate the action
  34233. * @param triggerOptions defines the trigger options
  34234. * @param target defines the object containing the value to interpolate
  34235. * @param propertyPath defines the path to the property in the target object
  34236. * @param value defines the target value at the end of the interpolation
  34237. * @param duration deines the time it will take for the property to interpolate to the value.
  34238. * @param condition defines the trigger related conditions
  34239. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34240. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34241. */
  34242. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34243. /** @hidden */
  34244. _prepare(): void;
  34245. /**
  34246. * Execute the action starts the value interpolation.
  34247. */
  34248. execute(): void;
  34249. /**
  34250. * Serializes the actions and its related information.
  34251. * @param parent defines the object to serialize in
  34252. * @returns the serialized object
  34253. */
  34254. serialize(parent: any): any;
  34255. }
  34256. }
  34257. declare module "babylonjs/Actions/index" {
  34258. export * from "babylonjs/Actions/action";
  34259. export * from "babylonjs/Actions/actionEvent";
  34260. export * from "babylonjs/Actions/actionManager";
  34261. export * from "babylonjs/Actions/condition";
  34262. export * from "babylonjs/Actions/directActions";
  34263. export * from "babylonjs/Actions/directAudioActions";
  34264. export * from "babylonjs/Actions/interpolateValueAction";
  34265. }
  34266. declare module "babylonjs/Animations/index" {
  34267. export * from "babylonjs/Animations/animatable";
  34268. export * from "babylonjs/Animations/animation";
  34269. export * from "babylonjs/Animations/animationGroup";
  34270. export * from "babylonjs/Animations/animationPropertiesOverride";
  34271. export * from "babylonjs/Animations/easing";
  34272. export * from "babylonjs/Animations/runtimeAnimation";
  34273. export * from "babylonjs/Animations/animationEvent";
  34274. export * from "babylonjs/Animations/animationGroup";
  34275. export * from "babylonjs/Animations/animationKey";
  34276. export * from "babylonjs/Animations/animationRange";
  34277. }
  34278. declare module "babylonjs/Audio/soundTrack" {
  34279. import { Sound } from "babylonjs/Audio/sound";
  34280. import { Analyser } from "babylonjs/Audio/analyser";
  34281. import { Scene } from "babylonjs/scene";
  34282. /**
  34283. * Options allowed during the creation of a sound track.
  34284. */
  34285. export interface ISoundTrackOptions {
  34286. /**
  34287. * The volume the sound track should take during creation
  34288. */
  34289. volume?: number;
  34290. /**
  34291. * Define if the sound track is the main sound track of the scene
  34292. */
  34293. mainTrack?: boolean;
  34294. }
  34295. /**
  34296. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34297. * It will be also used in a future release to apply effects on a specific track.
  34298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34299. */
  34300. export class SoundTrack {
  34301. /**
  34302. * The unique identifier of the sound track in the scene.
  34303. */
  34304. id: number;
  34305. /**
  34306. * The list of sounds included in the sound track.
  34307. */
  34308. soundCollection: Array<Sound>;
  34309. private _outputAudioNode;
  34310. private _scene;
  34311. private _isMainTrack;
  34312. private _connectedAnalyser;
  34313. private _options;
  34314. private _isInitialized;
  34315. /**
  34316. * Creates a new sound track.
  34317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34318. * @param scene Define the scene the sound track belongs to
  34319. * @param options
  34320. */
  34321. constructor(scene: Scene, options?: ISoundTrackOptions);
  34322. private _initializeSoundTrackAudioGraph;
  34323. /**
  34324. * Release the sound track and its associated resources
  34325. */
  34326. dispose(): void;
  34327. /**
  34328. * Adds a sound to this sound track
  34329. * @param sound define the cound to add
  34330. * @ignoreNaming
  34331. */
  34332. AddSound(sound: Sound): void;
  34333. /**
  34334. * Removes a sound to this sound track
  34335. * @param sound define the cound to remove
  34336. * @ignoreNaming
  34337. */
  34338. RemoveSound(sound: Sound): void;
  34339. /**
  34340. * Set a global volume for the full sound track.
  34341. * @param newVolume Define the new volume of the sound track
  34342. */
  34343. setVolume(newVolume: number): void;
  34344. /**
  34345. * Switch the panning model to HRTF:
  34346. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34348. */
  34349. switchPanningModelToHRTF(): void;
  34350. /**
  34351. * Switch the panning model to Equal Power:
  34352. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34354. */
  34355. switchPanningModelToEqualPower(): void;
  34356. /**
  34357. * Connect the sound track to an audio analyser allowing some amazing
  34358. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34360. * @param analyser The analyser to connect to the engine
  34361. */
  34362. connectToAnalyser(analyser: Analyser): void;
  34363. }
  34364. }
  34365. declare module "babylonjs/Audio/audioSceneComponent" {
  34366. import { Sound } from "babylonjs/Audio/sound";
  34367. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34368. import { Nullable } from "babylonjs/types";
  34369. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34370. import { Scene } from "babylonjs/scene";
  34371. import { AbstractScene } from "babylonjs/abstractScene";
  34372. module "babylonjs/abstractScene" {
  34373. interface AbstractScene {
  34374. /**
  34375. * The list of sounds used in the scene.
  34376. */
  34377. sounds: Nullable<Array<Sound>>;
  34378. }
  34379. }
  34380. module "babylonjs/scene" {
  34381. interface Scene {
  34382. /**
  34383. * @hidden
  34384. * Backing field
  34385. */
  34386. _mainSoundTrack: SoundTrack;
  34387. /**
  34388. * The main sound track played by the scene.
  34389. * It cotains your primary collection of sounds.
  34390. */
  34391. mainSoundTrack: SoundTrack;
  34392. /**
  34393. * The list of sound tracks added to the scene
  34394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34395. */
  34396. soundTracks: Nullable<Array<SoundTrack>>;
  34397. /**
  34398. * Gets a sound using a given name
  34399. * @param name defines the name to search for
  34400. * @return the found sound or null if not found at all.
  34401. */
  34402. getSoundByName(name: string): Nullable<Sound>;
  34403. /**
  34404. * Gets or sets if audio support is enabled
  34405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34406. */
  34407. audioEnabled: boolean;
  34408. /**
  34409. * Gets or sets if audio will be output to headphones
  34410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34411. */
  34412. headphone: boolean;
  34413. }
  34414. }
  34415. /**
  34416. * Defines the sound scene component responsible to manage any sounds
  34417. * in a given scene.
  34418. */
  34419. export class AudioSceneComponent implements ISceneSerializableComponent {
  34420. /**
  34421. * The component name helpfull to identify the component in the list of scene components.
  34422. */
  34423. readonly name: string;
  34424. /**
  34425. * The scene the component belongs to.
  34426. */
  34427. scene: Scene;
  34428. private _audioEnabled;
  34429. /**
  34430. * Gets whether audio is enabled or not.
  34431. * Please use related enable/disable method to switch state.
  34432. */
  34433. readonly audioEnabled: boolean;
  34434. private _headphone;
  34435. /**
  34436. * Gets whether audio is outputing to headphone or not.
  34437. * Please use the according Switch methods to change output.
  34438. */
  34439. readonly headphone: boolean;
  34440. /**
  34441. * Creates a new instance of the component for the given scene
  34442. * @param scene Defines the scene to register the component in
  34443. */
  34444. constructor(scene: Scene);
  34445. /**
  34446. * Registers the component in a given scene
  34447. */
  34448. register(): void;
  34449. /**
  34450. * Rebuilds the elements related to this component in case of
  34451. * context lost for instance.
  34452. */
  34453. rebuild(): void;
  34454. /**
  34455. * Serializes the component data to the specified json object
  34456. * @param serializationObject The object to serialize to
  34457. */
  34458. serialize(serializationObject: any): void;
  34459. /**
  34460. * Adds all the element from the container to the scene
  34461. * @param container the container holding the elements
  34462. */
  34463. addFromContainer(container: AbstractScene): void;
  34464. /**
  34465. * Removes all the elements in the container from the scene
  34466. * @param container contains the elements to remove
  34467. */
  34468. removeFromContainer(container: AbstractScene): void;
  34469. /**
  34470. * Disposes the component and the associated ressources.
  34471. */
  34472. dispose(): void;
  34473. /**
  34474. * Disables audio in the associated scene.
  34475. */
  34476. disableAudio(): void;
  34477. /**
  34478. * Enables audio in the associated scene.
  34479. */
  34480. enableAudio(): void;
  34481. /**
  34482. * Switch audio to headphone output.
  34483. */
  34484. switchAudioModeForHeadphones(): void;
  34485. /**
  34486. * Switch audio to normal speakers.
  34487. */
  34488. switchAudioModeForNormalSpeakers(): void;
  34489. private _afterRender;
  34490. }
  34491. }
  34492. declare module "babylonjs/Audio/weightedsound" {
  34493. import { Sound } from "babylonjs/Audio/sound";
  34494. /**
  34495. * Wraps one or more Sound objects and selects one with random weight for playback.
  34496. */
  34497. export class WeightedSound {
  34498. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34499. loop: boolean;
  34500. private _coneInnerAngle;
  34501. private _coneOuterAngle;
  34502. private _volume;
  34503. /** A Sound is currently playing. */
  34504. isPlaying: boolean;
  34505. /** A Sound is currently paused. */
  34506. isPaused: boolean;
  34507. private _sounds;
  34508. private _weights;
  34509. private _currentIndex?;
  34510. /**
  34511. * Creates a new WeightedSound from the list of sounds given.
  34512. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34513. * @param sounds Array of Sounds that will be selected from.
  34514. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34515. */
  34516. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34517. /**
  34518. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34519. */
  34520. /**
  34521. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34522. */
  34523. directionalConeInnerAngle: number;
  34524. /**
  34525. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34526. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34527. */
  34528. /**
  34529. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34530. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34531. */
  34532. directionalConeOuterAngle: number;
  34533. /**
  34534. * Playback volume.
  34535. */
  34536. /**
  34537. * Playback volume.
  34538. */
  34539. volume: number;
  34540. private _onended;
  34541. /**
  34542. * Suspend playback
  34543. */
  34544. pause(): void;
  34545. /**
  34546. * Stop playback
  34547. */
  34548. stop(): void;
  34549. /**
  34550. * Start playback.
  34551. * @param startOffset Position the clip head at a specific time in seconds.
  34552. */
  34553. play(startOffset?: number): void;
  34554. }
  34555. }
  34556. declare module "babylonjs/Audio/index" {
  34557. export * from "babylonjs/Audio/analyser";
  34558. export * from "babylonjs/Audio/audioEngine";
  34559. export * from "babylonjs/Audio/audioSceneComponent";
  34560. export * from "babylonjs/Audio/sound";
  34561. export * from "babylonjs/Audio/soundTrack";
  34562. export * from "babylonjs/Audio/weightedsound";
  34563. }
  34564. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34565. import { Behavior } from "babylonjs/Behaviors/behavior";
  34566. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34567. import { BackEase } from "babylonjs/Animations/easing";
  34568. /**
  34569. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34571. */
  34572. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34573. /**
  34574. * Gets the name of the behavior.
  34575. */
  34576. readonly name: string;
  34577. /**
  34578. * The easing function used by animations
  34579. */
  34580. static EasingFunction: BackEase;
  34581. /**
  34582. * The easing mode used by animations
  34583. */
  34584. static EasingMode: number;
  34585. /**
  34586. * The duration of the animation, in milliseconds
  34587. */
  34588. transitionDuration: number;
  34589. /**
  34590. * Length of the distance animated by the transition when lower radius is reached
  34591. */
  34592. lowerRadiusTransitionRange: number;
  34593. /**
  34594. * Length of the distance animated by the transition when upper radius is reached
  34595. */
  34596. upperRadiusTransitionRange: number;
  34597. private _autoTransitionRange;
  34598. /**
  34599. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34600. */
  34601. /**
  34602. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34603. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34604. */
  34605. autoTransitionRange: boolean;
  34606. private _attachedCamera;
  34607. private _onAfterCheckInputsObserver;
  34608. private _onMeshTargetChangedObserver;
  34609. /**
  34610. * Initializes the behavior.
  34611. */
  34612. init(): void;
  34613. /**
  34614. * Attaches the behavior to its arc rotate camera.
  34615. * @param camera Defines the camera to attach the behavior to
  34616. */
  34617. attach(camera: ArcRotateCamera): void;
  34618. /**
  34619. * Detaches the behavior from its current arc rotate camera.
  34620. */
  34621. detach(): void;
  34622. private _radiusIsAnimating;
  34623. private _radiusBounceTransition;
  34624. private _animatables;
  34625. private _cachedWheelPrecision;
  34626. /**
  34627. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34628. * @param radiusLimit The limit to check against.
  34629. * @return Bool to indicate if at limit.
  34630. */
  34631. private _isRadiusAtLimit;
  34632. /**
  34633. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34634. * @param radiusDelta The delta by which to animate to. Can be negative.
  34635. */
  34636. private _applyBoundRadiusAnimation;
  34637. /**
  34638. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34639. */
  34640. protected _clearAnimationLocks(): void;
  34641. /**
  34642. * Stops and removes all animations that have been applied to the camera
  34643. */
  34644. stopAllAnimations(): void;
  34645. }
  34646. }
  34647. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34648. import { Behavior } from "babylonjs/Behaviors/behavior";
  34649. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34650. import { ExponentialEase } from "babylonjs/Animations/easing";
  34651. import { Nullable } from "babylonjs/types";
  34652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34653. import { Vector3 } from "babylonjs/Maths/math";
  34654. /**
  34655. * 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.
  34656. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34657. */
  34658. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34659. /**
  34660. * Gets the name of the behavior.
  34661. */
  34662. readonly name: string;
  34663. private _mode;
  34664. private _radiusScale;
  34665. private _positionScale;
  34666. private _defaultElevation;
  34667. private _elevationReturnTime;
  34668. private _elevationReturnWaitTime;
  34669. private _zoomStopsAnimation;
  34670. private _framingTime;
  34671. /**
  34672. * The easing function used by animations
  34673. */
  34674. static EasingFunction: ExponentialEase;
  34675. /**
  34676. * The easing mode used by animations
  34677. */
  34678. static EasingMode: number;
  34679. /**
  34680. * Sets the current mode used by the behavior
  34681. */
  34682. /**
  34683. * Gets current mode used by the behavior.
  34684. */
  34685. mode: number;
  34686. /**
  34687. * Sets the scale applied to the radius (1 by default)
  34688. */
  34689. /**
  34690. * Gets the scale applied to the radius
  34691. */
  34692. radiusScale: number;
  34693. /**
  34694. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34695. */
  34696. /**
  34697. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34698. */
  34699. positionScale: number;
  34700. /**
  34701. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34702. * behaviour is triggered, in radians.
  34703. */
  34704. /**
  34705. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34706. * behaviour is triggered, in radians.
  34707. */
  34708. defaultElevation: number;
  34709. /**
  34710. * Sets the time (in milliseconds) taken to return to the default beta position.
  34711. * Negative value indicates camera should not return to default.
  34712. */
  34713. /**
  34714. * Gets the time (in milliseconds) taken to return to the default beta position.
  34715. * Negative value indicates camera should not return to default.
  34716. */
  34717. elevationReturnTime: number;
  34718. /**
  34719. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34720. */
  34721. /**
  34722. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34723. */
  34724. elevationReturnWaitTime: number;
  34725. /**
  34726. * Sets the flag that indicates if user zooming should stop animation.
  34727. */
  34728. /**
  34729. * Gets the flag that indicates if user zooming should stop animation.
  34730. */
  34731. zoomStopsAnimation: boolean;
  34732. /**
  34733. * Sets the transition time when framing the mesh, in milliseconds
  34734. */
  34735. /**
  34736. * Gets the transition time when framing the mesh, in milliseconds
  34737. */
  34738. framingTime: number;
  34739. /**
  34740. * Define if the behavior should automatically change the configured
  34741. * camera limits and sensibilities.
  34742. */
  34743. autoCorrectCameraLimitsAndSensibility: boolean;
  34744. private _onPrePointerObservableObserver;
  34745. private _onAfterCheckInputsObserver;
  34746. private _onMeshTargetChangedObserver;
  34747. private _attachedCamera;
  34748. private _isPointerDown;
  34749. private _lastInteractionTime;
  34750. /**
  34751. * Initializes the behavior.
  34752. */
  34753. init(): void;
  34754. /**
  34755. * Attaches the behavior to its arc rotate camera.
  34756. * @param camera Defines the camera to attach the behavior to
  34757. */
  34758. attach(camera: ArcRotateCamera): void;
  34759. /**
  34760. * Detaches the behavior from its current arc rotate camera.
  34761. */
  34762. detach(): void;
  34763. private _animatables;
  34764. private _betaIsAnimating;
  34765. private _betaTransition;
  34766. private _radiusTransition;
  34767. private _vectorTransition;
  34768. /**
  34769. * Targets the given mesh and updates zoom level accordingly.
  34770. * @param mesh The mesh to target.
  34771. * @param radius Optional. If a cached radius position already exists, overrides default.
  34772. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34773. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34774. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34775. */
  34776. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34777. /**
  34778. * Targets the given mesh with its children and updates zoom level accordingly.
  34779. * @param mesh The mesh to target.
  34780. * @param radius Optional. If a cached radius position already exists, overrides default.
  34781. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34782. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34783. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34784. */
  34785. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34786. /**
  34787. * Targets the given meshes with their children and updates zoom level accordingly.
  34788. * @param meshes The mesh to target.
  34789. * @param radius Optional. If a cached radius position already exists, overrides default.
  34790. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34791. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34792. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34793. */
  34794. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34795. /**
  34796. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34797. * @param minimumWorld Determines the smaller position of the bounding box extend
  34798. * @param maximumWorld Determines the bigger position of the bounding box extend
  34799. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34800. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34801. */
  34802. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34803. /**
  34804. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34805. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34806. * frustum width.
  34807. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34808. * to fully enclose the mesh in the viewing frustum.
  34809. */
  34810. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34811. /**
  34812. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34813. * is automatically returned to its default position (expected to be above ground plane).
  34814. */
  34815. private _maintainCameraAboveGround;
  34816. /**
  34817. * Returns the frustum slope based on the canvas ratio and camera FOV
  34818. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34819. */
  34820. private _getFrustumSlope;
  34821. /**
  34822. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34823. */
  34824. private _clearAnimationLocks;
  34825. /**
  34826. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34827. */
  34828. private _applyUserInteraction;
  34829. /**
  34830. * Stops and removes all animations that have been applied to the camera
  34831. */
  34832. stopAllAnimations(): void;
  34833. /**
  34834. * Gets a value indicating if the user is moving the camera
  34835. */
  34836. readonly isUserIsMoving: boolean;
  34837. /**
  34838. * The camera can move all the way towards the mesh.
  34839. */
  34840. static IgnoreBoundsSizeMode: number;
  34841. /**
  34842. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34843. */
  34844. static FitFrustumSidesMode: number;
  34845. }
  34846. }
  34847. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34848. import { Nullable } from "babylonjs/types";
  34849. import { Camera } from "babylonjs/Cameras/camera";
  34850. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34851. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34852. /**
  34853. * Base class for Camera Pointer Inputs.
  34854. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34855. * for example usage.
  34856. */
  34857. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34858. /**
  34859. * Defines the camera the input is attached to.
  34860. */
  34861. abstract camera: Camera;
  34862. /**
  34863. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34864. */
  34865. protected _altKey: boolean;
  34866. protected _ctrlKey: boolean;
  34867. protected _metaKey: boolean;
  34868. protected _shiftKey: boolean;
  34869. /**
  34870. * Which mouse buttons were pressed at time of last mouse event.
  34871. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34872. */
  34873. protected _buttonsPressed: number;
  34874. /**
  34875. * Defines the buttons associated with the input to handle camera move.
  34876. */
  34877. buttons: number[];
  34878. /**
  34879. * Attach the input controls to a specific dom element to get the input from.
  34880. * @param element Defines the element the controls should be listened from
  34881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34882. */
  34883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34884. /**
  34885. * Detach the current controls from the specified dom element.
  34886. * @param element Defines the element to stop listening the inputs from
  34887. */
  34888. detachControl(element: Nullable<HTMLElement>): void;
  34889. /**
  34890. * Gets the class name of the current input.
  34891. * @returns the class name
  34892. */
  34893. getClassName(): string;
  34894. /**
  34895. * Get the friendly name associated with the input class.
  34896. * @returns the input friendly name
  34897. */
  34898. getSimpleName(): string;
  34899. /**
  34900. * Called on pointer POINTERDOUBLETAP event.
  34901. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34902. */
  34903. protected onDoubleTap(type: string): void;
  34904. /**
  34905. * Called on pointer POINTERMOVE event if only a single touch is active.
  34906. * Override this method to provide functionality.
  34907. */
  34908. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34909. /**
  34910. * Called on pointer POINTERMOVE event if multiple touches are active.
  34911. * Override this method to provide functionality.
  34912. */
  34913. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34914. /**
  34915. * Called on JS contextmenu event.
  34916. * Override this method to provide functionality.
  34917. */
  34918. protected onContextMenu(evt: PointerEvent): void;
  34919. /**
  34920. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34921. * press.
  34922. * Override this method to provide functionality.
  34923. */
  34924. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34925. /**
  34926. * Called each time a new POINTERUP event occurs. Ie, for each button
  34927. * release.
  34928. * Override this method to provide functionality.
  34929. */
  34930. protected onButtonUp(evt: PointerEvent): void;
  34931. /**
  34932. * Called when window becomes inactive.
  34933. * Override this method to provide functionality.
  34934. */
  34935. protected onLostFocus(): void;
  34936. private _pointerInput;
  34937. private _observer;
  34938. private _onLostFocus;
  34939. }
  34940. }
  34941. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34942. import { Nullable } from "babylonjs/types";
  34943. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34944. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34945. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34946. /**
  34947. * Manage the pointers inputs to control an arc rotate camera.
  34948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34949. */
  34950. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34951. /**
  34952. * Defines the camera the input is attached to.
  34953. */
  34954. camera: ArcRotateCamera;
  34955. /**
  34956. * Gets the class name of the current input.
  34957. * @returns the class name
  34958. */
  34959. getClassName(): string;
  34960. /**
  34961. * Defines the buttons associated with the input to handle camera move.
  34962. */
  34963. buttons: number[];
  34964. /**
  34965. * Defines the pointer angular sensibility along the X axis or how fast is
  34966. * the camera rotating.
  34967. */
  34968. angularSensibilityX: number;
  34969. /**
  34970. * Defines the pointer angular sensibility along the Y axis or how fast is
  34971. * the camera rotating.
  34972. */
  34973. angularSensibilityY: number;
  34974. /**
  34975. * Defines the pointer pinch precision or how fast is the camera zooming.
  34976. */
  34977. pinchPrecision: number;
  34978. /**
  34979. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34980. * from 0.
  34981. * It defines the percentage of current camera.radius to use as delta when
  34982. * pinch zoom is used.
  34983. */
  34984. pinchDeltaPercentage: number;
  34985. /**
  34986. * Defines the pointer panning sensibility or how fast is the camera moving.
  34987. */
  34988. panningSensibility: number;
  34989. /**
  34990. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34991. */
  34992. multiTouchPanning: boolean;
  34993. /**
  34994. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34995. * zoom (pinch) through multitouch.
  34996. */
  34997. multiTouchPanAndZoom: boolean;
  34998. /**
  34999. * Revers pinch action direction.
  35000. */
  35001. pinchInwards: boolean;
  35002. private _isPanClick;
  35003. private _twoFingerActivityCount;
  35004. private _isPinching;
  35005. /**
  35006. * Called on pointer POINTERMOVE event if only a single touch is active.
  35007. */
  35008. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35009. /**
  35010. * Called on pointer POINTERDOUBLETAP event.
  35011. */
  35012. protected onDoubleTap(type: string): void;
  35013. /**
  35014. * Called on pointer POINTERMOVE event if multiple touches are active.
  35015. */
  35016. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35017. /**
  35018. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35019. * press.
  35020. */
  35021. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  35022. /**
  35023. * Called each time a new POINTERUP event occurs. Ie, for each button
  35024. * release.
  35025. */
  35026. protected onButtonUp(evt: PointerEvent): void;
  35027. /**
  35028. * Called when window becomes inactive.
  35029. */
  35030. protected onLostFocus(): void;
  35031. }
  35032. }
  35033. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35034. import { Nullable } from "babylonjs/types";
  35035. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35036. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35037. /**
  35038. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35040. */
  35041. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35042. /**
  35043. * Defines the camera the input is attached to.
  35044. */
  35045. camera: ArcRotateCamera;
  35046. /**
  35047. * Defines the list of key codes associated with the up action (increase alpha)
  35048. */
  35049. keysUp: number[];
  35050. /**
  35051. * Defines the list of key codes associated with the down action (decrease alpha)
  35052. */
  35053. keysDown: number[];
  35054. /**
  35055. * Defines the list of key codes associated with the left action (increase beta)
  35056. */
  35057. keysLeft: number[];
  35058. /**
  35059. * Defines the list of key codes associated with the right action (decrease beta)
  35060. */
  35061. keysRight: number[];
  35062. /**
  35063. * Defines the list of key codes associated with the reset action.
  35064. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35065. */
  35066. keysReset: number[];
  35067. /**
  35068. * Defines the panning sensibility of the inputs.
  35069. * (How fast is the camera paning)
  35070. */
  35071. panningSensibility: number;
  35072. /**
  35073. * Defines the zooming sensibility of the inputs.
  35074. * (How fast is the camera zooming)
  35075. */
  35076. zoomingSensibility: number;
  35077. /**
  35078. * Defines wether maintaining the alt key down switch the movement mode from
  35079. * orientation to zoom.
  35080. */
  35081. useAltToZoom: boolean;
  35082. /**
  35083. * Rotation speed of the camera
  35084. */
  35085. angularSpeed: number;
  35086. private _keys;
  35087. private _ctrlPressed;
  35088. private _altPressed;
  35089. private _onCanvasBlurObserver;
  35090. private _onKeyboardObserver;
  35091. private _engine;
  35092. private _scene;
  35093. /**
  35094. * Attach the input controls to a specific dom element to get the input from.
  35095. * @param element Defines the element the controls should be listened from
  35096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35097. */
  35098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35099. /**
  35100. * Detach the current controls from the specified dom element.
  35101. * @param element Defines the element to stop listening the inputs from
  35102. */
  35103. detachControl(element: Nullable<HTMLElement>): void;
  35104. /**
  35105. * Update the current camera state depending on the inputs that have been used this frame.
  35106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35107. */
  35108. checkInputs(): void;
  35109. /**
  35110. * Gets the class name of the current intput.
  35111. * @returns the class name
  35112. */
  35113. getClassName(): string;
  35114. /**
  35115. * Get the friendly name associated with the input class.
  35116. * @returns the input friendly name
  35117. */
  35118. getSimpleName(): string;
  35119. }
  35120. }
  35121. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35122. import { Nullable } from "babylonjs/types";
  35123. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35124. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35125. /**
  35126. * Manage the mouse wheel inputs to control an arc rotate camera.
  35127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35128. */
  35129. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35130. /**
  35131. * Defines the camera the input is attached to.
  35132. */
  35133. camera: ArcRotateCamera;
  35134. /**
  35135. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35136. */
  35137. wheelPrecision: number;
  35138. /**
  35139. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35140. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35141. */
  35142. wheelDeltaPercentage: number;
  35143. private _wheel;
  35144. private _observer;
  35145. /**
  35146. * Attach the input controls to a specific dom element to get the input from.
  35147. * @param element Defines the element the controls should be listened from
  35148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35149. */
  35150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35151. /**
  35152. * Detach the current controls from the specified dom element.
  35153. * @param element Defines the element to stop listening the inputs from
  35154. */
  35155. detachControl(element: Nullable<HTMLElement>): void;
  35156. /**
  35157. * Gets the class name of the current intput.
  35158. * @returns the class name
  35159. */
  35160. getClassName(): string;
  35161. /**
  35162. * Get the friendly name associated with the input class.
  35163. * @returns the input friendly name
  35164. */
  35165. getSimpleName(): string;
  35166. }
  35167. }
  35168. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35169. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35170. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35171. /**
  35172. * Default Inputs manager for the ArcRotateCamera.
  35173. * It groups all the default supported inputs for ease of use.
  35174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35175. */
  35176. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35177. /**
  35178. * Instantiates a new ArcRotateCameraInputsManager.
  35179. * @param camera Defines the camera the inputs belong to
  35180. */
  35181. constructor(camera: ArcRotateCamera);
  35182. /**
  35183. * Add mouse wheel input support to the input manager.
  35184. * @returns the current input manager
  35185. */
  35186. addMouseWheel(): ArcRotateCameraInputsManager;
  35187. /**
  35188. * Add pointers input support to the input manager.
  35189. * @returns the current input manager
  35190. */
  35191. addPointers(): ArcRotateCameraInputsManager;
  35192. /**
  35193. * Add keyboard input support to the input manager.
  35194. * @returns the current input manager
  35195. */
  35196. addKeyboard(): ArcRotateCameraInputsManager;
  35197. }
  35198. }
  35199. declare module "babylonjs/Cameras/arcRotateCamera" {
  35200. import { Observable } from "babylonjs/Misc/observable";
  35201. import { Nullable } from "babylonjs/types";
  35202. import { Scene } from "babylonjs/scene";
  35203. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35205. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35206. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35207. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35208. import { Camera } from "babylonjs/Cameras/camera";
  35209. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35210. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35211. import { Collider } from "babylonjs/Collisions/collider";
  35212. /**
  35213. * This represents an orbital type of camera.
  35214. *
  35215. * 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.
  35216. * 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.
  35217. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35218. */
  35219. export class ArcRotateCamera extends TargetCamera {
  35220. /**
  35221. * Defines the rotation angle of the camera along the longitudinal axis.
  35222. */
  35223. alpha: number;
  35224. /**
  35225. * Defines the rotation angle of the camera along the latitudinal axis.
  35226. */
  35227. beta: number;
  35228. /**
  35229. * Defines the radius of the camera from it s target point.
  35230. */
  35231. radius: number;
  35232. protected _target: Vector3;
  35233. protected _targetHost: Nullable<AbstractMesh>;
  35234. /**
  35235. * Defines the target point of the camera.
  35236. * The camera looks towards it form the radius distance.
  35237. */
  35238. target: Vector3;
  35239. /**
  35240. * Define the current local position of the camera in the scene
  35241. */
  35242. position: Vector3;
  35243. /**
  35244. * Current inertia value on the longitudinal axis.
  35245. * The bigger this number the longer it will take for the camera to stop.
  35246. */
  35247. inertialAlphaOffset: number;
  35248. /**
  35249. * Current inertia value on the latitudinal axis.
  35250. * The bigger this number the longer it will take for the camera to stop.
  35251. */
  35252. inertialBetaOffset: number;
  35253. /**
  35254. * Current inertia value on the radius axis.
  35255. * The bigger this number the longer it will take for the camera to stop.
  35256. */
  35257. inertialRadiusOffset: number;
  35258. /**
  35259. * Minimum allowed angle on the longitudinal axis.
  35260. * This can help limiting how the Camera is able to move in the scene.
  35261. */
  35262. lowerAlphaLimit: Nullable<number>;
  35263. /**
  35264. * Maximum allowed angle on the longitudinal axis.
  35265. * This can help limiting how the Camera is able to move in the scene.
  35266. */
  35267. upperAlphaLimit: Nullable<number>;
  35268. /**
  35269. * Minimum allowed angle on the latitudinal axis.
  35270. * This can help limiting how the Camera is able to move in the scene.
  35271. */
  35272. lowerBetaLimit: number;
  35273. /**
  35274. * Maximum allowed angle on the latitudinal axis.
  35275. * This can help limiting how the Camera is able to move in the scene.
  35276. */
  35277. upperBetaLimit: number;
  35278. /**
  35279. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35280. * This can help limiting how the Camera is able to move in the scene.
  35281. */
  35282. lowerRadiusLimit: Nullable<number>;
  35283. /**
  35284. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35285. * This can help limiting how the Camera is able to move in the scene.
  35286. */
  35287. upperRadiusLimit: Nullable<number>;
  35288. /**
  35289. * Defines the current inertia value used during panning of the camera along the X axis.
  35290. */
  35291. inertialPanningX: number;
  35292. /**
  35293. * Defines the current inertia value used during panning of the camera along the Y axis.
  35294. */
  35295. inertialPanningY: number;
  35296. /**
  35297. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35298. * Basically if your fingers moves away from more than this distance you will be considered
  35299. * in pinch mode.
  35300. */
  35301. pinchToPanMaxDistance: number;
  35302. /**
  35303. * Defines the maximum distance the camera can pan.
  35304. * This could help keeping the cammera always in your scene.
  35305. */
  35306. panningDistanceLimit: Nullable<number>;
  35307. /**
  35308. * Defines the target of the camera before paning.
  35309. */
  35310. panningOriginTarget: Vector3;
  35311. /**
  35312. * Defines the value of the inertia used during panning.
  35313. * 0 would mean stop inertia and one would mean no decelleration at all.
  35314. */
  35315. panningInertia: number;
  35316. /**
  35317. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35318. */
  35319. angularSensibilityX: number;
  35320. /**
  35321. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35322. */
  35323. angularSensibilityY: number;
  35324. /**
  35325. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35326. */
  35327. pinchPrecision: number;
  35328. /**
  35329. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35330. * It will be used instead of pinchDeltaPrecision if different from 0.
  35331. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35332. */
  35333. pinchDeltaPercentage: number;
  35334. /**
  35335. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35336. */
  35337. panningSensibility: number;
  35338. /**
  35339. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35340. */
  35341. keysUp: number[];
  35342. /**
  35343. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35344. */
  35345. keysDown: number[];
  35346. /**
  35347. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35348. */
  35349. keysLeft: number[];
  35350. /**
  35351. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35352. */
  35353. keysRight: number[];
  35354. /**
  35355. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35356. */
  35357. wheelPrecision: number;
  35358. /**
  35359. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35360. * It will be used instead of pinchDeltaPrecision if different from 0.
  35361. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35362. */
  35363. wheelDeltaPercentage: number;
  35364. /**
  35365. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35366. */
  35367. zoomOnFactor: number;
  35368. /**
  35369. * Defines a screen offset for the camera position.
  35370. */
  35371. targetScreenOffset: Vector2;
  35372. /**
  35373. * Allows the camera to be completely reversed.
  35374. * If false the camera can not arrive upside down.
  35375. */
  35376. allowUpsideDown: boolean;
  35377. /**
  35378. * Define if double tap/click is used to restore the previously saved state of the camera.
  35379. */
  35380. useInputToRestoreState: boolean;
  35381. /** @hidden */
  35382. _viewMatrix: Matrix;
  35383. /** @hidden */
  35384. _useCtrlForPanning: boolean;
  35385. /** @hidden */
  35386. _panningMouseButton: number;
  35387. /**
  35388. * Defines the input associated to the camera.
  35389. */
  35390. inputs: ArcRotateCameraInputsManager;
  35391. /** @hidden */
  35392. _reset: () => void;
  35393. /**
  35394. * Defines the allowed panning axis.
  35395. */
  35396. panningAxis: Vector3;
  35397. protected _localDirection: Vector3;
  35398. protected _transformedDirection: Vector3;
  35399. private _bouncingBehavior;
  35400. /**
  35401. * Gets the bouncing behavior of the camera if it has been enabled.
  35402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35403. */
  35404. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35405. /**
  35406. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35407. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35408. */
  35409. useBouncingBehavior: boolean;
  35410. private _framingBehavior;
  35411. /**
  35412. * Gets the framing behavior of the camera if it has been enabled.
  35413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35414. */
  35415. readonly framingBehavior: Nullable<FramingBehavior>;
  35416. /**
  35417. * Defines if the framing behavior of the camera is enabled on the camera.
  35418. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35419. */
  35420. useFramingBehavior: boolean;
  35421. private _autoRotationBehavior;
  35422. /**
  35423. * Gets the auto rotation behavior of the camera if it has been enabled.
  35424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35425. */
  35426. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35427. /**
  35428. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35429. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35430. */
  35431. useAutoRotationBehavior: boolean;
  35432. /**
  35433. * Observable triggered when the mesh target has been changed on the camera.
  35434. */
  35435. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35436. /**
  35437. * Event raised when the camera is colliding with a mesh.
  35438. */
  35439. onCollide: (collidedMesh: AbstractMesh) => void;
  35440. /**
  35441. * Defines whether the camera should check collision with the objects oh the scene.
  35442. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35443. */
  35444. checkCollisions: boolean;
  35445. /**
  35446. * Defines the collision radius of the camera.
  35447. * This simulates a sphere around the camera.
  35448. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35449. */
  35450. collisionRadius: Vector3;
  35451. protected _collider: Collider;
  35452. protected _previousPosition: Vector3;
  35453. protected _collisionVelocity: Vector3;
  35454. protected _newPosition: Vector3;
  35455. protected _previousAlpha: number;
  35456. protected _previousBeta: number;
  35457. protected _previousRadius: number;
  35458. protected _collisionTriggered: boolean;
  35459. protected _targetBoundingCenter: Nullable<Vector3>;
  35460. private _computationVector;
  35461. private _tempAxisVector;
  35462. private _tempAxisRotationMatrix;
  35463. /**
  35464. * Instantiates a new ArcRotateCamera in a given scene
  35465. * @param name Defines the name of the camera
  35466. * @param alpha Defines the camera rotation along the logitudinal axis
  35467. * @param beta Defines the camera rotation along the latitudinal axis
  35468. * @param radius Defines the camera distance from its target
  35469. * @param target Defines the camera target
  35470. * @param scene Defines the scene the camera belongs to
  35471. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35472. */
  35473. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35474. /** @hidden */
  35475. _initCache(): void;
  35476. /** @hidden */
  35477. _updateCache(ignoreParentClass?: boolean): void;
  35478. protected _getTargetPosition(): Vector3;
  35479. private _storedAlpha;
  35480. private _storedBeta;
  35481. private _storedRadius;
  35482. private _storedTarget;
  35483. /**
  35484. * Stores the current state of the camera (alpha, beta, radius and target)
  35485. * @returns the camera itself
  35486. */
  35487. storeState(): Camera;
  35488. /**
  35489. * @hidden
  35490. * Restored camera state. You must call storeState() first
  35491. */
  35492. _restoreStateValues(): boolean;
  35493. /** @hidden */
  35494. _isSynchronizedViewMatrix(): boolean;
  35495. /**
  35496. * Attached controls to the current camera.
  35497. * @param element Defines the element the controls should be listened from
  35498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35499. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35500. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35501. */
  35502. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35503. /**
  35504. * Detach the current controls from the camera.
  35505. * The camera will stop reacting to inputs.
  35506. * @param element Defines the element to stop listening the inputs from
  35507. */
  35508. detachControl(element: HTMLElement): void;
  35509. /** @hidden */
  35510. _checkInputs(): void;
  35511. protected _checkLimits(): void;
  35512. /**
  35513. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35514. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35515. */
  35516. rebuildAnglesAndRadius(updateView?: boolean): void;
  35517. /**
  35518. * Use a position to define the current camera related information like aplha, beta and radius
  35519. * @param position Defines the position to set the camera at
  35520. */
  35521. setPosition(position: Vector3): void;
  35522. /**
  35523. * Defines the target the camera should look at.
  35524. * This will automatically adapt alpha beta and radius to fit within the new target.
  35525. * @param target Defines the new target as a Vector or a mesh
  35526. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35527. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35528. */
  35529. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35530. /** @hidden */
  35531. _getViewMatrix(): Matrix;
  35532. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35533. /**
  35534. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35535. * @param meshes Defines the mesh to zoom on
  35536. * @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)
  35537. */
  35538. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35539. /**
  35540. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35541. * The target will be changed but the radius
  35542. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35543. * @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)
  35544. */
  35545. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35546. min: Vector3;
  35547. max: Vector3;
  35548. distance: number;
  35549. }, doNotUpdateMaxZ?: boolean): void;
  35550. /**
  35551. * @override
  35552. * Override Camera.createRigCamera
  35553. */
  35554. createRigCamera(name: string, cameraIndex: number): Camera;
  35555. /**
  35556. * @hidden
  35557. * @override
  35558. * Override Camera._updateRigCameras
  35559. */
  35560. _updateRigCameras(): void;
  35561. /**
  35562. * Destroy the camera and release the current resources hold by it.
  35563. */
  35564. dispose(): void;
  35565. /**
  35566. * Gets the current object class name.
  35567. * @return the class name
  35568. */
  35569. getClassName(): string;
  35570. }
  35571. }
  35572. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35573. import { Behavior } from "babylonjs/Behaviors/behavior";
  35574. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35575. /**
  35576. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35578. */
  35579. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35580. /**
  35581. * Gets the name of the behavior.
  35582. */
  35583. readonly name: string;
  35584. private _zoomStopsAnimation;
  35585. private _idleRotationSpeed;
  35586. private _idleRotationWaitTime;
  35587. private _idleRotationSpinupTime;
  35588. /**
  35589. * Sets the flag that indicates if user zooming should stop animation.
  35590. */
  35591. /**
  35592. * Gets the flag that indicates if user zooming should stop animation.
  35593. */
  35594. zoomStopsAnimation: boolean;
  35595. /**
  35596. * Sets the default speed at which the camera rotates around the model.
  35597. */
  35598. /**
  35599. * Gets the default speed at which the camera rotates around the model.
  35600. */
  35601. idleRotationSpeed: number;
  35602. /**
  35603. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35604. */
  35605. /**
  35606. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35607. */
  35608. idleRotationWaitTime: number;
  35609. /**
  35610. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35611. */
  35612. /**
  35613. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35614. */
  35615. idleRotationSpinupTime: number;
  35616. /**
  35617. * Gets a value indicating if the camera is currently rotating because of this behavior
  35618. */
  35619. readonly rotationInProgress: boolean;
  35620. private _onPrePointerObservableObserver;
  35621. private _onAfterCheckInputsObserver;
  35622. private _attachedCamera;
  35623. private _isPointerDown;
  35624. private _lastFrameTime;
  35625. private _lastInteractionTime;
  35626. private _cameraRotationSpeed;
  35627. /**
  35628. * Initializes the behavior.
  35629. */
  35630. init(): void;
  35631. /**
  35632. * Attaches the behavior to its arc rotate camera.
  35633. * @param camera Defines the camera to attach the behavior to
  35634. */
  35635. attach(camera: ArcRotateCamera): void;
  35636. /**
  35637. * Detaches the behavior from its current arc rotate camera.
  35638. */
  35639. detach(): void;
  35640. /**
  35641. * Returns true if user is scrolling.
  35642. * @return true if user is scrolling.
  35643. */
  35644. private _userIsZooming;
  35645. private _lastFrameRadius;
  35646. private _shouldAnimationStopForInteraction;
  35647. /**
  35648. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35649. */
  35650. private _applyUserInteraction;
  35651. private _userIsMoving;
  35652. }
  35653. }
  35654. declare module "babylonjs/Behaviors/Cameras/index" {
  35655. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35656. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35657. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35658. }
  35659. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35660. import { Mesh } from "babylonjs/Meshes/mesh";
  35661. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35662. import { Behavior } from "babylonjs/Behaviors/behavior";
  35663. /**
  35664. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35665. */
  35666. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35667. private ui;
  35668. /**
  35669. * The name of the behavior
  35670. */
  35671. name: string;
  35672. /**
  35673. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35674. */
  35675. distanceAwayFromFace: number;
  35676. /**
  35677. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35678. */
  35679. distanceAwayFromBottomOfFace: number;
  35680. private _faceVectors;
  35681. private _target;
  35682. private _scene;
  35683. private _onRenderObserver;
  35684. private _tmpMatrix;
  35685. private _tmpVector;
  35686. /**
  35687. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35688. * @param ui The transform node that should be attched to the mesh
  35689. */
  35690. constructor(ui: TransformNode);
  35691. /**
  35692. * Initializes the behavior
  35693. */
  35694. init(): void;
  35695. private _closestFace;
  35696. private _zeroVector;
  35697. private _lookAtTmpMatrix;
  35698. private _lookAtToRef;
  35699. /**
  35700. * Attaches the AttachToBoxBehavior to the passed in mesh
  35701. * @param target The mesh that the specified node will be attached to
  35702. */
  35703. attach(target: Mesh): void;
  35704. /**
  35705. * Detaches the behavior from the mesh
  35706. */
  35707. detach(): void;
  35708. }
  35709. }
  35710. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35711. import { Behavior } from "babylonjs/Behaviors/behavior";
  35712. import { Mesh } from "babylonjs/Meshes/mesh";
  35713. /**
  35714. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35715. */
  35716. export class FadeInOutBehavior implements Behavior<Mesh> {
  35717. /**
  35718. * Time in milliseconds to delay before fading in (Default: 0)
  35719. */
  35720. delay: number;
  35721. /**
  35722. * Time in milliseconds for the mesh to fade in (Default: 300)
  35723. */
  35724. fadeInTime: number;
  35725. private _millisecondsPerFrame;
  35726. private _hovered;
  35727. private _hoverValue;
  35728. private _ownerNode;
  35729. /**
  35730. * Instatiates the FadeInOutBehavior
  35731. */
  35732. constructor();
  35733. /**
  35734. * The name of the behavior
  35735. */
  35736. readonly name: string;
  35737. /**
  35738. * Initializes the behavior
  35739. */
  35740. init(): void;
  35741. /**
  35742. * Attaches the fade behavior on the passed in mesh
  35743. * @param ownerNode The mesh that will be faded in/out once attached
  35744. */
  35745. attach(ownerNode: Mesh): void;
  35746. /**
  35747. * Detaches the behavior from the mesh
  35748. */
  35749. detach(): void;
  35750. /**
  35751. * Triggers the mesh to begin fading in or out
  35752. * @param value if the object should fade in or out (true to fade in)
  35753. */
  35754. fadeIn(value: boolean): void;
  35755. private _update;
  35756. private _setAllVisibility;
  35757. }
  35758. }
  35759. declare module "babylonjs/Misc/pivotTools" {
  35760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35761. /**
  35762. * Class containing a set of static utilities functions for managing Pivots
  35763. * @hidden
  35764. */
  35765. export class PivotTools {
  35766. private static _PivotCached;
  35767. private static _OldPivotPoint;
  35768. private static _PivotTranslation;
  35769. private static _PivotTmpVector;
  35770. /** @hidden */
  35771. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35772. /** @hidden */
  35773. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35774. }
  35775. }
  35776. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35777. import { Scene } from "babylonjs/scene";
  35778. import { Vector4, Plane } from "babylonjs/Maths/math";
  35779. import { Mesh } from "babylonjs/Meshes/mesh";
  35780. /**
  35781. * Class containing static functions to help procedurally build meshes
  35782. */
  35783. export class PlaneBuilder {
  35784. /**
  35785. * Creates a plane mesh
  35786. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35787. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35788. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35792. * @param name defines the name of the mesh
  35793. * @param options defines the options used to create the mesh
  35794. * @param scene defines the hosting scene
  35795. * @returns the plane mesh
  35796. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35797. */
  35798. static CreatePlane(name: string, options: {
  35799. size?: number;
  35800. width?: number;
  35801. height?: number;
  35802. sideOrientation?: number;
  35803. frontUVs?: Vector4;
  35804. backUVs?: Vector4;
  35805. updatable?: boolean;
  35806. sourcePlane?: Plane;
  35807. }, scene: Scene): Mesh;
  35808. }
  35809. }
  35810. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35811. import { Behavior } from "babylonjs/Behaviors/behavior";
  35812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35813. import { Observable } from "babylonjs/Misc/observable";
  35814. import { Vector3 } from "babylonjs/Maths/math";
  35815. import { Ray } from "babylonjs/Culling/ray";
  35816. import "babylonjs/Meshes/Builders/planeBuilder";
  35817. /**
  35818. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35819. */
  35820. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35821. private static _AnyMouseID;
  35822. private _attachedNode;
  35823. private _dragPlane;
  35824. private _scene;
  35825. private _pointerObserver;
  35826. private _beforeRenderObserver;
  35827. private static _planeScene;
  35828. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35829. /**
  35830. * 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)
  35831. */
  35832. maxDragAngle: number;
  35833. /**
  35834. * @hidden
  35835. */
  35836. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35837. /**
  35838. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35839. */
  35840. currentDraggingPointerID: number;
  35841. /**
  35842. * The last position where the pointer hit the drag plane in world space
  35843. */
  35844. lastDragPosition: Vector3;
  35845. /**
  35846. * If the behavior is currently in a dragging state
  35847. */
  35848. dragging: boolean;
  35849. /**
  35850. * 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)
  35851. */
  35852. dragDeltaRatio: number;
  35853. /**
  35854. * If the drag plane orientation should be updated during the dragging (Default: true)
  35855. */
  35856. updateDragPlane: boolean;
  35857. private _debugMode;
  35858. private _moving;
  35859. /**
  35860. * Fires each time the attached mesh is dragged with the pointer
  35861. * * delta between last drag position and current drag position in world space
  35862. * * dragDistance along the drag axis
  35863. * * dragPlaneNormal normal of the current drag plane used during the drag
  35864. * * dragPlanePoint in world space where the drag intersects the drag plane
  35865. */
  35866. onDragObservable: Observable<{
  35867. delta: Vector3;
  35868. dragPlanePoint: Vector3;
  35869. dragPlaneNormal: Vector3;
  35870. dragDistance: number;
  35871. pointerId: number;
  35872. }>;
  35873. /**
  35874. * Fires each time a drag begins (eg. mouse down on mesh)
  35875. */
  35876. onDragStartObservable: Observable<{
  35877. dragPlanePoint: Vector3;
  35878. pointerId: number;
  35879. }>;
  35880. /**
  35881. * Fires each time a drag ends (eg. mouse release after drag)
  35882. */
  35883. onDragEndObservable: Observable<{
  35884. dragPlanePoint: Vector3;
  35885. pointerId: number;
  35886. }>;
  35887. /**
  35888. * If the attached mesh should be moved when dragged
  35889. */
  35890. moveAttached: boolean;
  35891. /**
  35892. * If the drag behavior will react to drag events (Default: true)
  35893. */
  35894. enabled: boolean;
  35895. /**
  35896. * If camera controls should be detached during the drag
  35897. */
  35898. detachCameraControls: boolean;
  35899. /**
  35900. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35901. */
  35902. useObjectOrienationForDragging: boolean;
  35903. private _options;
  35904. /**
  35905. * Creates a pointer drag behavior that can be attached to a mesh
  35906. * @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)
  35907. */
  35908. constructor(options?: {
  35909. dragAxis?: Vector3;
  35910. dragPlaneNormal?: Vector3;
  35911. });
  35912. /**
  35913. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35914. */
  35915. validateDrag: (targetPosition: Vector3) => boolean;
  35916. /**
  35917. * The name of the behavior
  35918. */
  35919. readonly name: string;
  35920. /**
  35921. * Initializes the behavior
  35922. */
  35923. init(): void;
  35924. private _tmpVector;
  35925. private _alternatePickedPoint;
  35926. private _worldDragAxis;
  35927. private _targetPosition;
  35928. private _attachedElement;
  35929. /**
  35930. * Attaches the drag behavior the passed in mesh
  35931. * @param ownerNode The mesh that will be dragged around once attached
  35932. */
  35933. attach(ownerNode: AbstractMesh): void;
  35934. /**
  35935. * Force relase the drag action by code.
  35936. */
  35937. releaseDrag(): void;
  35938. private _startDragRay;
  35939. private _lastPointerRay;
  35940. /**
  35941. * Simulates the start of a pointer drag event on the behavior
  35942. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35943. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35944. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35945. */
  35946. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35947. private _startDrag;
  35948. private _dragDelta;
  35949. private _moveDrag;
  35950. private _pickWithRayOnDragPlane;
  35951. private _pointA;
  35952. private _pointB;
  35953. private _pointC;
  35954. private _lineA;
  35955. private _lineB;
  35956. private _localAxis;
  35957. private _lookAt;
  35958. private _updateDragPlanePosition;
  35959. /**
  35960. * Detaches the behavior from the mesh
  35961. */
  35962. detach(): void;
  35963. }
  35964. }
  35965. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35966. import { Mesh } from "babylonjs/Meshes/mesh";
  35967. import { Behavior } from "babylonjs/Behaviors/behavior";
  35968. /**
  35969. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35970. */
  35971. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35972. private _dragBehaviorA;
  35973. private _dragBehaviorB;
  35974. private _startDistance;
  35975. private _initialScale;
  35976. private _targetScale;
  35977. private _ownerNode;
  35978. private _sceneRenderObserver;
  35979. /**
  35980. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35981. */
  35982. constructor();
  35983. /**
  35984. * The name of the behavior
  35985. */
  35986. readonly name: string;
  35987. /**
  35988. * Initializes the behavior
  35989. */
  35990. init(): void;
  35991. private _getCurrentDistance;
  35992. /**
  35993. * Attaches the scale behavior the passed in mesh
  35994. * @param ownerNode The mesh that will be scaled around once attached
  35995. */
  35996. attach(ownerNode: Mesh): void;
  35997. /**
  35998. * Detaches the behavior from the mesh
  35999. */
  36000. detach(): void;
  36001. }
  36002. }
  36003. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36004. import { Behavior } from "babylonjs/Behaviors/behavior";
  36005. import { Mesh } from "babylonjs/Meshes/mesh";
  36006. import { Observable } from "babylonjs/Misc/observable";
  36007. /**
  36008. * 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
  36009. */
  36010. export class SixDofDragBehavior implements Behavior<Mesh> {
  36011. private static _virtualScene;
  36012. private _ownerNode;
  36013. private _sceneRenderObserver;
  36014. private _scene;
  36015. private _targetPosition;
  36016. private _virtualOriginMesh;
  36017. private _virtualDragMesh;
  36018. private _pointerObserver;
  36019. private _moving;
  36020. private _startingOrientation;
  36021. /**
  36022. * 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)
  36023. */
  36024. private zDragFactor;
  36025. /**
  36026. * If the object should rotate to face the drag origin
  36027. */
  36028. rotateDraggedObject: boolean;
  36029. /**
  36030. * If the behavior is currently in a dragging state
  36031. */
  36032. dragging: boolean;
  36033. /**
  36034. * 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)
  36035. */
  36036. dragDeltaRatio: number;
  36037. /**
  36038. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36039. */
  36040. currentDraggingPointerID: number;
  36041. /**
  36042. * If camera controls should be detached during the drag
  36043. */
  36044. detachCameraControls: boolean;
  36045. /**
  36046. * Fires each time a drag starts
  36047. */
  36048. onDragStartObservable: Observable<{}>;
  36049. /**
  36050. * Fires each time a drag ends (eg. mouse release after drag)
  36051. */
  36052. onDragEndObservable: Observable<{}>;
  36053. /**
  36054. * 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
  36055. */
  36056. constructor();
  36057. /**
  36058. * The name of the behavior
  36059. */
  36060. readonly name: string;
  36061. /**
  36062. * Initializes the behavior
  36063. */
  36064. init(): void;
  36065. /**
  36066. * Attaches the scale behavior the passed in mesh
  36067. * @param ownerNode The mesh that will be scaled around once attached
  36068. */
  36069. attach(ownerNode: Mesh): void;
  36070. /**
  36071. * Detaches the behavior from the mesh
  36072. */
  36073. detach(): void;
  36074. }
  36075. }
  36076. declare module "babylonjs/Behaviors/Meshes/index" {
  36077. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36078. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36079. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36080. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36081. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36082. }
  36083. declare module "babylonjs/Behaviors/index" {
  36084. export * from "babylonjs/Behaviors/behavior";
  36085. export * from "babylonjs/Behaviors/Cameras/index";
  36086. export * from "babylonjs/Behaviors/Meshes/index";
  36087. }
  36088. declare module "babylonjs/Bones/boneIKController" {
  36089. import { Bone } from "babylonjs/Bones/bone";
  36090. import { Vector3 } from "babylonjs/Maths/math";
  36091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36092. import { Nullable } from "babylonjs/types";
  36093. /**
  36094. * Class used to apply inverse kinematics to bones
  36095. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36096. */
  36097. export class BoneIKController {
  36098. private static _tmpVecs;
  36099. private static _tmpQuat;
  36100. private static _tmpMats;
  36101. /**
  36102. * Gets or sets the target mesh
  36103. */
  36104. targetMesh: AbstractMesh;
  36105. /** Gets or sets the mesh used as pole */
  36106. poleTargetMesh: AbstractMesh;
  36107. /**
  36108. * Gets or sets the bone used as pole
  36109. */
  36110. poleTargetBone: Nullable<Bone>;
  36111. /**
  36112. * Gets or sets the target position
  36113. */
  36114. targetPosition: Vector3;
  36115. /**
  36116. * Gets or sets the pole target position
  36117. */
  36118. poleTargetPosition: Vector3;
  36119. /**
  36120. * Gets or sets the pole target local offset
  36121. */
  36122. poleTargetLocalOffset: Vector3;
  36123. /**
  36124. * Gets or sets the pole angle
  36125. */
  36126. poleAngle: number;
  36127. /**
  36128. * Gets or sets the mesh associated with the controller
  36129. */
  36130. mesh: AbstractMesh;
  36131. /**
  36132. * 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)
  36133. */
  36134. slerpAmount: number;
  36135. private _bone1Quat;
  36136. private _bone1Mat;
  36137. private _bone2Ang;
  36138. private _bone1;
  36139. private _bone2;
  36140. private _bone1Length;
  36141. private _bone2Length;
  36142. private _maxAngle;
  36143. private _maxReach;
  36144. private _rightHandedSystem;
  36145. private _bendAxis;
  36146. private _slerping;
  36147. private _adjustRoll;
  36148. /**
  36149. * Gets or sets maximum allowed angle
  36150. */
  36151. maxAngle: number;
  36152. /**
  36153. * Creates a new BoneIKController
  36154. * @param mesh defines the mesh to control
  36155. * @param bone defines the bone to control
  36156. * @param options defines options to set up the controller
  36157. */
  36158. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36159. targetMesh?: AbstractMesh;
  36160. poleTargetMesh?: AbstractMesh;
  36161. poleTargetBone?: Bone;
  36162. poleTargetLocalOffset?: Vector3;
  36163. poleAngle?: number;
  36164. bendAxis?: Vector3;
  36165. maxAngle?: number;
  36166. slerpAmount?: number;
  36167. });
  36168. private _setMaxAngle;
  36169. /**
  36170. * Force the controller to update the bones
  36171. */
  36172. update(): void;
  36173. }
  36174. }
  36175. declare module "babylonjs/Bones/boneLookController" {
  36176. import { Vector3, Space } from "babylonjs/Maths/math";
  36177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36178. import { Bone } from "babylonjs/Bones/bone";
  36179. /**
  36180. * Class used to make a bone look toward a point in space
  36181. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36182. */
  36183. export class BoneLookController {
  36184. private static _tmpVecs;
  36185. private static _tmpQuat;
  36186. private static _tmpMats;
  36187. /**
  36188. * The target Vector3 that the bone will look at
  36189. */
  36190. target: Vector3;
  36191. /**
  36192. * The mesh that the bone is attached to
  36193. */
  36194. mesh: AbstractMesh;
  36195. /**
  36196. * The bone that will be looking to the target
  36197. */
  36198. bone: Bone;
  36199. /**
  36200. * The up axis of the coordinate system that is used when the bone is rotated
  36201. */
  36202. upAxis: Vector3;
  36203. /**
  36204. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36205. */
  36206. upAxisSpace: Space;
  36207. /**
  36208. * Used to make an adjustment to the yaw of the bone
  36209. */
  36210. adjustYaw: number;
  36211. /**
  36212. * Used to make an adjustment to the pitch of the bone
  36213. */
  36214. adjustPitch: number;
  36215. /**
  36216. * Used to make an adjustment to the roll of the bone
  36217. */
  36218. adjustRoll: number;
  36219. /**
  36220. * 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)
  36221. */
  36222. slerpAmount: number;
  36223. private _minYaw;
  36224. private _maxYaw;
  36225. private _minPitch;
  36226. private _maxPitch;
  36227. private _minYawSin;
  36228. private _minYawCos;
  36229. private _maxYawSin;
  36230. private _maxYawCos;
  36231. private _midYawConstraint;
  36232. private _minPitchTan;
  36233. private _maxPitchTan;
  36234. private _boneQuat;
  36235. private _slerping;
  36236. private _transformYawPitch;
  36237. private _transformYawPitchInv;
  36238. private _firstFrameSkipped;
  36239. private _yawRange;
  36240. private _fowardAxis;
  36241. /**
  36242. * Gets or sets the minimum yaw angle that the bone can look to
  36243. */
  36244. minYaw: number;
  36245. /**
  36246. * Gets or sets the maximum yaw angle that the bone can look to
  36247. */
  36248. maxYaw: number;
  36249. /**
  36250. * Gets or sets the minimum pitch angle that the bone can look to
  36251. */
  36252. minPitch: number;
  36253. /**
  36254. * Gets or sets the maximum pitch angle that the bone can look to
  36255. */
  36256. maxPitch: number;
  36257. /**
  36258. * Create a BoneLookController
  36259. * @param mesh the mesh that the bone belongs to
  36260. * @param bone the bone that will be looking to the target
  36261. * @param target the target Vector3 to look at
  36262. * @param options optional settings:
  36263. * * maxYaw: the maximum angle the bone will yaw to
  36264. * * minYaw: the minimum angle the bone will yaw to
  36265. * * maxPitch: the maximum angle the bone will pitch to
  36266. * * minPitch: the minimum angle the bone will yaw to
  36267. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36268. * * upAxis: the up axis of the coordinate system
  36269. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36270. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36271. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36272. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36273. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36274. * * adjustRoll: used to make an adjustment to the roll of the bone
  36275. **/
  36276. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36277. maxYaw?: number;
  36278. minYaw?: number;
  36279. maxPitch?: number;
  36280. minPitch?: number;
  36281. slerpAmount?: number;
  36282. upAxis?: Vector3;
  36283. upAxisSpace?: Space;
  36284. yawAxis?: Vector3;
  36285. pitchAxis?: Vector3;
  36286. adjustYaw?: number;
  36287. adjustPitch?: number;
  36288. adjustRoll?: number;
  36289. });
  36290. /**
  36291. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36292. */
  36293. update(): void;
  36294. private _getAngleDiff;
  36295. private _getAngleBetween;
  36296. private _isAngleBetween;
  36297. }
  36298. }
  36299. declare module "babylonjs/Bones/index" {
  36300. export * from "babylonjs/Bones/bone";
  36301. export * from "babylonjs/Bones/boneIKController";
  36302. export * from "babylonjs/Bones/boneLookController";
  36303. export * from "babylonjs/Bones/skeleton";
  36304. }
  36305. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36306. import { Nullable } from "babylonjs/types";
  36307. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36308. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36309. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36310. /**
  36311. * Manage the gamepad inputs to control an arc rotate camera.
  36312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36313. */
  36314. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36315. /**
  36316. * Defines the camera the input is attached to.
  36317. */
  36318. camera: ArcRotateCamera;
  36319. /**
  36320. * Defines the gamepad the input is gathering event from.
  36321. */
  36322. gamepad: Nullable<Gamepad>;
  36323. /**
  36324. * Defines the gamepad rotation sensiblity.
  36325. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36326. */
  36327. gamepadRotationSensibility: number;
  36328. /**
  36329. * Defines the gamepad move sensiblity.
  36330. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36331. */
  36332. gamepadMoveSensibility: number;
  36333. private _onGamepadConnectedObserver;
  36334. private _onGamepadDisconnectedObserver;
  36335. /**
  36336. * Attach the input controls to a specific dom element to get the input from.
  36337. * @param element Defines the element the controls should be listened from
  36338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36339. */
  36340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36341. /**
  36342. * Detach the current controls from the specified dom element.
  36343. * @param element Defines the element to stop listening the inputs from
  36344. */
  36345. detachControl(element: Nullable<HTMLElement>): void;
  36346. /**
  36347. * Update the current camera state depending on the inputs that have been used this frame.
  36348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36349. */
  36350. checkInputs(): void;
  36351. /**
  36352. * Gets the class name of the current intput.
  36353. * @returns the class name
  36354. */
  36355. getClassName(): string;
  36356. /**
  36357. * Get the friendly name associated with the input class.
  36358. * @returns the input friendly name
  36359. */
  36360. getSimpleName(): string;
  36361. }
  36362. }
  36363. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36364. import { Nullable } from "babylonjs/types";
  36365. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36366. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36367. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36368. interface ArcRotateCameraInputsManager {
  36369. /**
  36370. * Add orientation input support to the input manager.
  36371. * @returns the current input manager
  36372. */
  36373. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36374. }
  36375. }
  36376. /**
  36377. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36379. */
  36380. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36381. /**
  36382. * Defines the camera the input is attached to.
  36383. */
  36384. camera: ArcRotateCamera;
  36385. /**
  36386. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36387. */
  36388. alphaCorrection: number;
  36389. /**
  36390. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36391. */
  36392. gammaCorrection: number;
  36393. private _alpha;
  36394. private _gamma;
  36395. private _dirty;
  36396. private _deviceOrientationHandler;
  36397. /**
  36398. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36399. */
  36400. constructor();
  36401. /**
  36402. * Attach the input controls to a specific dom element to get the input from.
  36403. * @param element Defines the element the controls should be listened from
  36404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36405. */
  36406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36407. /** @hidden */
  36408. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36409. /**
  36410. * Update the current camera state depending on the inputs that have been used this frame.
  36411. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36412. */
  36413. checkInputs(): void;
  36414. /**
  36415. * Detach the current controls from the specified dom element.
  36416. * @param element Defines the element to stop listening the inputs from
  36417. */
  36418. detachControl(element: Nullable<HTMLElement>): void;
  36419. /**
  36420. * Gets the class name of the current intput.
  36421. * @returns the class name
  36422. */
  36423. getClassName(): string;
  36424. /**
  36425. * Get the friendly name associated with the input class.
  36426. * @returns the input friendly name
  36427. */
  36428. getSimpleName(): string;
  36429. }
  36430. }
  36431. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36432. import { Nullable } from "babylonjs/types";
  36433. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36434. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36435. /**
  36436. * Listen to mouse events to control the camera.
  36437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36438. */
  36439. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36440. /**
  36441. * Defines the camera the input is attached to.
  36442. */
  36443. camera: FlyCamera;
  36444. /**
  36445. * Defines if touch is enabled. (Default is true.)
  36446. */
  36447. touchEnabled: boolean;
  36448. /**
  36449. * Defines the buttons associated with the input to handle camera rotation.
  36450. */
  36451. buttons: number[];
  36452. /**
  36453. * Assign buttons for Yaw control.
  36454. */
  36455. buttonsYaw: number[];
  36456. /**
  36457. * Assign buttons for Pitch control.
  36458. */
  36459. buttonsPitch: number[];
  36460. /**
  36461. * Assign buttons for Roll control.
  36462. */
  36463. buttonsRoll: number[];
  36464. /**
  36465. * Detect if any button is being pressed while mouse is moved.
  36466. * -1 = Mouse locked.
  36467. * 0 = Left button.
  36468. * 1 = Middle Button.
  36469. * 2 = Right Button.
  36470. */
  36471. activeButton: number;
  36472. /**
  36473. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36474. * Higher values reduce its sensitivity.
  36475. */
  36476. angularSensibility: number;
  36477. private _mousemoveCallback;
  36478. private _observer;
  36479. private _rollObserver;
  36480. private previousPosition;
  36481. private noPreventDefault;
  36482. private element;
  36483. /**
  36484. * Listen to mouse events to control the camera.
  36485. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36487. */
  36488. constructor(touchEnabled?: boolean);
  36489. /**
  36490. * Attach the mouse control to the HTML DOM element.
  36491. * @param element Defines the element that listens to the input events.
  36492. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36493. */
  36494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36495. /**
  36496. * Detach the current controls from the specified dom element.
  36497. * @param element Defines the element to stop listening the inputs from
  36498. */
  36499. detachControl(element: Nullable<HTMLElement>): void;
  36500. /**
  36501. * Gets the class name of the current input.
  36502. * @returns the class name.
  36503. */
  36504. getClassName(): string;
  36505. /**
  36506. * Get the friendly name associated with the input class.
  36507. * @returns the input's friendly name.
  36508. */
  36509. getSimpleName(): string;
  36510. private _pointerInput;
  36511. private _onMouseMove;
  36512. /**
  36513. * Rotate camera by mouse offset.
  36514. */
  36515. private rotateCamera;
  36516. }
  36517. }
  36518. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36519. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36520. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36521. /**
  36522. * Default Inputs manager for the FlyCamera.
  36523. * It groups all the default supported inputs for ease of use.
  36524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36525. */
  36526. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36527. /**
  36528. * Instantiates a new FlyCameraInputsManager.
  36529. * @param camera Defines the camera the inputs belong to.
  36530. */
  36531. constructor(camera: FlyCamera);
  36532. /**
  36533. * Add keyboard input support to the input manager.
  36534. * @returns the new FlyCameraKeyboardMoveInput().
  36535. */
  36536. addKeyboard(): FlyCameraInputsManager;
  36537. /**
  36538. * Add mouse input support to the input manager.
  36539. * @param touchEnabled Enable touch screen support.
  36540. * @returns the new FlyCameraMouseInput().
  36541. */
  36542. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36543. }
  36544. }
  36545. declare module "babylonjs/Cameras/flyCamera" {
  36546. import { Scene } from "babylonjs/scene";
  36547. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36549. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36550. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36551. /**
  36552. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36553. * such as in a 3D Space Shooter or a Flight Simulator.
  36554. */
  36555. export class FlyCamera extends TargetCamera {
  36556. /**
  36557. * Define the collision ellipsoid of the camera.
  36558. * This is helpful for simulating a camera body, like a player's body.
  36559. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36560. */
  36561. ellipsoid: Vector3;
  36562. /**
  36563. * Define an offset for the position of the ellipsoid around the camera.
  36564. * This can be helpful if the camera is attached away from the player's body center,
  36565. * such as at its head.
  36566. */
  36567. ellipsoidOffset: Vector3;
  36568. /**
  36569. * Enable or disable collisions of the camera with the rest of the scene objects.
  36570. */
  36571. checkCollisions: boolean;
  36572. /**
  36573. * Enable or disable gravity on the camera.
  36574. */
  36575. applyGravity: boolean;
  36576. /**
  36577. * Define the current direction the camera is moving to.
  36578. */
  36579. cameraDirection: Vector3;
  36580. /**
  36581. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36582. * This overrides and empties cameraRotation.
  36583. */
  36584. rotationQuaternion: Quaternion;
  36585. /**
  36586. * Track Roll to maintain the wanted Rolling when looking around.
  36587. */
  36588. _trackRoll: number;
  36589. /**
  36590. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36591. */
  36592. rollCorrect: number;
  36593. /**
  36594. * Mimic a banked turn, Rolling the camera when Yawing.
  36595. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36596. */
  36597. bankedTurn: boolean;
  36598. /**
  36599. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36600. */
  36601. bankedTurnLimit: number;
  36602. /**
  36603. * Value of 0 disables the banked Roll.
  36604. * Value of 1 is equal to the Yaw angle in radians.
  36605. */
  36606. bankedTurnMultiplier: number;
  36607. /**
  36608. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36609. */
  36610. inputs: FlyCameraInputsManager;
  36611. /**
  36612. * Gets the input sensibility for mouse input.
  36613. * Higher values reduce sensitivity.
  36614. */
  36615. /**
  36616. * Sets the input sensibility for a mouse input.
  36617. * Higher values reduce sensitivity.
  36618. */
  36619. angularSensibility: number;
  36620. /**
  36621. * Get the keys for camera movement forward.
  36622. */
  36623. /**
  36624. * Set the keys for camera movement forward.
  36625. */
  36626. keysForward: number[];
  36627. /**
  36628. * Get the keys for camera movement backward.
  36629. */
  36630. keysBackward: number[];
  36631. /**
  36632. * Get the keys for camera movement up.
  36633. */
  36634. /**
  36635. * Set the keys for camera movement up.
  36636. */
  36637. keysUp: number[];
  36638. /**
  36639. * Get the keys for camera movement down.
  36640. */
  36641. /**
  36642. * Set the keys for camera movement down.
  36643. */
  36644. keysDown: number[];
  36645. /**
  36646. * Get the keys for camera movement left.
  36647. */
  36648. /**
  36649. * Set the keys for camera movement left.
  36650. */
  36651. keysLeft: number[];
  36652. /**
  36653. * Set the keys for camera movement right.
  36654. */
  36655. /**
  36656. * Set the keys for camera movement right.
  36657. */
  36658. keysRight: number[];
  36659. /**
  36660. * Event raised when the camera collides with a mesh in the scene.
  36661. */
  36662. onCollide: (collidedMesh: AbstractMesh) => void;
  36663. private _collider;
  36664. private _needMoveForGravity;
  36665. private _oldPosition;
  36666. private _diffPosition;
  36667. private _newPosition;
  36668. /** @hidden */
  36669. _localDirection: Vector3;
  36670. /** @hidden */
  36671. _transformedDirection: Vector3;
  36672. /**
  36673. * Instantiates a FlyCamera.
  36674. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36675. * such as in a 3D Space Shooter or a Flight Simulator.
  36676. * @param name Define the name of the camera in the scene.
  36677. * @param position Define the starting position of the camera in the scene.
  36678. * @param scene Define the scene the camera belongs to.
  36679. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36680. */
  36681. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36682. /**
  36683. * Attach a control to the HTML DOM element.
  36684. * @param element Defines the element that listens to the input events.
  36685. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36686. */
  36687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36688. /**
  36689. * Detach a control from the HTML DOM element.
  36690. * The camera will stop reacting to that input.
  36691. * @param element Defines the element that listens to the input events.
  36692. */
  36693. detachControl(element: HTMLElement): void;
  36694. private _collisionMask;
  36695. /**
  36696. * Get the mask that the camera ignores in collision events.
  36697. */
  36698. /**
  36699. * Set the mask that the camera ignores in collision events.
  36700. */
  36701. collisionMask: number;
  36702. /** @hidden */
  36703. _collideWithWorld(displacement: Vector3): void;
  36704. /** @hidden */
  36705. private _onCollisionPositionChange;
  36706. /** @hidden */
  36707. _checkInputs(): void;
  36708. /** @hidden */
  36709. _decideIfNeedsToMove(): boolean;
  36710. /** @hidden */
  36711. _updatePosition(): void;
  36712. /**
  36713. * Restore the Roll to its target value at the rate specified.
  36714. * @param rate - Higher means slower restoring.
  36715. * @hidden
  36716. */
  36717. restoreRoll(rate: number): void;
  36718. /**
  36719. * Destroy the camera and release the current resources held by it.
  36720. */
  36721. dispose(): void;
  36722. /**
  36723. * Get the current object class name.
  36724. * @returns the class name.
  36725. */
  36726. getClassName(): string;
  36727. }
  36728. }
  36729. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36730. import { Nullable } from "babylonjs/types";
  36731. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36732. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36733. /**
  36734. * Listen to keyboard events to control the camera.
  36735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36736. */
  36737. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36738. /**
  36739. * Defines the camera the input is attached to.
  36740. */
  36741. camera: FlyCamera;
  36742. /**
  36743. * The list of keyboard keys used to control the forward move of the camera.
  36744. */
  36745. keysForward: number[];
  36746. /**
  36747. * The list of keyboard keys used to control the backward move of the camera.
  36748. */
  36749. keysBackward: number[];
  36750. /**
  36751. * The list of keyboard keys used to control the forward move of the camera.
  36752. */
  36753. keysUp: number[];
  36754. /**
  36755. * The list of keyboard keys used to control the backward move of the camera.
  36756. */
  36757. keysDown: number[];
  36758. /**
  36759. * The list of keyboard keys used to control the right strafe move of the camera.
  36760. */
  36761. keysRight: number[];
  36762. /**
  36763. * The list of keyboard keys used to control the left strafe move of the camera.
  36764. */
  36765. keysLeft: number[];
  36766. private _keys;
  36767. private _onCanvasBlurObserver;
  36768. private _onKeyboardObserver;
  36769. private _engine;
  36770. private _scene;
  36771. /**
  36772. * Attach the input controls to a specific dom element to get the input from.
  36773. * @param element Defines the element the controls should be listened from
  36774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36775. */
  36776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36777. /**
  36778. * Detach the current controls from the specified dom element.
  36779. * @param element Defines the element to stop listening the inputs from
  36780. */
  36781. detachControl(element: Nullable<HTMLElement>): void;
  36782. /**
  36783. * Gets the class name of the current intput.
  36784. * @returns the class name
  36785. */
  36786. getClassName(): string;
  36787. /** @hidden */
  36788. _onLostFocus(e: FocusEvent): void;
  36789. /**
  36790. * Get the friendly name associated with the input class.
  36791. * @returns the input friendly name
  36792. */
  36793. getSimpleName(): string;
  36794. /**
  36795. * Update the current camera state depending on the inputs that have been used this frame.
  36796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36797. */
  36798. checkInputs(): void;
  36799. }
  36800. }
  36801. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36802. import { Nullable } from "babylonjs/types";
  36803. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36804. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36805. /**
  36806. * Manage the mouse wheel inputs to control a follow camera.
  36807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36808. */
  36809. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36810. /**
  36811. * Defines the camera the input is attached to.
  36812. */
  36813. camera: FollowCamera;
  36814. /**
  36815. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36816. */
  36817. axisControlRadius: boolean;
  36818. /**
  36819. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36820. */
  36821. axisControlHeight: boolean;
  36822. /**
  36823. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36824. */
  36825. axisControlRotation: boolean;
  36826. /**
  36827. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36828. * relation to mouseWheel events.
  36829. */
  36830. wheelPrecision: number;
  36831. /**
  36832. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36833. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36834. */
  36835. wheelDeltaPercentage: number;
  36836. private _wheel;
  36837. private _observer;
  36838. /**
  36839. * Attach the input controls to a specific dom element to get the input from.
  36840. * @param element Defines the element the controls should be listened from
  36841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36842. */
  36843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36844. /**
  36845. * Detach the current controls from the specified dom element.
  36846. * @param element Defines the element to stop listening the inputs from
  36847. */
  36848. detachControl(element: Nullable<HTMLElement>): void;
  36849. /**
  36850. * Gets the class name of the current intput.
  36851. * @returns the class name
  36852. */
  36853. getClassName(): string;
  36854. /**
  36855. * Get the friendly name associated with the input class.
  36856. * @returns the input friendly name
  36857. */
  36858. getSimpleName(): string;
  36859. }
  36860. }
  36861. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36862. import { Nullable } from "babylonjs/types";
  36863. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36864. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36865. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36866. /**
  36867. * Manage the pointers inputs to control an follow camera.
  36868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36869. */
  36870. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36871. /**
  36872. * Defines the camera the input is attached to.
  36873. */
  36874. camera: FollowCamera;
  36875. /**
  36876. * Gets the class name of the current input.
  36877. * @returns the class name
  36878. */
  36879. getClassName(): string;
  36880. /**
  36881. * Defines the pointer angular sensibility along the X axis or how fast is
  36882. * the camera rotating.
  36883. * A negative number will reverse the axis direction.
  36884. */
  36885. angularSensibilityX: number;
  36886. /**
  36887. * Defines the pointer angular sensibility along the Y axis or how fast is
  36888. * the camera rotating.
  36889. * A negative number will reverse the axis direction.
  36890. */
  36891. angularSensibilityY: number;
  36892. /**
  36893. * Defines the pointer pinch precision or how fast is the camera zooming.
  36894. * A negative number will reverse the axis direction.
  36895. */
  36896. pinchPrecision: number;
  36897. /**
  36898. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36899. * from 0.
  36900. * It defines the percentage of current camera.radius to use as delta when
  36901. * pinch zoom is used.
  36902. */
  36903. pinchDeltaPercentage: number;
  36904. /**
  36905. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36906. */
  36907. axisXControlRadius: boolean;
  36908. /**
  36909. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36910. */
  36911. axisXControlHeight: boolean;
  36912. /**
  36913. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36914. */
  36915. axisXControlRotation: boolean;
  36916. /**
  36917. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36918. */
  36919. axisYControlRadius: boolean;
  36920. /**
  36921. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36922. */
  36923. axisYControlHeight: boolean;
  36924. /**
  36925. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36926. */
  36927. axisYControlRotation: boolean;
  36928. /**
  36929. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36930. */
  36931. axisPinchControlRadius: boolean;
  36932. /**
  36933. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36934. */
  36935. axisPinchControlHeight: boolean;
  36936. /**
  36937. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36938. */
  36939. axisPinchControlRotation: boolean;
  36940. /**
  36941. * Log error messages if basic misconfiguration has occurred.
  36942. */
  36943. warningEnable: boolean;
  36944. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36945. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36946. private _warningCounter;
  36947. private _warning;
  36948. }
  36949. }
  36950. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36951. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36952. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36953. /**
  36954. * Default Inputs manager for the FollowCamera.
  36955. * It groups all the default supported inputs for ease of use.
  36956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36957. */
  36958. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36959. /**
  36960. * Instantiates a new FollowCameraInputsManager.
  36961. * @param camera Defines the camera the inputs belong to
  36962. */
  36963. constructor(camera: FollowCamera);
  36964. /**
  36965. * Add keyboard input support to the input manager.
  36966. * @returns the current input manager
  36967. */
  36968. addKeyboard(): FollowCameraInputsManager;
  36969. /**
  36970. * Add mouse wheel input support to the input manager.
  36971. * @returns the current input manager
  36972. */
  36973. addMouseWheel(): FollowCameraInputsManager;
  36974. /**
  36975. * Add pointers input support to the input manager.
  36976. * @returns the current input manager
  36977. */
  36978. addPointers(): FollowCameraInputsManager;
  36979. /**
  36980. * Add orientation input support to the input manager.
  36981. * @returns the current input manager
  36982. */
  36983. addVRDeviceOrientation(): FollowCameraInputsManager;
  36984. }
  36985. }
  36986. declare module "babylonjs/Cameras/followCamera" {
  36987. import { Nullable } from "babylonjs/types";
  36988. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36989. import { Scene } from "babylonjs/scene";
  36990. import { Vector3 } from "babylonjs/Maths/math";
  36991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36992. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36993. /**
  36994. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36995. * an arc rotate version arcFollowCamera are available.
  36996. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36997. */
  36998. export class FollowCamera extends TargetCamera {
  36999. /**
  37000. * Distance the follow camera should follow an object at
  37001. */
  37002. radius: number;
  37003. /**
  37004. * Minimum allowed distance of the camera to the axis of rotation
  37005. * (The camera can not get closer).
  37006. * This can help limiting how the Camera is able to move in the scene.
  37007. */
  37008. lowerRadiusLimit: Nullable<number>;
  37009. /**
  37010. * Maximum allowed distance of the camera to the axis of rotation
  37011. * (The camera can not get further).
  37012. * This can help limiting how the Camera is able to move in the scene.
  37013. */
  37014. upperRadiusLimit: Nullable<number>;
  37015. /**
  37016. * Define a rotation offset between the camera and the object it follows
  37017. */
  37018. rotationOffset: number;
  37019. /**
  37020. * Minimum allowed angle to camera position relative to target object.
  37021. * This can help limiting how the Camera is able to move in the scene.
  37022. */
  37023. lowerRotationOffsetLimit: Nullable<number>;
  37024. /**
  37025. * Maximum allowed angle to camera position relative to target object.
  37026. * This can help limiting how the Camera is able to move in the scene.
  37027. */
  37028. upperRotationOffsetLimit: Nullable<number>;
  37029. /**
  37030. * Define a height offset between the camera and the object it follows.
  37031. * It can help following an object from the top (like a car chaing a plane)
  37032. */
  37033. heightOffset: number;
  37034. /**
  37035. * Minimum allowed height of camera position relative to target object.
  37036. * This can help limiting how the Camera is able to move in the scene.
  37037. */
  37038. lowerHeightOffsetLimit: Nullable<number>;
  37039. /**
  37040. * Maximum allowed height of camera position relative to target object.
  37041. * This can help limiting how the Camera is able to move in the scene.
  37042. */
  37043. upperHeightOffsetLimit: Nullable<number>;
  37044. /**
  37045. * Define how fast the camera can accelerate to follow it s target.
  37046. */
  37047. cameraAcceleration: number;
  37048. /**
  37049. * Define the speed limit of the camera following an object.
  37050. */
  37051. maxCameraSpeed: number;
  37052. /**
  37053. * Define the target of the camera.
  37054. */
  37055. lockedTarget: Nullable<AbstractMesh>;
  37056. /**
  37057. * Defines the input associated with the camera.
  37058. */
  37059. inputs: FollowCameraInputsManager;
  37060. /**
  37061. * Instantiates the follow camera.
  37062. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37063. * @param name Define the name of the camera in the scene
  37064. * @param position Define the position of the camera
  37065. * @param scene Define the scene the camera belong to
  37066. * @param lockedTarget Define the target of the camera
  37067. */
  37068. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37069. private _follow;
  37070. /**
  37071. * Attached controls to the current camera.
  37072. * @param element Defines the element the controls should be listened from
  37073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37074. */
  37075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37076. /**
  37077. * Detach the current controls from the camera.
  37078. * The camera will stop reacting to inputs.
  37079. * @param element Defines the element to stop listening the inputs from
  37080. */
  37081. detachControl(element: HTMLElement): void;
  37082. /** @hidden */
  37083. _checkInputs(): void;
  37084. private _checkLimits;
  37085. /**
  37086. * Gets the camera class name.
  37087. * @returns the class name
  37088. */
  37089. getClassName(): string;
  37090. }
  37091. /**
  37092. * Arc Rotate version of the follow camera.
  37093. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37094. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37095. */
  37096. export class ArcFollowCamera extends TargetCamera {
  37097. /** The longitudinal angle of the camera */
  37098. alpha: number;
  37099. /** The latitudinal angle of the camera */
  37100. beta: number;
  37101. /** The radius of the camera from its target */
  37102. radius: number;
  37103. /** Define the camera target (the messh it should follow) */
  37104. target: Nullable<AbstractMesh>;
  37105. private _cartesianCoordinates;
  37106. /**
  37107. * Instantiates a new ArcFollowCamera
  37108. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37109. * @param name Define the name of the camera
  37110. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37111. * @param beta Define the rotation angle of the camera around the elevation axis
  37112. * @param radius Define the radius of the camera from its target point
  37113. * @param target Define the target of the camera
  37114. * @param scene Define the scene the camera belongs to
  37115. */
  37116. constructor(name: string,
  37117. /** The longitudinal angle of the camera */
  37118. alpha: number,
  37119. /** The latitudinal angle of the camera */
  37120. beta: number,
  37121. /** The radius of the camera from its target */
  37122. radius: number,
  37123. /** Define the camera target (the messh it should follow) */
  37124. target: Nullable<AbstractMesh>, scene: Scene);
  37125. private _follow;
  37126. /** @hidden */
  37127. _checkInputs(): void;
  37128. /**
  37129. * Returns the class name of the object.
  37130. * It is mostly used internally for serialization purposes.
  37131. */
  37132. getClassName(): string;
  37133. }
  37134. }
  37135. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37136. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37137. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37138. import { Nullable } from "babylonjs/types";
  37139. /**
  37140. * Manage the keyboard inputs to control the movement of a follow camera.
  37141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37142. */
  37143. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37144. /**
  37145. * Defines the camera the input is attached to.
  37146. */
  37147. camera: FollowCamera;
  37148. /**
  37149. * Defines the list of key codes associated with the up action (increase heightOffset)
  37150. */
  37151. keysHeightOffsetIncr: number[];
  37152. /**
  37153. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37154. */
  37155. keysHeightOffsetDecr: number[];
  37156. /**
  37157. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37158. */
  37159. keysHeightOffsetModifierAlt: boolean;
  37160. /**
  37161. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37162. */
  37163. keysHeightOffsetModifierCtrl: boolean;
  37164. /**
  37165. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37166. */
  37167. keysHeightOffsetModifierShift: boolean;
  37168. /**
  37169. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37170. */
  37171. keysRotationOffsetIncr: number[];
  37172. /**
  37173. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37174. */
  37175. keysRotationOffsetDecr: number[];
  37176. /**
  37177. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37178. */
  37179. keysRotationOffsetModifierAlt: boolean;
  37180. /**
  37181. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37182. */
  37183. keysRotationOffsetModifierCtrl: boolean;
  37184. /**
  37185. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37186. */
  37187. keysRotationOffsetModifierShift: boolean;
  37188. /**
  37189. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37190. */
  37191. keysRadiusIncr: number[];
  37192. /**
  37193. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37194. */
  37195. keysRadiusDecr: number[];
  37196. /**
  37197. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37198. */
  37199. keysRadiusModifierAlt: boolean;
  37200. /**
  37201. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37202. */
  37203. keysRadiusModifierCtrl: boolean;
  37204. /**
  37205. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37206. */
  37207. keysRadiusModifierShift: boolean;
  37208. /**
  37209. * Defines the rate of change of heightOffset.
  37210. */
  37211. heightSensibility: number;
  37212. /**
  37213. * Defines the rate of change of rotationOffset.
  37214. */
  37215. rotationSensibility: number;
  37216. /**
  37217. * Defines the rate of change of radius.
  37218. */
  37219. radiusSensibility: number;
  37220. private _keys;
  37221. private _ctrlPressed;
  37222. private _altPressed;
  37223. private _shiftPressed;
  37224. private _onCanvasBlurObserver;
  37225. private _onKeyboardObserver;
  37226. private _engine;
  37227. private _scene;
  37228. /**
  37229. * Attach the input controls to a specific dom element to get the input from.
  37230. * @param element Defines the element the controls should be listened from
  37231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37232. */
  37233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37234. /**
  37235. * Detach the current controls from the specified dom element.
  37236. * @param element Defines the element to stop listening the inputs from
  37237. */
  37238. detachControl(element: Nullable<HTMLElement>): void;
  37239. /**
  37240. * Update the current camera state depending on the inputs that have been used this frame.
  37241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37242. */
  37243. checkInputs(): void;
  37244. /**
  37245. * Gets the class name of the current input.
  37246. * @returns the class name
  37247. */
  37248. getClassName(): string;
  37249. /**
  37250. * Get the friendly name associated with the input class.
  37251. * @returns the input friendly name
  37252. */
  37253. getSimpleName(): string;
  37254. /**
  37255. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37256. * allow modification of the heightOffset value.
  37257. */
  37258. private _modifierHeightOffset;
  37259. /**
  37260. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37261. * allow modification of the rotationOffset value.
  37262. */
  37263. private _modifierRotationOffset;
  37264. /**
  37265. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37266. * allow modification of the radius value.
  37267. */
  37268. private _modifierRadius;
  37269. }
  37270. }
  37271. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37272. import { Nullable } from "babylonjs/types";
  37273. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37274. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37275. module "babylonjs/Cameras/freeCameraInputsManager" {
  37276. interface FreeCameraInputsManager {
  37277. /**
  37278. * Add orientation input support to the input manager.
  37279. * @returns the current input manager
  37280. */
  37281. addDeviceOrientation(): FreeCameraInputsManager;
  37282. }
  37283. }
  37284. /**
  37285. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37286. * Screen rotation is taken into account.
  37287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37288. */
  37289. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37290. private _camera;
  37291. private _screenOrientationAngle;
  37292. private _constantTranform;
  37293. private _screenQuaternion;
  37294. private _alpha;
  37295. private _beta;
  37296. private _gamma;
  37297. /**
  37298. * Instantiates a new input
  37299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37300. */
  37301. constructor();
  37302. /**
  37303. * Define the camera controlled by the input.
  37304. */
  37305. camera: FreeCamera;
  37306. /**
  37307. * Attach the input controls to a specific dom element to get the input from.
  37308. * @param element Defines the element the controls should be listened from
  37309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37310. */
  37311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37312. private _orientationChanged;
  37313. private _deviceOrientation;
  37314. /**
  37315. * Detach the current controls from the specified dom element.
  37316. * @param element Defines the element to stop listening the inputs from
  37317. */
  37318. detachControl(element: Nullable<HTMLElement>): void;
  37319. /**
  37320. * Update the current camera state depending on the inputs that have been used this frame.
  37321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37322. */
  37323. checkInputs(): void;
  37324. /**
  37325. * Gets the class name of the current intput.
  37326. * @returns the class name
  37327. */
  37328. getClassName(): string;
  37329. /**
  37330. * Get the friendly name associated with the input class.
  37331. * @returns the input friendly name
  37332. */
  37333. getSimpleName(): string;
  37334. }
  37335. }
  37336. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37337. import { Nullable } from "babylonjs/types";
  37338. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37339. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37340. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37341. /**
  37342. * Manage the gamepad inputs to control a free camera.
  37343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37344. */
  37345. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37346. /**
  37347. * Define the camera the input is attached to.
  37348. */
  37349. camera: FreeCamera;
  37350. /**
  37351. * Define the Gamepad controlling the input
  37352. */
  37353. gamepad: Nullable<Gamepad>;
  37354. /**
  37355. * Defines the gamepad rotation sensiblity.
  37356. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37357. */
  37358. gamepadAngularSensibility: number;
  37359. /**
  37360. * Defines the gamepad move sensiblity.
  37361. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37362. */
  37363. gamepadMoveSensibility: number;
  37364. private _onGamepadConnectedObserver;
  37365. private _onGamepadDisconnectedObserver;
  37366. private _cameraTransform;
  37367. private _deltaTransform;
  37368. private _vector3;
  37369. private _vector2;
  37370. /**
  37371. * Attach the input controls to a specific dom element to get the input from.
  37372. * @param element Defines the element the controls should be listened from
  37373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37374. */
  37375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37376. /**
  37377. * Detach the current controls from the specified dom element.
  37378. * @param element Defines the element to stop listening the inputs from
  37379. */
  37380. detachControl(element: Nullable<HTMLElement>): void;
  37381. /**
  37382. * Update the current camera state depending on the inputs that have been used this frame.
  37383. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37384. */
  37385. checkInputs(): void;
  37386. /**
  37387. * Gets the class name of the current intput.
  37388. * @returns the class name
  37389. */
  37390. getClassName(): string;
  37391. /**
  37392. * Get the friendly name associated with the input class.
  37393. * @returns the input friendly name
  37394. */
  37395. getSimpleName(): string;
  37396. }
  37397. }
  37398. declare module "babylonjs/Misc/virtualJoystick" {
  37399. import { Nullable } from "babylonjs/types";
  37400. import { Vector3 } from "babylonjs/Maths/math";
  37401. /**
  37402. * Defines the potential axis of a Joystick
  37403. */
  37404. export enum JoystickAxis {
  37405. /** X axis */
  37406. X = 0,
  37407. /** Y axis */
  37408. Y = 1,
  37409. /** Z axis */
  37410. Z = 2
  37411. }
  37412. /**
  37413. * Class used to define virtual joystick (used in touch mode)
  37414. */
  37415. export class VirtualJoystick {
  37416. /**
  37417. * Gets or sets a boolean indicating that left and right values must be inverted
  37418. */
  37419. reverseLeftRight: boolean;
  37420. /**
  37421. * Gets or sets a boolean indicating that up and down values must be inverted
  37422. */
  37423. reverseUpDown: boolean;
  37424. /**
  37425. * Gets the offset value for the position (ie. the change of the position value)
  37426. */
  37427. deltaPosition: Vector3;
  37428. /**
  37429. * Gets a boolean indicating if the virtual joystick was pressed
  37430. */
  37431. pressed: boolean;
  37432. /**
  37433. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37434. */
  37435. static Canvas: Nullable<HTMLCanvasElement>;
  37436. private static _globalJoystickIndex;
  37437. private static vjCanvasContext;
  37438. private static vjCanvasWidth;
  37439. private static vjCanvasHeight;
  37440. private static halfWidth;
  37441. private _action;
  37442. private _axisTargetedByLeftAndRight;
  37443. private _axisTargetedByUpAndDown;
  37444. private _joystickSensibility;
  37445. private _inversedSensibility;
  37446. private _joystickPointerID;
  37447. private _joystickColor;
  37448. private _joystickPointerPos;
  37449. private _joystickPreviousPointerPos;
  37450. private _joystickPointerStartPos;
  37451. private _deltaJoystickVector;
  37452. private _leftJoystick;
  37453. private _touches;
  37454. private _onPointerDownHandlerRef;
  37455. private _onPointerMoveHandlerRef;
  37456. private _onPointerUpHandlerRef;
  37457. private _onResize;
  37458. /**
  37459. * Creates a new virtual joystick
  37460. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37461. */
  37462. constructor(leftJoystick?: boolean);
  37463. /**
  37464. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37465. * @param newJoystickSensibility defines the new sensibility
  37466. */
  37467. setJoystickSensibility(newJoystickSensibility: number): void;
  37468. private _onPointerDown;
  37469. private _onPointerMove;
  37470. private _onPointerUp;
  37471. /**
  37472. * Change the color of the virtual joystick
  37473. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37474. */
  37475. setJoystickColor(newColor: string): void;
  37476. /**
  37477. * Defines a callback to call when the joystick is touched
  37478. * @param action defines the callback
  37479. */
  37480. setActionOnTouch(action: () => any): void;
  37481. /**
  37482. * Defines which axis you'd like to control for left & right
  37483. * @param axis defines the axis to use
  37484. */
  37485. setAxisForLeftRight(axis: JoystickAxis): void;
  37486. /**
  37487. * Defines which axis you'd like to control for up & down
  37488. * @param axis defines the axis to use
  37489. */
  37490. setAxisForUpDown(axis: JoystickAxis): void;
  37491. private _drawVirtualJoystick;
  37492. /**
  37493. * Release internal HTML canvas
  37494. */
  37495. releaseCanvas(): void;
  37496. }
  37497. }
  37498. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37499. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37500. import { Nullable } from "babylonjs/types";
  37501. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37502. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37503. module "babylonjs/Cameras/freeCameraInputsManager" {
  37504. interface FreeCameraInputsManager {
  37505. /**
  37506. * Add virtual joystick input support to the input manager.
  37507. * @returns the current input manager
  37508. */
  37509. addVirtualJoystick(): FreeCameraInputsManager;
  37510. }
  37511. }
  37512. /**
  37513. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37515. */
  37516. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37517. /**
  37518. * Defines the camera the input is attached to.
  37519. */
  37520. camera: FreeCamera;
  37521. private _leftjoystick;
  37522. private _rightjoystick;
  37523. /**
  37524. * Gets the left stick of the virtual joystick.
  37525. * @returns The virtual Joystick
  37526. */
  37527. getLeftJoystick(): VirtualJoystick;
  37528. /**
  37529. * Gets the right stick of the virtual joystick.
  37530. * @returns The virtual Joystick
  37531. */
  37532. getRightJoystick(): VirtualJoystick;
  37533. /**
  37534. * Update the current camera state depending on the inputs that have been used this frame.
  37535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37536. */
  37537. checkInputs(): void;
  37538. /**
  37539. * Attach the input controls to a specific dom element to get the input from.
  37540. * @param element Defines the element the controls should be listened from
  37541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37542. */
  37543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37544. /**
  37545. * Detach the current controls from the specified dom element.
  37546. * @param element Defines the element to stop listening the inputs from
  37547. */
  37548. detachControl(element: Nullable<HTMLElement>): void;
  37549. /**
  37550. * Gets the class name of the current intput.
  37551. * @returns the class name
  37552. */
  37553. getClassName(): string;
  37554. /**
  37555. * Get the friendly name associated with the input class.
  37556. * @returns the input friendly name
  37557. */
  37558. getSimpleName(): string;
  37559. }
  37560. }
  37561. declare module "babylonjs/Cameras/Inputs/index" {
  37562. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37563. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37564. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37565. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37566. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37567. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37568. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37569. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37570. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37571. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37572. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37573. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37574. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37575. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37576. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37577. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37578. }
  37579. declare module "babylonjs/Cameras/touchCamera" {
  37580. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37581. import { Scene } from "babylonjs/scene";
  37582. import { Vector3 } from "babylonjs/Maths/math";
  37583. /**
  37584. * This represents a FPS type of camera controlled by touch.
  37585. * This is like a universal camera minus the Gamepad controls.
  37586. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37587. */
  37588. export class TouchCamera extends FreeCamera {
  37589. /**
  37590. * Defines the touch sensibility for rotation.
  37591. * The higher the faster.
  37592. */
  37593. touchAngularSensibility: number;
  37594. /**
  37595. * Defines the touch sensibility for move.
  37596. * The higher the faster.
  37597. */
  37598. touchMoveSensibility: number;
  37599. /**
  37600. * Instantiates a new touch camera.
  37601. * This represents a FPS type of camera controlled by touch.
  37602. * This is like a universal camera minus the Gamepad controls.
  37603. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37604. * @param name Define the name of the camera in the scene
  37605. * @param position Define the start position of the camera in the scene
  37606. * @param scene Define the scene the camera belongs to
  37607. */
  37608. constructor(name: string, position: Vector3, scene: Scene);
  37609. /**
  37610. * Gets the current object class name.
  37611. * @return the class name
  37612. */
  37613. getClassName(): string;
  37614. /** @hidden */
  37615. _setupInputs(): void;
  37616. }
  37617. }
  37618. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37619. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37620. import { Scene } from "babylonjs/scene";
  37621. import { Vector3, Axis } from "babylonjs/Maths/math";
  37622. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37623. /**
  37624. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37625. * being tilted forward or back and left or right.
  37626. */
  37627. export class DeviceOrientationCamera extends FreeCamera {
  37628. private _initialQuaternion;
  37629. private _quaternionCache;
  37630. /**
  37631. * Creates a new device orientation camera
  37632. * @param name The name of the camera
  37633. * @param position The start position camera
  37634. * @param scene The scene the camera belongs to
  37635. */
  37636. constructor(name: string, position: Vector3, scene: Scene);
  37637. /**
  37638. * Gets the current instance class name ("DeviceOrientationCamera").
  37639. * This helps avoiding instanceof at run time.
  37640. * @returns the class name
  37641. */
  37642. getClassName(): string;
  37643. /**
  37644. * @hidden
  37645. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37646. */
  37647. _checkInputs(): void;
  37648. /**
  37649. * Reset the camera to its default orientation on the specified axis only.
  37650. * @param axis The axis to reset
  37651. */
  37652. resetToCurrentRotation(axis?: Axis): void;
  37653. }
  37654. }
  37655. declare module "babylonjs/Cameras/universalCamera" {
  37656. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37657. import { Scene } from "babylonjs/scene";
  37658. import { Vector3 } from "babylonjs/Maths/math";
  37659. /**
  37660. * 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,
  37661. * which still works and will still be found in many Playgrounds.
  37662. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37663. */
  37664. export class UniversalCamera extends TouchCamera {
  37665. /**
  37666. * Defines the gamepad rotation sensiblity.
  37667. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37668. */
  37669. gamepadAngularSensibility: number;
  37670. /**
  37671. * Defines the gamepad move sensiblity.
  37672. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37673. */
  37674. gamepadMoveSensibility: number;
  37675. /**
  37676. * 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,
  37677. * which still works and will still be found in many Playgrounds.
  37678. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37679. * @param name Define the name of the camera in the scene
  37680. * @param position Define the start position of the camera in the scene
  37681. * @param scene Define the scene the camera belongs to
  37682. */
  37683. constructor(name: string, position: Vector3, scene: Scene);
  37684. /**
  37685. * Gets the current object class name.
  37686. * @return the class name
  37687. */
  37688. getClassName(): string;
  37689. }
  37690. }
  37691. declare module "babylonjs/Cameras/gamepadCamera" {
  37692. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37693. import { Scene } from "babylonjs/scene";
  37694. import { Vector3 } from "babylonjs/Maths/math";
  37695. /**
  37696. * This represents a FPS type of camera. This is only here for back compat purpose.
  37697. * Please use the UniversalCamera instead as both are identical.
  37698. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37699. */
  37700. export class GamepadCamera extends UniversalCamera {
  37701. /**
  37702. * Instantiates a new Gamepad Camera
  37703. * This represents a FPS type of camera. This is only here for back compat purpose.
  37704. * Please use the UniversalCamera instead as both are identical.
  37705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37706. * @param name Define the name of the camera in the scene
  37707. * @param position Define the start position of the camera in the scene
  37708. * @param scene Define the scene the camera belongs to
  37709. */
  37710. constructor(name: string, position: Vector3, scene: Scene);
  37711. /**
  37712. * Gets the current object class name.
  37713. * @return the class name
  37714. */
  37715. getClassName(): string;
  37716. }
  37717. }
  37718. declare module "babylonjs/Shaders/pass.fragment" {
  37719. /** @hidden */
  37720. export var passPixelShader: {
  37721. name: string;
  37722. shader: string;
  37723. };
  37724. }
  37725. declare module "babylonjs/Shaders/passCube.fragment" {
  37726. /** @hidden */
  37727. export var passCubePixelShader: {
  37728. name: string;
  37729. shader: string;
  37730. };
  37731. }
  37732. declare module "babylonjs/PostProcesses/passPostProcess" {
  37733. import { Nullable } from "babylonjs/types";
  37734. import { Camera } from "babylonjs/Cameras/camera";
  37735. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37736. import { Engine } from "babylonjs/Engines/engine";
  37737. import "babylonjs/Shaders/pass.fragment";
  37738. import "babylonjs/Shaders/passCube.fragment";
  37739. /**
  37740. * PassPostProcess which produces an output the same as it's input
  37741. */
  37742. export class PassPostProcess extends PostProcess {
  37743. /**
  37744. * Creates the PassPostProcess
  37745. * @param name The name of the effect.
  37746. * @param options The required width/height ratio to downsize to before computing the render pass.
  37747. * @param camera The camera to apply the render pass to.
  37748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37749. * @param engine The engine which the post process will be applied. (default: current engine)
  37750. * @param reusable If the post process can be reused on the same frame. (default: false)
  37751. * @param textureType The type of texture to be used when performing the post processing.
  37752. * @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)
  37753. */
  37754. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37755. }
  37756. /**
  37757. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37758. */
  37759. export class PassCubePostProcess extends PostProcess {
  37760. private _face;
  37761. /**
  37762. * Gets or sets the cube face to display.
  37763. * * 0 is +X
  37764. * * 1 is -X
  37765. * * 2 is +Y
  37766. * * 3 is -Y
  37767. * * 4 is +Z
  37768. * * 5 is -Z
  37769. */
  37770. face: number;
  37771. /**
  37772. * Creates the PassCubePostProcess
  37773. * @param name The name of the effect.
  37774. * @param options The required width/height ratio to downsize to before computing the render pass.
  37775. * @param camera The camera to apply the render pass to.
  37776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37777. * @param engine The engine which the post process will be applied. (default: current engine)
  37778. * @param reusable If the post process can be reused on the same frame. (default: false)
  37779. * @param textureType The type of texture to be used when performing the post processing.
  37780. * @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)
  37781. */
  37782. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37783. }
  37784. }
  37785. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37786. /** @hidden */
  37787. export var anaglyphPixelShader: {
  37788. name: string;
  37789. shader: string;
  37790. };
  37791. }
  37792. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37793. import { Engine } from "babylonjs/Engines/engine";
  37794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37795. import { Camera } from "babylonjs/Cameras/camera";
  37796. import "babylonjs/Shaders/anaglyph.fragment";
  37797. /**
  37798. * Postprocess used to generate anaglyphic rendering
  37799. */
  37800. export class AnaglyphPostProcess extends PostProcess {
  37801. private _passedProcess;
  37802. /**
  37803. * Creates a new AnaglyphPostProcess
  37804. * @param name defines postprocess name
  37805. * @param options defines creation options or target ratio scale
  37806. * @param rigCameras defines cameras using this postprocess
  37807. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37808. * @param engine defines hosting engine
  37809. * @param reusable defines if the postprocess will be reused multiple times per frame
  37810. */
  37811. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37812. }
  37813. }
  37814. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37815. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37816. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37817. import { Scene } from "babylonjs/scene";
  37818. import { Vector3 } from "babylonjs/Maths/math";
  37819. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37820. /**
  37821. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37822. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37823. */
  37824. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37825. /**
  37826. * Creates a new AnaglyphArcRotateCamera
  37827. * @param name defines camera name
  37828. * @param alpha defines alpha angle (in radians)
  37829. * @param beta defines beta angle (in radians)
  37830. * @param radius defines radius
  37831. * @param target defines camera target
  37832. * @param interaxialDistance defines distance between each color axis
  37833. * @param scene defines the hosting scene
  37834. */
  37835. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37836. /**
  37837. * Gets camera class name
  37838. * @returns AnaglyphArcRotateCamera
  37839. */
  37840. getClassName(): string;
  37841. }
  37842. }
  37843. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37844. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37845. import { Scene } from "babylonjs/scene";
  37846. import { Vector3 } from "babylonjs/Maths/math";
  37847. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37848. /**
  37849. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37850. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37851. */
  37852. export class AnaglyphFreeCamera extends FreeCamera {
  37853. /**
  37854. * Creates a new AnaglyphFreeCamera
  37855. * @param name defines camera name
  37856. * @param position defines initial position
  37857. * @param interaxialDistance defines distance between each color axis
  37858. * @param scene defines the hosting scene
  37859. */
  37860. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37861. /**
  37862. * Gets camera class name
  37863. * @returns AnaglyphFreeCamera
  37864. */
  37865. getClassName(): string;
  37866. }
  37867. }
  37868. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37869. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37870. import { Scene } from "babylonjs/scene";
  37871. import { Vector3 } from "babylonjs/Maths/math";
  37872. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37873. /**
  37874. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37875. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37876. */
  37877. export class AnaglyphGamepadCamera extends GamepadCamera {
  37878. /**
  37879. * Creates a new AnaglyphGamepadCamera
  37880. * @param name defines camera name
  37881. * @param position defines initial position
  37882. * @param interaxialDistance defines distance between each color axis
  37883. * @param scene defines the hosting scene
  37884. */
  37885. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37886. /**
  37887. * Gets camera class name
  37888. * @returns AnaglyphGamepadCamera
  37889. */
  37890. getClassName(): string;
  37891. }
  37892. }
  37893. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37894. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37895. import { Scene } from "babylonjs/scene";
  37896. import { Vector3 } from "babylonjs/Maths/math";
  37897. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37898. /**
  37899. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37900. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37901. */
  37902. export class AnaglyphUniversalCamera extends UniversalCamera {
  37903. /**
  37904. * Creates a new AnaglyphUniversalCamera
  37905. * @param name defines camera name
  37906. * @param position defines initial position
  37907. * @param interaxialDistance defines distance between each color axis
  37908. * @param scene defines the hosting scene
  37909. */
  37910. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37911. /**
  37912. * Gets camera class name
  37913. * @returns AnaglyphUniversalCamera
  37914. */
  37915. getClassName(): string;
  37916. }
  37917. }
  37918. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37919. /** @hidden */
  37920. export var stereoscopicInterlacePixelShader: {
  37921. name: string;
  37922. shader: string;
  37923. };
  37924. }
  37925. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37926. import { Camera } from "babylonjs/Cameras/camera";
  37927. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37928. import { Engine } from "babylonjs/Engines/engine";
  37929. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37930. /**
  37931. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37932. */
  37933. export class StereoscopicInterlacePostProcess extends PostProcess {
  37934. private _stepSize;
  37935. private _passedProcess;
  37936. /**
  37937. * Initializes a StereoscopicInterlacePostProcess
  37938. * @param name The name of the effect.
  37939. * @param rigCameras The rig cameras to be appled to the post process
  37940. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37942. * @param engine The engine which the post process will be applied. (default: current engine)
  37943. * @param reusable If the post process can be reused on the same frame. (default: false)
  37944. */
  37945. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37946. }
  37947. }
  37948. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37949. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37950. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37951. import { Scene } from "babylonjs/scene";
  37952. import { Vector3 } from "babylonjs/Maths/math";
  37953. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37954. /**
  37955. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37956. * @see http://doc.babylonjs.com/features/cameras
  37957. */
  37958. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37959. /**
  37960. * Creates a new StereoscopicArcRotateCamera
  37961. * @param name defines camera name
  37962. * @param alpha defines alpha angle (in radians)
  37963. * @param beta defines beta angle (in radians)
  37964. * @param radius defines radius
  37965. * @param target defines camera target
  37966. * @param interaxialDistance defines distance between each color axis
  37967. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37968. * @param scene defines the hosting scene
  37969. */
  37970. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37971. /**
  37972. * Gets camera class name
  37973. * @returns StereoscopicArcRotateCamera
  37974. */
  37975. getClassName(): string;
  37976. }
  37977. }
  37978. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37979. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37980. import { Scene } from "babylonjs/scene";
  37981. import { Vector3 } from "babylonjs/Maths/math";
  37982. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37983. /**
  37984. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37985. * @see http://doc.babylonjs.com/features/cameras
  37986. */
  37987. export class StereoscopicFreeCamera extends FreeCamera {
  37988. /**
  37989. * Creates a new StereoscopicFreeCamera
  37990. * @param name defines camera name
  37991. * @param position defines initial position
  37992. * @param interaxialDistance defines distance between each color axis
  37993. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37994. * @param scene defines the hosting scene
  37995. */
  37996. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37997. /**
  37998. * Gets camera class name
  37999. * @returns StereoscopicFreeCamera
  38000. */
  38001. getClassName(): string;
  38002. }
  38003. }
  38004. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38005. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38006. import { Scene } from "babylonjs/scene";
  38007. import { Vector3 } from "babylonjs/Maths/math";
  38008. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38009. /**
  38010. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38011. * @see http://doc.babylonjs.com/features/cameras
  38012. */
  38013. export class StereoscopicGamepadCamera extends GamepadCamera {
  38014. /**
  38015. * Creates a new StereoscopicGamepadCamera
  38016. * @param name defines camera name
  38017. * @param position defines initial position
  38018. * @param interaxialDistance defines distance between each color axis
  38019. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38020. * @param scene defines the hosting scene
  38021. */
  38022. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38023. /**
  38024. * Gets camera class name
  38025. * @returns StereoscopicGamepadCamera
  38026. */
  38027. getClassName(): string;
  38028. }
  38029. }
  38030. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38031. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38032. import { Scene } from "babylonjs/scene";
  38033. import { Vector3 } from "babylonjs/Maths/math";
  38034. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38035. /**
  38036. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38037. * @see http://doc.babylonjs.com/features/cameras
  38038. */
  38039. export class StereoscopicUniversalCamera extends UniversalCamera {
  38040. /**
  38041. * Creates a new StereoscopicUniversalCamera
  38042. * @param name defines camera name
  38043. * @param position defines initial position
  38044. * @param interaxialDistance defines distance between each color axis
  38045. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38046. * @param scene defines the hosting scene
  38047. */
  38048. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38049. /**
  38050. * Gets camera class name
  38051. * @returns StereoscopicUniversalCamera
  38052. */
  38053. getClassName(): string;
  38054. }
  38055. }
  38056. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38057. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38058. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38059. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38060. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38061. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38062. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38063. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38064. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38065. }
  38066. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38067. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38068. import { Scene } from "babylonjs/scene";
  38069. import { Vector3 } from "babylonjs/Maths/math";
  38070. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38071. /**
  38072. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38073. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38074. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38075. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38076. */
  38077. export class VirtualJoysticksCamera extends FreeCamera {
  38078. /**
  38079. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38080. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38081. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38082. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38083. * @param name Define the name of the camera in the scene
  38084. * @param position Define the start position of the camera in the scene
  38085. * @param scene Define the scene the camera belongs to
  38086. */
  38087. constructor(name: string, position: Vector3, scene: Scene);
  38088. /**
  38089. * Gets the current object class name.
  38090. * @return the class name
  38091. */
  38092. getClassName(): string;
  38093. }
  38094. }
  38095. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38096. import { Matrix } from "babylonjs/Maths/math";
  38097. /**
  38098. * This represents all the required metrics to create a VR camera.
  38099. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38100. */
  38101. export class VRCameraMetrics {
  38102. /**
  38103. * Define the horizontal resolution off the screen.
  38104. */
  38105. hResolution: number;
  38106. /**
  38107. * Define the vertical resolution off the screen.
  38108. */
  38109. vResolution: number;
  38110. /**
  38111. * Define the horizontal screen size.
  38112. */
  38113. hScreenSize: number;
  38114. /**
  38115. * Define the vertical screen size.
  38116. */
  38117. vScreenSize: number;
  38118. /**
  38119. * Define the vertical screen center position.
  38120. */
  38121. vScreenCenter: number;
  38122. /**
  38123. * Define the distance of the eyes to the screen.
  38124. */
  38125. eyeToScreenDistance: number;
  38126. /**
  38127. * Define the distance between both lenses
  38128. */
  38129. lensSeparationDistance: number;
  38130. /**
  38131. * Define the distance between both viewer's eyes.
  38132. */
  38133. interpupillaryDistance: number;
  38134. /**
  38135. * Define the distortion factor of the VR postprocess.
  38136. * Please, touch with care.
  38137. */
  38138. distortionK: number[];
  38139. /**
  38140. * Define the chromatic aberration correction factors for the VR post process.
  38141. */
  38142. chromaAbCorrection: number[];
  38143. /**
  38144. * Define the scale factor of the post process.
  38145. * The smaller the better but the slower.
  38146. */
  38147. postProcessScaleFactor: number;
  38148. /**
  38149. * Define an offset for the lens center.
  38150. */
  38151. lensCenterOffset: number;
  38152. /**
  38153. * Define if the current vr camera should compensate the distortion of the lense or not.
  38154. */
  38155. compensateDistortion: boolean;
  38156. /**
  38157. * Gets the rendering aspect ratio based on the provided resolutions.
  38158. */
  38159. readonly aspectRatio: number;
  38160. /**
  38161. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38162. */
  38163. readonly aspectRatioFov: number;
  38164. /**
  38165. * @hidden
  38166. */
  38167. readonly leftHMatrix: Matrix;
  38168. /**
  38169. * @hidden
  38170. */
  38171. readonly rightHMatrix: Matrix;
  38172. /**
  38173. * @hidden
  38174. */
  38175. readonly leftPreViewMatrix: Matrix;
  38176. /**
  38177. * @hidden
  38178. */
  38179. readonly rightPreViewMatrix: Matrix;
  38180. /**
  38181. * Get the default VRMetrics based on the most generic setup.
  38182. * @returns the default vr metrics
  38183. */
  38184. static GetDefault(): VRCameraMetrics;
  38185. }
  38186. }
  38187. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38188. /** @hidden */
  38189. export var vrDistortionCorrectionPixelShader: {
  38190. name: string;
  38191. shader: string;
  38192. };
  38193. }
  38194. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38195. import { Camera } from "babylonjs/Cameras/camera";
  38196. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38197. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38198. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38199. /**
  38200. * VRDistortionCorrectionPostProcess used for mobile VR
  38201. */
  38202. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38203. private _isRightEye;
  38204. private _distortionFactors;
  38205. private _postProcessScaleFactor;
  38206. private _lensCenterOffset;
  38207. private _scaleIn;
  38208. private _scaleFactor;
  38209. private _lensCenter;
  38210. /**
  38211. * Initializes the VRDistortionCorrectionPostProcess
  38212. * @param name The name of the effect.
  38213. * @param camera The camera to apply the render pass to.
  38214. * @param isRightEye If this is for the right eye distortion
  38215. * @param vrMetrics All the required metrics for the VR camera
  38216. */
  38217. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38218. }
  38219. }
  38220. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38221. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38222. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38223. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38224. import { Scene } from "babylonjs/scene";
  38225. import { Vector3 } from "babylonjs/Maths/math";
  38226. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38227. import "babylonjs/Cameras/RigModes/vrRigMode";
  38228. /**
  38229. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38230. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38231. */
  38232. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38233. /**
  38234. * Creates a new VRDeviceOrientationArcRotateCamera
  38235. * @param name defines camera name
  38236. * @param alpha defines the camera rotation along the logitudinal axis
  38237. * @param beta defines the camera rotation along the latitudinal axis
  38238. * @param radius defines the camera distance from its target
  38239. * @param target defines the camera target
  38240. * @param scene defines the scene the camera belongs to
  38241. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38242. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38243. */
  38244. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38245. /**
  38246. * Gets camera class name
  38247. * @returns VRDeviceOrientationArcRotateCamera
  38248. */
  38249. getClassName(): string;
  38250. }
  38251. }
  38252. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38253. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38254. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38255. import { Scene } from "babylonjs/scene";
  38256. import { Vector3 } from "babylonjs/Maths/math";
  38257. import "babylonjs/Cameras/RigModes/vrRigMode";
  38258. /**
  38259. * Camera used to simulate VR rendering (based on FreeCamera)
  38260. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38261. */
  38262. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38263. /**
  38264. * Creates a new VRDeviceOrientationFreeCamera
  38265. * @param name defines camera name
  38266. * @param position defines the start position of the camera
  38267. * @param scene defines the scene the camera belongs to
  38268. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38269. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38270. */
  38271. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38272. /**
  38273. * Gets camera class name
  38274. * @returns VRDeviceOrientationFreeCamera
  38275. */
  38276. getClassName(): string;
  38277. }
  38278. }
  38279. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38280. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38281. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38282. import { Scene } from "babylonjs/scene";
  38283. import { Vector3 } from "babylonjs/Maths/math";
  38284. /**
  38285. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38286. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38287. */
  38288. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38289. /**
  38290. * Creates a new VRDeviceOrientationGamepadCamera
  38291. * @param name defines camera name
  38292. * @param position defines the start position of the camera
  38293. * @param scene defines the scene the camera belongs to
  38294. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38295. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38296. */
  38297. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38298. /**
  38299. * Gets camera class name
  38300. * @returns VRDeviceOrientationGamepadCamera
  38301. */
  38302. getClassName(): string;
  38303. }
  38304. }
  38305. declare module "babylonjs/Gamepads/xboxGamepad" {
  38306. import { Observable } from "babylonjs/Misc/observable";
  38307. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38308. /**
  38309. * Defines supported buttons for XBox360 compatible gamepads
  38310. */
  38311. export enum Xbox360Button {
  38312. /** A */
  38313. A = 0,
  38314. /** B */
  38315. B = 1,
  38316. /** X */
  38317. X = 2,
  38318. /** Y */
  38319. Y = 3,
  38320. /** Start */
  38321. Start = 4,
  38322. /** Back */
  38323. Back = 5,
  38324. /** Left button */
  38325. LB = 6,
  38326. /** Right button */
  38327. RB = 7,
  38328. /** Left stick */
  38329. LeftStick = 8,
  38330. /** Right stick */
  38331. RightStick = 9
  38332. }
  38333. /** Defines values for XBox360 DPad */
  38334. export enum Xbox360Dpad {
  38335. /** Up */
  38336. Up = 0,
  38337. /** Down */
  38338. Down = 1,
  38339. /** Left */
  38340. Left = 2,
  38341. /** Right */
  38342. Right = 3
  38343. }
  38344. /**
  38345. * Defines a XBox360 gamepad
  38346. */
  38347. export class Xbox360Pad extends Gamepad {
  38348. private _leftTrigger;
  38349. private _rightTrigger;
  38350. private _onlefttriggerchanged;
  38351. private _onrighttriggerchanged;
  38352. private _onbuttondown;
  38353. private _onbuttonup;
  38354. private _ondpaddown;
  38355. private _ondpadup;
  38356. /** Observable raised when a button is pressed */
  38357. onButtonDownObservable: Observable<Xbox360Button>;
  38358. /** Observable raised when a button is released */
  38359. onButtonUpObservable: Observable<Xbox360Button>;
  38360. /** Observable raised when a pad is pressed */
  38361. onPadDownObservable: Observable<Xbox360Dpad>;
  38362. /** Observable raised when a pad is released */
  38363. onPadUpObservable: Observable<Xbox360Dpad>;
  38364. private _buttonA;
  38365. private _buttonB;
  38366. private _buttonX;
  38367. private _buttonY;
  38368. private _buttonBack;
  38369. private _buttonStart;
  38370. private _buttonLB;
  38371. private _buttonRB;
  38372. private _buttonLeftStick;
  38373. private _buttonRightStick;
  38374. private _dPadUp;
  38375. private _dPadDown;
  38376. private _dPadLeft;
  38377. private _dPadRight;
  38378. private _isXboxOnePad;
  38379. /**
  38380. * Creates a new XBox360 gamepad object
  38381. * @param id defines the id of this gamepad
  38382. * @param index defines its index
  38383. * @param gamepad defines the internal HTML gamepad object
  38384. * @param xboxOne defines if it is a XBox One gamepad
  38385. */
  38386. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38387. /**
  38388. * Defines the callback to call when left trigger is pressed
  38389. * @param callback defines the callback to use
  38390. */
  38391. onlefttriggerchanged(callback: (value: number) => void): void;
  38392. /**
  38393. * Defines the callback to call when right trigger is pressed
  38394. * @param callback defines the callback to use
  38395. */
  38396. onrighttriggerchanged(callback: (value: number) => void): void;
  38397. /**
  38398. * Gets the left trigger value
  38399. */
  38400. /**
  38401. * Sets the left trigger value
  38402. */
  38403. leftTrigger: number;
  38404. /**
  38405. * Gets the right trigger value
  38406. */
  38407. /**
  38408. * Sets the right trigger value
  38409. */
  38410. rightTrigger: number;
  38411. /**
  38412. * Defines the callback to call when a button is pressed
  38413. * @param callback defines the callback to use
  38414. */
  38415. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38416. /**
  38417. * Defines the callback to call when a button is released
  38418. * @param callback defines the callback to use
  38419. */
  38420. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38421. /**
  38422. * Defines the callback to call when a pad is pressed
  38423. * @param callback defines the callback to use
  38424. */
  38425. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38426. /**
  38427. * Defines the callback to call when a pad is released
  38428. * @param callback defines the callback to use
  38429. */
  38430. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38431. private _setButtonValue;
  38432. private _setDPadValue;
  38433. /**
  38434. * Gets the value of the `A` button
  38435. */
  38436. /**
  38437. * Sets the value of the `A` button
  38438. */
  38439. buttonA: number;
  38440. /**
  38441. * Gets the value of the `B` button
  38442. */
  38443. /**
  38444. * Sets the value of the `B` button
  38445. */
  38446. buttonB: number;
  38447. /**
  38448. * Gets the value of the `X` button
  38449. */
  38450. /**
  38451. * Sets the value of the `X` button
  38452. */
  38453. buttonX: number;
  38454. /**
  38455. * Gets the value of the `Y` button
  38456. */
  38457. /**
  38458. * Sets the value of the `Y` button
  38459. */
  38460. buttonY: number;
  38461. /**
  38462. * Gets the value of the `Start` button
  38463. */
  38464. /**
  38465. * Sets the value of the `Start` button
  38466. */
  38467. buttonStart: number;
  38468. /**
  38469. * Gets the value of the `Back` button
  38470. */
  38471. /**
  38472. * Sets the value of the `Back` button
  38473. */
  38474. buttonBack: number;
  38475. /**
  38476. * Gets the value of the `Left` button
  38477. */
  38478. /**
  38479. * Sets the value of the `Left` button
  38480. */
  38481. buttonLB: number;
  38482. /**
  38483. * Gets the value of the `Right` button
  38484. */
  38485. /**
  38486. * Sets the value of the `Right` button
  38487. */
  38488. buttonRB: number;
  38489. /**
  38490. * Gets the value of the Left joystick
  38491. */
  38492. /**
  38493. * Sets the value of the Left joystick
  38494. */
  38495. buttonLeftStick: number;
  38496. /**
  38497. * Gets the value of the Right joystick
  38498. */
  38499. /**
  38500. * Sets the value of the Right joystick
  38501. */
  38502. buttonRightStick: number;
  38503. /**
  38504. * Gets the value of D-pad up
  38505. */
  38506. /**
  38507. * Sets the value of D-pad up
  38508. */
  38509. dPadUp: number;
  38510. /**
  38511. * Gets the value of D-pad down
  38512. */
  38513. /**
  38514. * Sets the value of D-pad down
  38515. */
  38516. dPadDown: number;
  38517. /**
  38518. * Gets the value of D-pad left
  38519. */
  38520. /**
  38521. * Sets the value of D-pad left
  38522. */
  38523. dPadLeft: number;
  38524. /**
  38525. * Gets the value of D-pad right
  38526. */
  38527. /**
  38528. * Sets the value of D-pad right
  38529. */
  38530. dPadRight: number;
  38531. /**
  38532. * Force the gamepad to synchronize with device values
  38533. */
  38534. update(): void;
  38535. /**
  38536. * Disposes the gamepad
  38537. */
  38538. dispose(): void;
  38539. }
  38540. }
  38541. declare module "babylonjs/Materials/pushMaterial" {
  38542. import { Nullable } from "babylonjs/types";
  38543. import { Scene } from "babylonjs/scene";
  38544. import { Matrix } from "babylonjs/Maths/math";
  38545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38546. import { Mesh } from "babylonjs/Meshes/mesh";
  38547. import { Material } from "babylonjs/Materials/material";
  38548. import { Effect } from "babylonjs/Materials/effect";
  38549. /**
  38550. * Base class of materials working in push mode in babylon JS
  38551. * @hidden
  38552. */
  38553. export class PushMaterial extends Material {
  38554. protected _activeEffect: Effect;
  38555. protected _normalMatrix: Matrix;
  38556. /**
  38557. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38558. * This means that the material can keep using a previous shader while a new one is being compiled.
  38559. * This is mostly used when shader parallel compilation is supported (true by default)
  38560. */
  38561. allowShaderHotSwapping: boolean;
  38562. constructor(name: string, scene: Scene);
  38563. getEffect(): Effect;
  38564. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38565. /**
  38566. * Binds the given world matrix to the active effect
  38567. *
  38568. * @param world the matrix to bind
  38569. */
  38570. bindOnlyWorldMatrix(world: Matrix): void;
  38571. /**
  38572. * Binds the given normal matrix to the active effect
  38573. *
  38574. * @param normalMatrix the matrix to bind
  38575. */
  38576. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38577. bind(world: Matrix, mesh?: Mesh): void;
  38578. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38579. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38580. }
  38581. }
  38582. declare module "babylonjs/Materials/materialFlags" {
  38583. /**
  38584. * This groups all the flags used to control the materials channel.
  38585. */
  38586. export class MaterialFlags {
  38587. private static _DiffuseTextureEnabled;
  38588. /**
  38589. * Are diffuse textures enabled in the application.
  38590. */
  38591. static DiffuseTextureEnabled: boolean;
  38592. private static _AmbientTextureEnabled;
  38593. /**
  38594. * Are ambient textures enabled in the application.
  38595. */
  38596. static AmbientTextureEnabled: boolean;
  38597. private static _OpacityTextureEnabled;
  38598. /**
  38599. * Are opacity textures enabled in the application.
  38600. */
  38601. static OpacityTextureEnabled: boolean;
  38602. private static _ReflectionTextureEnabled;
  38603. /**
  38604. * Are reflection textures enabled in the application.
  38605. */
  38606. static ReflectionTextureEnabled: boolean;
  38607. private static _EmissiveTextureEnabled;
  38608. /**
  38609. * Are emissive textures enabled in the application.
  38610. */
  38611. static EmissiveTextureEnabled: boolean;
  38612. private static _SpecularTextureEnabled;
  38613. /**
  38614. * Are specular textures enabled in the application.
  38615. */
  38616. static SpecularTextureEnabled: boolean;
  38617. private static _BumpTextureEnabled;
  38618. /**
  38619. * Are bump textures enabled in the application.
  38620. */
  38621. static BumpTextureEnabled: boolean;
  38622. private static _LightmapTextureEnabled;
  38623. /**
  38624. * Are lightmap textures enabled in the application.
  38625. */
  38626. static LightmapTextureEnabled: boolean;
  38627. private static _RefractionTextureEnabled;
  38628. /**
  38629. * Are refraction textures enabled in the application.
  38630. */
  38631. static RefractionTextureEnabled: boolean;
  38632. private static _ColorGradingTextureEnabled;
  38633. /**
  38634. * Are color grading textures enabled in the application.
  38635. */
  38636. static ColorGradingTextureEnabled: boolean;
  38637. private static _FresnelEnabled;
  38638. /**
  38639. * Are fresnels enabled in the application.
  38640. */
  38641. static FresnelEnabled: boolean;
  38642. private static _ClearCoatTextureEnabled;
  38643. /**
  38644. * Are clear coat textures enabled in the application.
  38645. */
  38646. static ClearCoatTextureEnabled: boolean;
  38647. private static _ClearCoatBumpTextureEnabled;
  38648. /**
  38649. * Are clear coat bump textures enabled in the application.
  38650. */
  38651. static ClearCoatBumpTextureEnabled: boolean;
  38652. private static _ClearCoatTintTextureEnabled;
  38653. /**
  38654. * Are clear coat tint textures enabled in the application.
  38655. */
  38656. static ClearCoatTintTextureEnabled: boolean;
  38657. private static _SheenTextureEnabled;
  38658. /**
  38659. * Are sheen textures enabled in the application.
  38660. */
  38661. static SheenTextureEnabled: boolean;
  38662. private static _AnisotropicTextureEnabled;
  38663. /**
  38664. * Are anisotropic textures enabled in the application.
  38665. */
  38666. static AnisotropicTextureEnabled: boolean;
  38667. }
  38668. }
  38669. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38670. /** @hidden */
  38671. export var defaultFragmentDeclaration: {
  38672. name: string;
  38673. shader: string;
  38674. };
  38675. }
  38676. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38677. /** @hidden */
  38678. export var defaultUboDeclaration: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38684. /** @hidden */
  38685. export var lightFragmentDeclaration: {
  38686. name: string;
  38687. shader: string;
  38688. };
  38689. }
  38690. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38691. /** @hidden */
  38692. export var lightUboDeclaration: {
  38693. name: string;
  38694. shader: string;
  38695. };
  38696. }
  38697. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38698. /** @hidden */
  38699. export var lightsFragmentFunctions: {
  38700. name: string;
  38701. shader: string;
  38702. };
  38703. }
  38704. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38705. /** @hidden */
  38706. export var shadowsFragmentFunctions: {
  38707. name: string;
  38708. shader: string;
  38709. };
  38710. }
  38711. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38712. /** @hidden */
  38713. export var fresnelFunction: {
  38714. name: string;
  38715. shader: string;
  38716. };
  38717. }
  38718. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38719. /** @hidden */
  38720. export var reflectionFunction: {
  38721. name: string;
  38722. shader: string;
  38723. };
  38724. }
  38725. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38726. /** @hidden */
  38727. export var bumpFragmentFunctions: {
  38728. name: string;
  38729. shader: string;
  38730. };
  38731. }
  38732. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38733. /** @hidden */
  38734. export var logDepthDeclaration: {
  38735. name: string;
  38736. shader: string;
  38737. };
  38738. }
  38739. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38740. /** @hidden */
  38741. export var bumpFragment: {
  38742. name: string;
  38743. shader: string;
  38744. };
  38745. }
  38746. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38747. /** @hidden */
  38748. export var depthPrePass: {
  38749. name: string;
  38750. shader: string;
  38751. };
  38752. }
  38753. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38754. /** @hidden */
  38755. export var lightFragment: {
  38756. name: string;
  38757. shader: string;
  38758. };
  38759. }
  38760. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38761. /** @hidden */
  38762. export var logDepthFragment: {
  38763. name: string;
  38764. shader: string;
  38765. };
  38766. }
  38767. declare module "babylonjs/Shaders/default.fragment" {
  38768. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38769. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38770. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38771. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38772. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38773. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38774. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38775. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38776. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38777. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38778. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38779. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38780. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38781. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38782. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38783. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38784. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38785. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38786. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38787. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38788. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38789. /** @hidden */
  38790. export var defaultPixelShader: {
  38791. name: string;
  38792. shader: string;
  38793. };
  38794. }
  38795. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38796. /** @hidden */
  38797. export var defaultVertexDeclaration: {
  38798. name: string;
  38799. shader: string;
  38800. };
  38801. }
  38802. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38803. /** @hidden */
  38804. export var bumpVertexDeclaration: {
  38805. name: string;
  38806. shader: string;
  38807. };
  38808. }
  38809. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38810. /** @hidden */
  38811. export var bumpVertex: {
  38812. name: string;
  38813. shader: string;
  38814. };
  38815. }
  38816. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38817. /** @hidden */
  38818. export var fogVertex: {
  38819. name: string;
  38820. shader: string;
  38821. };
  38822. }
  38823. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38824. /** @hidden */
  38825. export var shadowsVertex: {
  38826. name: string;
  38827. shader: string;
  38828. };
  38829. }
  38830. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38831. /** @hidden */
  38832. export var pointCloudVertex: {
  38833. name: string;
  38834. shader: string;
  38835. };
  38836. }
  38837. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38838. /** @hidden */
  38839. export var logDepthVertex: {
  38840. name: string;
  38841. shader: string;
  38842. };
  38843. }
  38844. declare module "babylonjs/Shaders/default.vertex" {
  38845. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38846. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38848. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38849. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38850. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38851. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38852. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38853. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38854. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38855. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38857. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38858. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38859. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38860. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38861. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38862. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38863. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38864. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38865. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38866. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38867. /** @hidden */
  38868. export var defaultVertexShader: {
  38869. name: string;
  38870. shader: string;
  38871. };
  38872. }
  38873. declare module "babylonjs/Materials/standardMaterial" {
  38874. import { SmartArray } from "babylonjs/Misc/smartArray";
  38875. import { IAnimatable } from "babylonjs/Misc/tools";
  38876. import { Nullable } from "babylonjs/types";
  38877. import { Scene } from "babylonjs/scene";
  38878. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38879. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38881. import { Mesh } from "babylonjs/Meshes/mesh";
  38882. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38883. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38884. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38885. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38886. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38888. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38889. import "babylonjs/Shaders/default.fragment";
  38890. import "babylonjs/Shaders/default.vertex";
  38891. /** @hidden */
  38892. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38893. MAINUV1: boolean;
  38894. MAINUV2: boolean;
  38895. DIFFUSE: boolean;
  38896. DIFFUSEDIRECTUV: number;
  38897. AMBIENT: boolean;
  38898. AMBIENTDIRECTUV: number;
  38899. OPACITY: boolean;
  38900. OPACITYDIRECTUV: number;
  38901. OPACITYRGB: boolean;
  38902. REFLECTION: boolean;
  38903. EMISSIVE: boolean;
  38904. EMISSIVEDIRECTUV: number;
  38905. SPECULAR: boolean;
  38906. SPECULARDIRECTUV: number;
  38907. BUMP: boolean;
  38908. BUMPDIRECTUV: number;
  38909. PARALLAX: boolean;
  38910. PARALLAXOCCLUSION: boolean;
  38911. SPECULAROVERALPHA: boolean;
  38912. CLIPPLANE: boolean;
  38913. CLIPPLANE2: boolean;
  38914. CLIPPLANE3: boolean;
  38915. CLIPPLANE4: boolean;
  38916. ALPHATEST: boolean;
  38917. DEPTHPREPASS: boolean;
  38918. ALPHAFROMDIFFUSE: boolean;
  38919. POINTSIZE: boolean;
  38920. FOG: boolean;
  38921. SPECULARTERM: boolean;
  38922. DIFFUSEFRESNEL: boolean;
  38923. OPACITYFRESNEL: boolean;
  38924. REFLECTIONFRESNEL: boolean;
  38925. REFRACTIONFRESNEL: boolean;
  38926. EMISSIVEFRESNEL: boolean;
  38927. FRESNEL: boolean;
  38928. NORMAL: boolean;
  38929. UV1: boolean;
  38930. UV2: boolean;
  38931. VERTEXCOLOR: boolean;
  38932. VERTEXALPHA: boolean;
  38933. NUM_BONE_INFLUENCERS: number;
  38934. BonesPerMesh: number;
  38935. BONETEXTURE: boolean;
  38936. INSTANCES: boolean;
  38937. GLOSSINESS: boolean;
  38938. ROUGHNESS: boolean;
  38939. EMISSIVEASILLUMINATION: boolean;
  38940. LINKEMISSIVEWITHDIFFUSE: boolean;
  38941. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38942. LIGHTMAP: boolean;
  38943. LIGHTMAPDIRECTUV: number;
  38944. OBJECTSPACE_NORMALMAP: boolean;
  38945. USELIGHTMAPASSHADOWMAP: boolean;
  38946. REFLECTIONMAP_3D: boolean;
  38947. REFLECTIONMAP_SPHERICAL: boolean;
  38948. REFLECTIONMAP_PLANAR: boolean;
  38949. REFLECTIONMAP_CUBIC: boolean;
  38950. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38951. REFLECTIONMAP_PROJECTION: boolean;
  38952. REFLECTIONMAP_SKYBOX: boolean;
  38953. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38954. REFLECTIONMAP_EXPLICIT: boolean;
  38955. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38956. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38957. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38958. INVERTCUBICMAP: boolean;
  38959. LOGARITHMICDEPTH: boolean;
  38960. REFRACTION: boolean;
  38961. REFRACTIONMAP_3D: boolean;
  38962. REFLECTIONOVERALPHA: boolean;
  38963. TWOSIDEDLIGHTING: boolean;
  38964. SHADOWFLOAT: boolean;
  38965. MORPHTARGETS: boolean;
  38966. MORPHTARGETS_NORMAL: boolean;
  38967. MORPHTARGETS_TANGENT: boolean;
  38968. NUM_MORPH_INFLUENCERS: number;
  38969. NONUNIFORMSCALING: boolean;
  38970. PREMULTIPLYALPHA: boolean;
  38971. IMAGEPROCESSING: boolean;
  38972. VIGNETTE: boolean;
  38973. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38974. VIGNETTEBLENDMODEOPAQUE: boolean;
  38975. TONEMAPPING: boolean;
  38976. TONEMAPPING_ACES: boolean;
  38977. CONTRAST: boolean;
  38978. COLORCURVES: boolean;
  38979. COLORGRADING: boolean;
  38980. COLORGRADING3D: boolean;
  38981. SAMPLER3DGREENDEPTH: boolean;
  38982. SAMPLER3DBGRMAP: boolean;
  38983. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38984. /**
  38985. * If the reflection texture on this material is in linear color space
  38986. * @hidden
  38987. */
  38988. IS_REFLECTION_LINEAR: boolean;
  38989. /**
  38990. * If the refraction texture on this material is in linear color space
  38991. * @hidden
  38992. */
  38993. IS_REFRACTION_LINEAR: boolean;
  38994. EXPOSURE: boolean;
  38995. constructor();
  38996. setReflectionMode(modeToEnable: string): void;
  38997. }
  38998. /**
  38999. * This is the default material used in Babylon. It is the best trade off between quality
  39000. * and performances.
  39001. * @see http://doc.babylonjs.com/babylon101/materials
  39002. */
  39003. export class StandardMaterial extends PushMaterial {
  39004. private _diffuseTexture;
  39005. /**
  39006. * The basic texture of the material as viewed under a light.
  39007. */
  39008. diffuseTexture: Nullable<BaseTexture>;
  39009. private _ambientTexture;
  39010. /**
  39011. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39012. */
  39013. ambientTexture: Nullable<BaseTexture>;
  39014. private _opacityTexture;
  39015. /**
  39016. * Define the transparency of the material from a texture.
  39017. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39018. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39019. */
  39020. opacityTexture: Nullable<BaseTexture>;
  39021. private _reflectionTexture;
  39022. /**
  39023. * Define the texture used to display the reflection.
  39024. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39025. */
  39026. reflectionTexture: Nullable<BaseTexture>;
  39027. private _emissiveTexture;
  39028. /**
  39029. * Define texture of the material as if self lit.
  39030. * This will be mixed in the final result even in the absence of light.
  39031. */
  39032. emissiveTexture: Nullable<BaseTexture>;
  39033. private _specularTexture;
  39034. /**
  39035. * Define how the color and intensity of the highlight given by the light in the material.
  39036. */
  39037. specularTexture: Nullable<BaseTexture>;
  39038. private _bumpTexture;
  39039. /**
  39040. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39041. * 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.
  39042. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39043. */
  39044. bumpTexture: Nullable<BaseTexture>;
  39045. private _lightmapTexture;
  39046. /**
  39047. * Complex lighting can be computationally expensive to compute at runtime.
  39048. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39049. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39050. */
  39051. lightmapTexture: Nullable<BaseTexture>;
  39052. private _refractionTexture;
  39053. /**
  39054. * Define the texture used to display the refraction.
  39055. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39056. */
  39057. refractionTexture: Nullable<BaseTexture>;
  39058. /**
  39059. * The color of the material lit by the environmental background lighting.
  39060. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39061. */
  39062. ambientColor: Color3;
  39063. /**
  39064. * The basic color of the material as viewed under a light.
  39065. */
  39066. diffuseColor: Color3;
  39067. /**
  39068. * Define how the color and intensity of the highlight given by the light in the material.
  39069. */
  39070. specularColor: Color3;
  39071. /**
  39072. * Define the color of the material as if self lit.
  39073. * This will be mixed in the final result even in the absence of light.
  39074. */
  39075. emissiveColor: Color3;
  39076. /**
  39077. * Defines how sharp are the highlights in the material.
  39078. * The bigger the value the sharper giving a more glossy feeling to the result.
  39079. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39080. */
  39081. specularPower: number;
  39082. private _useAlphaFromDiffuseTexture;
  39083. /**
  39084. * Does the transparency come from the diffuse texture alpha channel.
  39085. */
  39086. useAlphaFromDiffuseTexture: boolean;
  39087. private _useEmissiveAsIllumination;
  39088. /**
  39089. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39090. */
  39091. useEmissiveAsIllumination: boolean;
  39092. private _linkEmissiveWithDiffuse;
  39093. /**
  39094. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39095. * the emissive level when the final color is close to one.
  39096. */
  39097. linkEmissiveWithDiffuse: boolean;
  39098. private _useSpecularOverAlpha;
  39099. /**
  39100. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39101. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39102. */
  39103. useSpecularOverAlpha: boolean;
  39104. private _useReflectionOverAlpha;
  39105. /**
  39106. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39107. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39108. */
  39109. useReflectionOverAlpha: boolean;
  39110. private _disableLighting;
  39111. /**
  39112. * Does lights from the scene impacts this material.
  39113. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39114. */
  39115. disableLighting: boolean;
  39116. private _useObjectSpaceNormalMap;
  39117. /**
  39118. * Allows using an object space normal map (instead of tangent space).
  39119. */
  39120. useObjectSpaceNormalMap: boolean;
  39121. private _useParallax;
  39122. /**
  39123. * Is parallax enabled or not.
  39124. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39125. */
  39126. useParallax: boolean;
  39127. private _useParallaxOcclusion;
  39128. /**
  39129. * Is parallax occlusion enabled or not.
  39130. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39131. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39132. */
  39133. useParallaxOcclusion: boolean;
  39134. /**
  39135. * 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.
  39136. */
  39137. parallaxScaleBias: number;
  39138. private _roughness;
  39139. /**
  39140. * Helps to define how blurry the reflections should appears in the material.
  39141. */
  39142. roughness: number;
  39143. /**
  39144. * In case of refraction, define the value of the indice of refraction.
  39145. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39146. */
  39147. indexOfRefraction: number;
  39148. /**
  39149. * Invert the refraction texture alongside the y axis.
  39150. * It can be useful with procedural textures or probe for instance.
  39151. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39152. */
  39153. invertRefractionY: boolean;
  39154. /**
  39155. * Defines the alpha limits in alpha test mode.
  39156. */
  39157. alphaCutOff: number;
  39158. private _useLightmapAsShadowmap;
  39159. /**
  39160. * In case of light mapping, define whether the map contains light or shadow informations.
  39161. */
  39162. useLightmapAsShadowmap: boolean;
  39163. private _diffuseFresnelParameters;
  39164. /**
  39165. * Define the diffuse fresnel parameters of the material.
  39166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39167. */
  39168. diffuseFresnelParameters: FresnelParameters;
  39169. private _opacityFresnelParameters;
  39170. /**
  39171. * Define the opacity fresnel parameters of the material.
  39172. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39173. */
  39174. opacityFresnelParameters: FresnelParameters;
  39175. private _reflectionFresnelParameters;
  39176. /**
  39177. * Define the reflection fresnel parameters of the material.
  39178. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39179. */
  39180. reflectionFresnelParameters: FresnelParameters;
  39181. private _refractionFresnelParameters;
  39182. /**
  39183. * Define the refraction fresnel parameters of the material.
  39184. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39185. */
  39186. refractionFresnelParameters: FresnelParameters;
  39187. private _emissiveFresnelParameters;
  39188. /**
  39189. * Define the emissive fresnel parameters of the material.
  39190. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39191. */
  39192. emissiveFresnelParameters: FresnelParameters;
  39193. private _useReflectionFresnelFromSpecular;
  39194. /**
  39195. * If true automatically deducts the fresnels values from the material specularity.
  39196. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39197. */
  39198. useReflectionFresnelFromSpecular: boolean;
  39199. private _useGlossinessFromSpecularMapAlpha;
  39200. /**
  39201. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39202. */
  39203. useGlossinessFromSpecularMapAlpha: boolean;
  39204. private _maxSimultaneousLights;
  39205. /**
  39206. * Defines the maximum number of lights that can be used in the material
  39207. */
  39208. maxSimultaneousLights: number;
  39209. private _invertNormalMapX;
  39210. /**
  39211. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39212. */
  39213. invertNormalMapX: boolean;
  39214. private _invertNormalMapY;
  39215. /**
  39216. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39217. */
  39218. invertNormalMapY: boolean;
  39219. private _twoSidedLighting;
  39220. /**
  39221. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39222. */
  39223. twoSidedLighting: boolean;
  39224. /**
  39225. * Default configuration related to image processing available in the standard Material.
  39226. */
  39227. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39228. /**
  39229. * Gets the image processing configuration used either in this material.
  39230. */
  39231. /**
  39232. * Sets the Default image processing configuration used either in the this material.
  39233. *
  39234. * If sets to null, the scene one is in use.
  39235. */
  39236. imageProcessingConfiguration: ImageProcessingConfiguration;
  39237. /**
  39238. * Keep track of the image processing observer to allow dispose and replace.
  39239. */
  39240. private _imageProcessingObserver;
  39241. /**
  39242. * Attaches a new image processing configuration to the Standard Material.
  39243. * @param configuration
  39244. */
  39245. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39246. /**
  39247. * Gets wether the color curves effect is enabled.
  39248. */
  39249. /**
  39250. * Sets wether the color curves effect is enabled.
  39251. */
  39252. cameraColorCurvesEnabled: boolean;
  39253. /**
  39254. * Gets wether the color grading effect is enabled.
  39255. */
  39256. /**
  39257. * Gets wether the color grading effect is enabled.
  39258. */
  39259. cameraColorGradingEnabled: boolean;
  39260. /**
  39261. * Gets wether tonemapping is enabled or not.
  39262. */
  39263. /**
  39264. * Sets wether tonemapping is enabled or not
  39265. */
  39266. cameraToneMappingEnabled: boolean;
  39267. /**
  39268. * The camera exposure used on this material.
  39269. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39270. * This corresponds to a photographic exposure.
  39271. */
  39272. /**
  39273. * The camera exposure used on this material.
  39274. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39275. * This corresponds to a photographic exposure.
  39276. */
  39277. cameraExposure: number;
  39278. /**
  39279. * Gets The camera contrast used on this material.
  39280. */
  39281. /**
  39282. * Sets The camera contrast used on this material.
  39283. */
  39284. cameraContrast: number;
  39285. /**
  39286. * Gets the Color Grading 2D Lookup Texture.
  39287. */
  39288. /**
  39289. * Sets the Color Grading 2D Lookup Texture.
  39290. */
  39291. cameraColorGradingTexture: Nullable<BaseTexture>;
  39292. /**
  39293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39295. * 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;
  39296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39297. */
  39298. /**
  39299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39301. * 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;
  39302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39303. */
  39304. cameraColorCurves: Nullable<ColorCurves>;
  39305. /**
  39306. * Custom callback helping to override the default shader used in the material.
  39307. */
  39308. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39309. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39310. protected _worldViewProjectionMatrix: Matrix;
  39311. protected _globalAmbientColor: Color3;
  39312. protected _useLogarithmicDepth: boolean;
  39313. /**
  39314. * Instantiates a new standard material.
  39315. * This is the default material used in Babylon. It is the best trade off between quality
  39316. * and performances.
  39317. * @see http://doc.babylonjs.com/babylon101/materials
  39318. * @param name Define the name of the material in the scene
  39319. * @param scene Define the scene the material belong to
  39320. */
  39321. constructor(name: string, scene: Scene);
  39322. /**
  39323. * Gets a boolean indicating that current material needs to register RTT
  39324. */
  39325. readonly hasRenderTargetTextures: boolean;
  39326. /**
  39327. * Gets the current class name of the material e.g. "StandardMaterial"
  39328. * Mainly use in serialization.
  39329. * @returns the class name
  39330. */
  39331. getClassName(): string;
  39332. /**
  39333. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39334. * You can try switching to logarithmic depth.
  39335. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39336. */
  39337. useLogarithmicDepth: boolean;
  39338. /**
  39339. * Specifies if the material will require alpha blending
  39340. * @returns a boolean specifying if alpha blending is needed
  39341. */
  39342. needAlphaBlending(): boolean;
  39343. /**
  39344. * Specifies if this material should be rendered in alpha test mode
  39345. * @returns a boolean specifying if an alpha test is needed.
  39346. */
  39347. needAlphaTesting(): boolean;
  39348. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39349. /**
  39350. * Get the texture used for alpha test purpose.
  39351. * @returns the diffuse texture in case of the standard material.
  39352. */
  39353. getAlphaTestTexture(): Nullable<BaseTexture>;
  39354. /**
  39355. * Get if the submesh is ready to be used and all its information available.
  39356. * Child classes can use it to update shaders
  39357. * @param mesh defines the mesh to check
  39358. * @param subMesh defines which submesh to check
  39359. * @param useInstances specifies that instances should be used
  39360. * @returns a boolean indicating that the submesh is ready or not
  39361. */
  39362. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39363. /**
  39364. * Builds the material UBO layouts.
  39365. * Used internally during the effect preparation.
  39366. */
  39367. buildUniformLayout(): void;
  39368. /**
  39369. * Unbinds the material from the mesh
  39370. */
  39371. unbind(): void;
  39372. /**
  39373. * Binds the submesh to this material by preparing the effect and shader to draw
  39374. * @param world defines the world transformation matrix
  39375. * @param mesh defines the mesh containing the submesh
  39376. * @param subMesh defines the submesh to bind the material to
  39377. */
  39378. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39379. /**
  39380. * Get the list of animatables in the material.
  39381. * @returns the list of animatables object used in the material
  39382. */
  39383. getAnimatables(): IAnimatable[];
  39384. /**
  39385. * Gets the active textures from the material
  39386. * @returns an array of textures
  39387. */
  39388. getActiveTextures(): BaseTexture[];
  39389. /**
  39390. * Specifies if the material uses a texture
  39391. * @param texture defines the texture to check against the material
  39392. * @returns a boolean specifying if the material uses the texture
  39393. */
  39394. hasTexture(texture: BaseTexture): boolean;
  39395. /**
  39396. * Disposes the material
  39397. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39398. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39399. */
  39400. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39401. /**
  39402. * Makes a duplicate of the material, and gives it a new name
  39403. * @param name defines the new name for the duplicated material
  39404. * @returns the cloned material
  39405. */
  39406. clone(name: string): StandardMaterial;
  39407. /**
  39408. * Serializes this material in a JSON representation
  39409. * @returns the serialized material object
  39410. */
  39411. serialize(): any;
  39412. /**
  39413. * Creates a standard material from parsed material data
  39414. * @param source defines the JSON representation of the material
  39415. * @param scene defines the hosting scene
  39416. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39417. * @returns a new standard material
  39418. */
  39419. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39420. /**
  39421. * Are diffuse textures enabled in the application.
  39422. */
  39423. static DiffuseTextureEnabled: boolean;
  39424. /**
  39425. * Are ambient textures enabled in the application.
  39426. */
  39427. static AmbientTextureEnabled: boolean;
  39428. /**
  39429. * Are opacity textures enabled in the application.
  39430. */
  39431. static OpacityTextureEnabled: boolean;
  39432. /**
  39433. * Are reflection textures enabled in the application.
  39434. */
  39435. static ReflectionTextureEnabled: boolean;
  39436. /**
  39437. * Are emissive textures enabled in the application.
  39438. */
  39439. static EmissiveTextureEnabled: boolean;
  39440. /**
  39441. * Are specular textures enabled in the application.
  39442. */
  39443. static SpecularTextureEnabled: boolean;
  39444. /**
  39445. * Are bump textures enabled in the application.
  39446. */
  39447. static BumpTextureEnabled: boolean;
  39448. /**
  39449. * Are lightmap textures enabled in the application.
  39450. */
  39451. static LightmapTextureEnabled: boolean;
  39452. /**
  39453. * Are refraction textures enabled in the application.
  39454. */
  39455. static RefractionTextureEnabled: boolean;
  39456. /**
  39457. * Are color grading textures enabled in the application.
  39458. */
  39459. static ColorGradingTextureEnabled: boolean;
  39460. /**
  39461. * Are fresnels enabled in the application.
  39462. */
  39463. static FresnelEnabled: boolean;
  39464. }
  39465. }
  39466. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39467. import { Scene } from "babylonjs/scene";
  39468. import { Texture } from "babylonjs/Materials/Textures/texture";
  39469. /**
  39470. * A class extending Texture allowing drawing on a texture
  39471. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39472. */
  39473. export class DynamicTexture extends Texture {
  39474. private _generateMipMaps;
  39475. private _canvas;
  39476. private _context;
  39477. private _engine;
  39478. /**
  39479. * Creates a DynamicTexture
  39480. * @param name defines the name of the texture
  39481. * @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
  39482. * @param scene defines the scene where you want the texture
  39483. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39484. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39485. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39486. */
  39487. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39488. /**
  39489. * Get the current class name of the texture useful for serialization or dynamic coding.
  39490. * @returns "DynamicTexture"
  39491. */
  39492. getClassName(): string;
  39493. /**
  39494. * Gets the current state of canRescale
  39495. */
  39496. readonly canRescale: boolean;
  39497. private _recreate;
  39498. /**
  39499. * Scales the texture
  39500. * @param ratio the scale factor to apply to both width and height
  39501. */
  39502. scale(ratio: number): void;
  39503. /**
  39504. * Resizes the texture
  39505. * @param width the new width
  39506. * @param height the new height
  39507. */
  39508. scaleTo(width: number, height: number): void;
  39509. /**
  39510. * Gets the context of the canvas used by the texture
  39511. * @returns the canvas context of the dynamic texture
  39512. */
  39513. getContext(): CanvasRenderingContext2D;
  39514. /**
  39515. * Clears the texture
  39516. */
  39517. clear(): void;
  39518. /**
  39519. * Updates the texture
  39520. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39521. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39522. */
  39523. update(invertY?: boolean, premulAlpha?: boolean): void;
  39524. /**
  39525. * Draws text onto the texture
  39526. * @param text defines the text to be drawn
  39527. * @param x defines the placement of the text from the left
  39528. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39529. * @param font defines the font to be used with font-style, font-size, font-name
  39530. * @param color defines the color used for the text
  39531. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39532. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39533. * @param update defines whether texture is immediately update (default is true)
  39534. */
  39535. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39536. /**
  39537. * Clones the texture
  39538. * @returns the clone of the texture.
  39539. */
  39540. clone(): DynamicTexture;
  39541. /**
  39542. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39543. * @returns a serialized dynamic texture object
  39544. */
  39545. serialize(): any;
  39546. /** @hidden */
  39547. _rebuild(): void;
  39548. }
  39549. }
  39550. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39551. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39552. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39553. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39554. /** @hidden */
  39555. export var imageProcessingPixelShader: {
  39556. name: string;
  39557. shader: string;
  39558. };
  39559. }
  39560. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39561. import { Nullable } from "babylonjs/types";
  39562. import { Color4 } from "babylonjs/Maths/math";
  39563. import { Camera } from "babylonjs/Cameras/camera";
  39564. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39565. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39566. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39568. import { Engine } from "babylonjs/Engines/engine";
  39569. import "babylonjs/Shaders/imageProcessing.fragment";
  39570. import "babylonjs/Shaders/postprocess.vertex";
  39571. /**
  39572. * ImageProcessingPostProcess
  39573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39574. */
  39575. export class ImageProcessingPostProcess extends PostProcess {
  39576. /**
  39577. * Default configuration related to image processing available in the PBR Material.
  39578. */
  39579. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39580. /**
  39581. * Gets the image processing configuration used either in this material.
  39582. */
  39583. /**
  39584. * Sets the Default image processing configuration used either in the this material.
  39585. *
  39586. * If sets to null, the scene one is in use.
  39587. */
  39588. imageProcessingConfiguration: ImageProcessingConfiguration;
  39589. /**
  39590. * Keep track of the image processing observer to allow dispose and replace.
  39591. */
  39592. private _imageProcessingObserver;
  39593. /**
  39594. * Attaches a new image processing configuration to the PBR Material.
  39595. * @param configuration
  39596. */
  39597. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39598. /**
  39599. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39600. */
  39601. /**
  39602. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39603. */
  39604. colorCurves: Nullable<ColorCurves>;
  39605. /**
  39606. * Gets wether the color curves effect is enabled.
  39607. */
  39608. /**
  39609. * Sets wether the color curves effect is enabled.
  39610. */
  39611. colorCurvesEnabled: boolean;
  39612. /**
  39613. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39614. */
  39615. /**
  39616. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39617. */
  39618. colorGradingTexture: Nullable<BaseTexture>;
  39619. /**
  39620. * Gets wether the color grading effect is enabled.
  39621. */
  39622. /**
  39623. * Gets wether the color grading effect is enabled.
  39624. */
  39625. colorGradingEnabled: boolean;
  39626. /**
  39627. * Gets exposure used in the effect.
  39628. */
  39629. /**
  39630. * Sets exposure used in the effect.
  39631. */
  39632. exposure: number;
  39633. /**
  39634. * Gets wether tonemapping is enabled or not.
  39635. */
  39636. /**
  39637. * Sets wether tonemapping is enabled or not
  39638. */
  39639. toneMappingEnabled: boolean;
  39640. /**
  39641. * Gets the type of tone mapping effect.
  39642. */
  39643. /**
  39644. * Sets the type of tone mapping effect.
  39645. */
  39646. toneMappingType: number;
  39647. /**
  39648. * Gets contrast used in the effect.
  39649. */
  39650. /**
  39651. * Sets contrast used in the effect.
  39652. */
  39653. contrast: number;
  39654. /**
  39655. * Gets Vignette stretch size.
  39656. */
  39657. /**
  39658. * Sets Vignette stretch size.
  39659. */
  39660. vignetteStretch: number;
  39661. /**
  39662. * Gets Vignette centre X Offset.
  39663. */
  39664. /**
  39665. * Sets Vignette centre X Offset.
  39666. */
  39667. vignetteCentreX: number;
  39668. /**
  39669. * Gets Vignette centre Y Offset.
  39670. */
  39671. /**
  39672. * Sets Vignette centre Y Offset.
  39673. */
  39674. vignetteCentreY: number;
  39675. /**
  39676. * Gets Vignette weight or intensity of the vignette effect.
  39677. */
  39678. /**
  39679. * Sets Vignette weight or intensity of the vignette effect.
  39680. */
  39681. vignetteWeight: number;
  39682. /**
  39683. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39684. * if vignetteEnabled is set to true.
  39685. */
  39686. /**
  39687. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39688. * if vignetteEnabled is set to true.
  39689. */
  39690. vignetteColor: Color4;
  39691. /**
  39692. * Gets Camera field of view used by the Vignette effect.
  39693. */
  39694. /**
  39695. * Sets Camera field of view used by the Vignette effect.
  39696. */
  39697. vignetteCameraFov: number;
  39698. /**
  39699. * Gets the vignette blend mode allowing different kind of effect.
  39700. */
  39701. /**
  39702. * Sets the vignette blend mode allowing different kind of effect.
  39703. */
  39704. vignetteBlendMode: number;
  39705. /**
  39706. * Gets wether the vignette effect is enabled.
  39707. */
  39708. /**
  39709. * Sets wether the vignette effect is enabled.
  39710. */
  39711. vignetteEnabled: boolean;
  39712. private _fromLinearSpace;
  39713. /**
  39714. * Gets wether the input of the processing is in Gamma or Linear Space.
  39715. */
  39716. /**
  39717. * Sets wether the input of the processing is in Gamma or Linear Space.
  39718. */
  39719. fromLinearSpace: boolean;
  39720. /**
  39721. * Defines cache preventing GC.
  39722. */
  39723. private _defines;
  39724. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39725. /**
  39726. * "ImageProcessingPostProcess"
  39727. * @returns "ImageProcessingPostProcess"
  39728. */
  39729. getClassName(): string;
  39730. protected _updateParameters(): void;
  39731. dispose(camera?: Camera): void;
  39732. }
  39733. }
  39734. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39735. import { Scene } from "babylonjs/scene";
  39736. import { Color3 } from "babylonjs/Maths/math";
  39737. import { Mesh } from "babylonjs/Meshes/mesh";
  39738. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39739. /**
  39740. * Class containing static functions to help procedurally build meshes
  39741. */
  39742. export class GroundBuilder {
  39743. /**
  39744. * Creates a ground mesh
  39745. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39746. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39748. * @param name defines the name of the mesh
  39749. * @param options defines the options used to create the mesh
  39750. * @param scene defines the hosting scene
  39751. * @returns the ground mesh
  39752. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39753. */
  39754. static CreateGround(name: string, options: {
  39755. width?: number;
  39756. height?: number;
  39757. subdivisions?: number;
  39758. subdivisionsX?: number;
  39759. subdivisionsY?: number;
  39760. updatable?: boolean;
  39761. }, scene: any): Mesh;
  39762. /**
  39763. * Creates a tiled ground mesh
  39764. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39765. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39766. * * 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
  39767. * * 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
  39768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39769. * @param name defines the name of the mesh
  39770. * @param options defines the options used to create the mesh
  39771. * @param scene defines the hosting scene
  39772. * @returns the tiled ground mesh
  39773. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39774. */
  39775. static CreateTiledGround(name: string, options: {
  39776. xmin: number;
  39777. zmin: number;
  39778. xmax: number;
  39779. zmax: number;
  39780. subdivisions?: {
  39781. w: number;
  39782. h: number;
  39783. };
  39784. precision?: {
  39785. w: number;
  39786. h: number;
  39787. };
  39788. updatable?: boolean;
  39789. }, scene: Scene): Mesh;
  39790. /**
  39791. * Creates a ground mesh from a height map
  39792. * * The parameter `url` sets the URL of the height map image resource.
  39793. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39794. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39795. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39796. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39797. * * 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.
  39798. * * 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).
  39799. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39801. * @param name defines the name of the mesh
  39802. * @param url defines the url to the height map
  39803. * @param options defines the options used to create the mesh
  39804. * @param scene defines the hosting scene
  39805. * @returns the ground mesh
  39806. * @see https://doc.babylonjs.com/babylon101/height_map
  39807. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39808. */
  39809. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39810. width?: number;
  39811. height?: number;
  39812. subdivisions?: number;
  39813. minHeight?: number;
  39814. maxHeight?: number;
  39815. colorFilter?: Color3;
  39816. alphaFilter?: number;
  39817. updatable?: boolean;
  39818. onReady?: (mesh: GroundMesh) => void;
  39819. }, scene: Scene): GroundMesh;
  39820. }
  39821. }
  39822. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39823. import { Vector4 } from "babylonjs/Maths/math";
  39824. import { Mesh } from "babylonjs/Meshes/mesh";
  39825. /**
  39826. * Class containing static functions to help procedurally build meshes
  39827. */
  39828. export class TorusBuilder {
  39829. /**
  39830. * Creates a torus mesh
  39831. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39832. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39833. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39837. * @param name defines the name of the mesh
  39838. * @param options defines the options used to create the mesh
  39839. * @param scene defines the hosting scene
  39840. * @returns the torus mesh
  39841. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39842. */
  39843. static CreateTorus(name: string, options: {
  39844. diameter?: number;
  39845. thickness?: number;
  39846. tessellation?: number;
  39847. updatable?: boolean;
  39848. sideOrientation?: number;
  39849. frontUVs?: Vector4;
  39850. backUVs?: Vector4;
  39851. }, scene: any): Mesh;
  39852. }
  39853. }
  39854. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39855. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39856. import { Mesh } from "babylonjs/Meshes/mesh";
  39857. /**
  39858. * Class containing static functions to help procedurally build meshes
  39859. */
  39860. export class CylinderBuilder {
  39861. /**
  39862. * Creates a cylinder or a cone mesh
  39863. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39864. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39865. * * 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.
  39866. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39867. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39868. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39869. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39870. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39871. * * 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).
  39872. * * 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
  39873. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39874. * * 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
  39875. * * 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.
  39876. * * If `enclose` is false, a ring surface is one element.
  39877. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39878. * * 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
  39879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39882. * @param name defines the name of the mesh
  39883. * @param options defines the options used to create the mesh
  39884. * @param scene defines the hosting scene
  39885. * @returns the cylinder mesh
  39886. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39887. */
  39888. static CreateCylinder(name: string, options: {
  39889. height?: number;
  39890. diameterTop?: number;
  39891. diameterBottom?: number;
  39892. diameter?: number;
  39893. tessellation?: number;
  39894. subdivisions?: number;
  39895. arc?: number;
  39896. faceColors?: Color4[];
  39897. faceUV?: Vector4[];
  39898. updatable?: boolean;
  39899. hasRings?: boolean;
  39900. enclose?: boolean;
  39901. sideOrientation?: number;
  39902. frontUVs?: Vector4;
  39903. backUVs?: Vector4;
  39904. }, scene: any): Mesh;
  39905. }
  39906. }
  39907. declare module "babylonjs/Gamepads/gamepadManager" {
  39908. import { Observable } from "babylonjs/Misc/observable";
  39909. import { Nullable } from "babylonjs/types";
  39910. import { Scene } from "babylonjs/scene";
  39911. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39912. /**
  39913. * Manager for handling gamepads
  39914. */
  39915. export class GamepadManager {
  39916. private _scene?;
  39917. private _babylonGamepads;
  39918. private _oneGamepadConnected;
  39919. /** @hidden */
  39920. _isMonitoring: boolean;
  39921. private _gamepadEventSupported;
  39922. private _gamepadSupport;
  39923. /**
  39924. * observable to be triggered when the gamepad controller has been connected
  39925. */
  39926. onGamepadConnectedObservable: Observable<Gamepad>;
  39927. /**
  39928. * observable to be triggered when the gamepad controller has been disconnected
  39929. */
  39930. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39931. private _onGamepadConnectedEvent;
  39932. private _onGamepadDisconnectedEvent;
  39933. /**
  39934. * Initializes the gamepad manager
  39935. * @param _scene BabylonJS scene
  39936. */
  39937. constructor(_scene?: Scene | undefined);
  39938. /**
  39939. * The gamepads in the game pad manager
  39940. */
  39941. readonly gamepads: Gamepad[];
  39942. /**
  39943. * Get the gamepad controllers based on type
  39944. * @param type The type of gamepad controller
  39945. * @returns Nullable gamepad
  39946. */
  39947. getGamepadByType(type?: number): Nullable<Gamepad>;
  39948. /**
  39949. * Disposes the gamepad manager
  39950. */
  39951. dispose(): void;
  39952. private _addNewGamepad;
  39953. private _startMonitoringGamepads;
  39954. private _stopMonitoringGamepads;
  39955. /** @hidden */
  39956. _checkGamepadsStatus(): void;
  39957. private _updateGamepadObjects;
  39958. }
  39959. }
  39960. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39961. import { Nullable } from "babylonjs/types";
  39962. import { Scene } from "babylonjs/scene";
  39963. import { ISceneComponent } from "babylonjs/sceneComponent";
  39964. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39965. module "babylonjs/scene" {
  39966. interface Scene {
  39967. /** @hidden */
  39968. _gamepadManager: Nullable<GamepadManager>;
  39969. /**
  39970. * Gets the gamepad manager associated with the scene
  39971. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39972. */
  39973. gamepadManager: GamepadManager;
  39974. }
  39975. }
  39976. module "babylonjs/Cameras/freeCameraInputsManager" {
  39977. /**
  39978. * Interface representing a free camera inputs manager
  39979. */
  39980. interface FreeCameraInputsManager {
  39981. /**
  39982. * Adds gamepad input support to the FreeCameraInputsManager.
  39983. * @returns the FreeCameraInputsManager
  39984. */
  39985. addGamepad(): FreeCameraInputsManager;
  39986. }
  39987. }
  39988. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39989. /**
  39990. * Interface representing an arc rotate camera inputs manager
  39991. */
  39992. interface ArcRotateCameraInputsManager {
  39993. /**
  39994. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39995. * @returns the camera inputs manager
  39996. */
  39997. addGamepad(): ArcRotateCameraInputsManager;
  39998. }
  39999. }
  40000. /**
  40001. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40002. */
  40003. export class GamepadSystemSceneComponent implements ISceneComponent {
  40004. /**
  40005. * The component name helpfull to identify the component in the list of scene components.
  40006. */
  40007. readonly name: string;
  40008. /**
  40009. * The scene the component belongs to.
  40010. */
  40011. scene: Scene;
  40012. /**
  40013. * Creates a new instance of the component for the given scene
  40014. * @param scene Defines the scene to register the component in
  40015. */
  40016. constructor(scene: Scene);
  40017. /**
  40018. * Registers the component in a given scene
  40019. */
  40020. register(): void;
  40021. /**
  40022. * Rebuilds the elements related to this component in case of
  40023. * context lost for instance.
  40024. */
  40025. rebuild(): void;
  40026. /**
  40027. * Disposes the component and the associated ressources
  40028. */
  40029. dispose(): void;
  40030. private _beforeCameraUpdate;
  40031. }
  40032. }
  40033. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40034. import { Observable } from "babylonjs/Misc/observable";
  40035. import { Nullable } from "babylonjs/types";
  40036. import { Camera } from "babylonjs/Cameras/camera";
  40037. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40038. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40039. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40040. import { Scene } from "babylonjs/scene";
  40041. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40042. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40044. import { Mesh } from "babylonjs/Meshes/mesh";
  40045. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40046. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40047. import "babylonjs/Meshes/Builders/groundBuilder";
  40048. import "babylonjs/Meshes/Builders/torusBuilder";
  40049. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40050. import "babylonjs/Gamepads/gamepadSceneComponent";
  40051. import "babylonjs/Animations/animatable";
  40052. /**
  40053. * Options to modify the vr teleportation behavior.
  40054. */
  40055. export interface VRTeleportationOptions {
  40056. /**
  40057. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40058. */
  40059. floorMeshName?: string;
  40060. /**
  40061. * A list of meshes to be used as the teleportation floor. (default: empty)
  40062. */
  40063. floorMeshes?: Mesh[];
  40064. }
  40065. /**
  40066. * Options to modify the vr experience helper's behavior.
  40067. */
  40068. export interface VRExperienceHelperOptions extends WebVROptions {
  40069. /**
  40070. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40071. */
  40072. createDeviceOrientationCamera?: boolean;
  40073. /**
  40074. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40075. */
  40076. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40077. /**
  40078. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40079. */
  40080. laserToggle?: boolean;
  40081. /**
  40082. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40083. */
  40084. floorMeshes?: Mesh[];
  40085. /**
  40086. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40087. */
  40088. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40089. }
  40090. /**
  40091. * Event containing information after VR has been entered
  40092. */
  40093. export class OnAfterEnteringVRObservableEvent {
  40094. /**
  40095. * If entering vr was successful
  40096. */
  40097. success: boolean;
  40098. }
  40099. /**
  40100. * Helps to quickly add VR support to an existing scene.
  40101. * See http://doc.babylonjs.com/how_to/webvr_helper
  40102. */
  40103. export class VRExperienceHelper {
  40104. /** Options to modify the vr experience helper's behavior. */
  40105. webVROptions: VRExperienceHelperOptions;
  40106. private _scene;
  40107. private _position;
  40108. private _btnVR;
  40109. private _btnVRDisplayed;
  40110. private _webVRsupported;
  40111. private _webVRready;
  40112. private _webVRrequesting;
  40113. private _webVRpresenting;
  40114. private _hasEnteredVR;
  40115. private _fullscreenVRpresenting;
  40116. private _canvas;
  40117. private _webVRCamera;
  40118. private _vrDeviceOrientationCamera;
  40119. private _deviceOrientationCamera;
  40120. private _existingCamera;
  40121. private _onKeyDown;
  40122. private _onVrDisplayPresentChange;
  40123. private _onVRDisplayChanged;
  40124. private _onVRRequestPresentStart;
  40125. private _onVRRequestPresentComplete;
  40126. /**
  40127. * Observable raised right before entering VR.
  40128. */
  40129. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40130. /**
  40131. * Observable raised when entering VR has completed.
  40132. */
  40133. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40134. /**
  40135. * Observable raised when exiting VR.
  40136. */
  40137. onExitingVRObservable: Observable<VRExperienceHelper>;
  40138. /**
  40139. * Observable raised when controller mesh is loaded.
  40140. */
  40141. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40142. /** Return this.onEnteringVRObservable
  40143. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40144. */
  40145. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40146. /** Return this.onExitingVRObservable
  40147. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40148. */
  40149. readonly onExitingVR: Observable<VRExperienceHelper>;
  40150. /** Return this.onControllerMeshLoadedObservable
  40151. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40152. */
  40153. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40154. private _rayLength;
  40155. private _useCustomVRButton;
  40156. private _teleportationRequested;
  40157. private _teleportActive;
  40158. private _floorMeshName;
  40159. private _floorMeshesCollection;
  40160. private _rotationAllowed;
  40161. private _teleportBackwardsVector;
  40162. private _teleportationTarget;
  40163. private _isDefaultTeleportationTarget;
  40164. private _postProcessMove;
  40165. private _teleportationFillColor;
  40166. private _teleportationBorderColor;
  40167. private _rotationAngle;
  40168. private _haloCenter;
  40169. private _cameraGazer;
  40170. private _padSensibilityUp;
  40171. private _padSensibilityDown;
  40172. private _leftController;
  40173. private _rightController;
  40174. /**
  40175. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40176. */
  40177. onNewMeshSelected: Observable<AbstractMesh>;
  40178. /**
  40179. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40180. */
  40181. onNewMeshPicked: Observable<PickingInfo>;
  40182. private _circleEase;
  40183. /**
  40184. * Observable raised before camera teleportation
  40185. */
  40186. onBeforeCameraTeleport: Observable<Vector3>;
  40187. /**
  40188. * Observable raised after camera teleportation
  40189. */
  40190. onAfterCameraTeleport: Observable<Vector3>;
  40191. /**
  40192. * Observable raised when current selected mesh gets unselected
  40193. */
  40194. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40195. private _raySelectionPredicate;
  40196. /**
  40197. * To be optionaly changed by user to define custom ray selection
  40198. */
  40199. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40200. /**
  40201. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40202. */
  40203. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40204. /**
  40205. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40206. */
  40207. teleportationEnabled: boolean;
  40208. private _defaultHeight;
  40209. private _teleportationInitialized;
  40210. private _interactionsEnabled;
  40211. private _interactionsRequested;
  40212. private _displayGaze;
  40213. private _displayLaserPointer;
  40214. /**
  40215. * The mesh used to display where the user is going to teleport.
  40216. */
  40217. /**
  40218. * Sets the mesh to be used to display where the user is going to teleport.
  40219. */
  40220. teleportationTarget: Mesh;
  40221. /**
  40222. * 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
  40223. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40224. * See http://doc.babylonjs.com/resources/baking_transformations
  40225. */
  40226. gazeTrackerMesh: Mesh;
  40227. /**
  40228. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40229. */
  40230. updateGazeTrackerScale: boolean;
  40231. /**
  40232. * If the gaze trackers color should be updated when selecting meshes
  40233. */
  40234. updateGazeTrackerColor: boolean;
  40235. /**
  40236. * The gaze tracking mesh corresponding to the left controller
  40237. */
  40238. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40239. /**
  40240. * The gaze tracking mesh corresponding to the right controller
  40241. */
  40242. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40243. /**
  40244. * If the ray of the gaze should be displayed.
  40245. */
  40246. /**
  40247. * Sets if the ray of the gaze should be displayed.
  40248. */
  40249. displayGaze: boolean;
  40250. /**
  40251. * If the ray of the LaserPointer should be displayed.
  40252. */
  40253. /**
  40254. * Sets if the ray of the LaserPointer should be displayed.
  40255. */
  40256. displayLaserPointer: boolean;
  40257. /**
  40258. * The deviceOrientationCamera used as the camera when not in VR.
  40259. */
  40260. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40261. /**
  40262. * Based on the current WebVR support, returns the current VR camera used.
  40263. */
  40264. readonly currentVRCamera: Nullable<Camera>;
  40265. /**
  40266. * The webVRCamera which is used when in VR.
  40267. */
  40268. readonly webVRCamera: WebVRFreeCamera;
  40269. /**
  40270. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40271. */
  40272. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40273. private readonly _teleportationRequestInitiated;
  40274. /**
  40275. * Defines wether or not Pointer lock should be requested when switching to
  40276. * full screen.
  40277. */
  40278. requestPointerLockOnFullScreen: boolean;
  40279. /**
  40280. * Instantiates a VRExperienceHelper.
  40281. * Helps to quickly add VR support to an existing scene.
  40282. * @param scene The scene the VRExperienceHelper belongs to.
  40283. * @param webVROptions Options to modify the vr experience helper's behavior.
  40284. */
  40285. constructor(scene: Scene,
  40286. /** Options to modify the vr experience helper's behavior. */
  40287. webVROptions?: VRExperienceHelperOptions);
  40288. private _onDefaultMeshLoaded;
  40289. private _onResize;
  40290. private _onFullscreenChange;
  40291. /**
  40292. * Gets a value indicating if we are currently in VR mode.
  40293. */
  40294. readonly isInVRMode: boolean;
  40295. private onVrDisplayPresentChange;
  40296. private onVRDisplayChanged;
  40297. private moveButtonToBottomRight;
  40298. private displayVRButton;
  40299. private updateButtonVisibility;
  40300. private _cachedAngularSensibility;
  40301. /**
  40302. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40303. * Otherwise, will use the fullscreen API.
  40304. */
  40305. enterVR(): void;
  40306. /**
  40307. * Attempt to exit VR, or fullscreen.
  40308. */
  40309. exitVR(): void;
  40310. /**
  40311. * The position of the vr experience helper.
  40312. */
  40313. /**
  40314. * Sets the position of the vr experience helper.
  40315. */
  40316. position: Vector3;
  40317. /**
  40318. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40319. */
  40320. enableInteractions(): void;
  40321. private readonly _noControllerIsActive;
  40322. private beforeRender;
  40323. private _isTeleportationFloor;
  40324. /**
  40325. * Adds a floor mesh to be used for teleportation.
  40326. * @param floorMesh the mesh to be used for teleportation.
  40327. */
  40328. addFloorMesh(floorMesh: Mesh): void;
  40329. /**
  40330. * Removes a floor mesh from being used for teleportation.
  40331. * @param floorMesh the mesh to be removed.
  40332. */
  40333. removeFloorMesh(floorMesh: Mesh): void;
  40334. /**
  40335. * Enables interactions and teleportation using the VR controllers and gaze.
  40336. * @param vrTeleportationOptions options to modify teleportation behavior.
  40337. */
  40338. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40339. private _onNewGamepadConnected;
  40340. private _tryEnableInteractionOnController;
  40341. private _onNewGamepadDisconnected;
  40342. private _enableInteractionOnController;
  40343. private _checkTeleportWithRay;
  40344. private _checkRotate;
  40345. private _checkTeleportBackwards;
  40346. private _enableTeleportationOnController;
  40347. private _createTeleportationCircles;
  40348. private _displayTeleportationTarget;
  40349. private _hideTeleportationTarget;
  40350. private _rotateCamera;
  40351. private _moveTeleportationSelectorTo;
  40352. private _workingVector;
  40353. private _workingQuaternion;
  40354. private _workingMatrix;
  40355. /**
  40356. * Teleports the users feet to the desired location
  40357. * @param location The location where the user's feet should be placed
  40358. */
  40359. teleportCamera(location: Vector3): void;
  40360. private _convertNormalToDirectionOfRay;
  40361. private _castRayAndSelectObject;
  40362. private _notifySelectedMeshUnselected;
  40363. /**
  40364. * Sets the color of the laser ray from the vr controllers.
  40365. * @param color new color for the ray.
  40366. */
  40367. changeLaserColor(color: Color3): void;
  40368. /**
  40369. * Sets the color of the ray from the vr headsets gaze.
  40370. * @param color new color for the ray.
  40371. */
  40372. changeGazeColor(color: Color3): void;
  40373. /**
  40374. * Exits VR and disposes of the vr experience helper
  40375. */
  40376. dispose(): void;
  40377. /**
  40378. * Gets the name of the VRExperienceHelper class
  40379. * @returns "VRExperienceHelper"
  40380. */
  40381. getClassName(): string;
  40382. }
  40383. }
  40384. declare module "babylonjs/Cameras/VR/index" {
  40385. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40386. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40387. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40388. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40389. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40390. export * from "babylonjs/Cameras/VR/webVRCamera";
  40391. }
  40392. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40393. import { Observable } from "babylonjs/Misc/observable";
  40394. import { Nullable } from "babylonjs/types";
  40395. import { IDisposable, Scene } from "babylonjs/scene";
  40396. import { Vector3 } from "babylonjs/Maths/math";
  40397. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40398. import { Ray } from "babylonjs/Culling/ray";
  40399. /**
  40400. * Manages an XRSession
  40401. * @see https://doc.babylonjs.com/how_to/webxr
  40402. */
  40403. export class WebXRSessionManager implements IDisposable {
  40404. private scene;
  40405. /**
  40406. * Fires every time a new xrFrame arrives which can be used to update the camera
  40407. */
  40408. onXRFrameObservable: Observable<any>;
  40409. /**
  40410. * Fires when the xr session is ended either by the device or manually done
  40411. */
  40412. onXRSessionEnded: Observable<any>;
  40413. /** @hidden */
  40414. _xrSession: XRSession;
  40415. /** @hidden */
  40416. _frameOfReference: XRFrameOfReference;
  40417. /** @hidden */
  40418. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40419. /** @hidden */
  40420. _currentXRFrame: Nullable<XRFrame>;
  40421. private _xrNavigator;
  40422. private _xrDevice;
  40423. private _tmpMatrix;
  40424. /**
  40425. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40426. * @param scene The scene which the session should be created for
  40427. */
  40428. constructor(scene: Scene);
  40429. /**
  40430. * Initializes the manager
  40431. * After initialization enterXR can be called to start an XR session
  40432. * @returns Promise which resolves after it is initialized
  40433. */
  40434. initializeAsync(): Promise<void>;
  40435. /**
  40436. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40437. * @param sessionCreationOptions xr options to create the session with
  40438. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40439. * @returns Promise which resolves after it enters XR
  40440. */
  40441. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40442. /**
  40443. * Stops the xrSession and restores the renderloop
  40444. * @returns Promise which resolves after it exits XR
  40445. */
  40446. exitXRAsync(): Promise<void>;
  40447. /**
  40448. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40449. * @param ray ray to cast into the environment
  40450. * @returns Promise which resolves with a collision point in the environment if it exists
  40451. */
  40452. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40453. /**
  40454. * Checks if a session would be supported for the creation options specified
  40455. * @param options creation options to check if they are supported
  40456. * @returns true if supported
  40457. */
  40458. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40459. /**
  40460. * @hidden
  40461. * Converts the render layer of xrSession to a render target
  40462. * @param session session to create render target for
  40463. * @param scene scene the new render target should be created for
  40464. */
  40465. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40466. /**
  40467. * Disposes of the session manager
  40468. */
  40469. dispose(): void;
  40470. }
  40471. }
  40472. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40473. import { Scene } from "babylonjs/scene";
  40474. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40475. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40476. /**
  40477. * WebXR Camera which holds the views for the xrSession
  40478. * @see https://doc.babylonjs.com/how_to/webxr
  40479. */
  40480. export class WebXRCamera extends FreeCamera {
  40481. private static _TmpMatrix;
  40482. /**
  40483. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40484. * @param name the name of the camera
  40485. * @param scene the scene to add the camera to
  40486. */
  40487. constructor(name: string, scene: Scene);
  40488. private _updateNumberOfRigCameras;
  40489. /** @hidden */
  40490. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40491. /**
  40492. * Updates the cameras position from the current pose information of the XR session
  40493. * @param xrSessionManager the session containing pose information
  40494. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40495. */
  40496. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40497. }
  40498. }
  40499. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40500. import { Nullable } from "babylonjs/types";
  40501. import { Observable } from "babylonjs/Misc/observable";
  40502. import { IDisposable, Scene } from "babylonjs/scene";
  40503. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40505. import { Ray } from "babylonjs/Culling/ray";
  40506. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40507. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40508. /**
  40509. * States of the webXR experience
  40510. */
  40511. export enum WebXRState {
  40512. /**
  40513. * Transitioning to being in XR mode
  40514. */
  40515. ENTERING_XR = 0,
  40516. /**
  40517. * Transitioning to non XR mode
  40518. */
  40519. EXITING_XR = 1,
  40520. /**
  40521. * In XR mode and presenting
  40522. */
  40523. IN_XR = 2,
  40524. /**
  40525. * Not entered XR mode
  40526. */
  40527. NOT_IN_XR = 3
  40528. }
  40529. /**
  40530. * Helper class used to enable XR
  40531. * @see https://doc.babylonjs.com/how_to/webxr
  40532. */
  40533. export class WebXRExperienceHelper implements IDisposable {
  40534. private scene;
  40535. /**
  40536. * 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
  40537. */
  40538. container: AbstractMesh;
  40539. /**
  40540. * Camera used to render xr content
  40541. */
  40542. camera: WebXRCamera;
  40543. /**
  40544. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40545. */
  40546. state: WebXRState;
  40547. private _setState;
  40548. private static _TmpVector;
  40549. /**
  40550. * Fires when the state of the experience helper has changed
  40551. */
  40552. onStateChangedObservable: Observable<WebXRState>;
  40553. /** @hidden */
  40554. _sessionManager: WebXRSessionManager;
  40555. private _nonVRCamera;
  40556. private _originalSceneAutoClear;
  40557. private _supported;
  40558. /**
  40559. * Creates the experience helper
  40560. * @param scene the scene to attach the experience helper to
  40561. * @returns a promise for the experience helper
  40562. */
  40563. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40564. /**
  40565. * Creates a WebXRExperienceHelper
  40566. * @param scene The scene the helper should be created in
  40567. */
  40568. private constructor();
  40569. /**
  40570. * Exits XR mode and returns the scene to its original state
  40571. * @returns promise that resolves after xr mode has exited
  40572. */
  40573. exitXRAsync(): Promise<void>;
  40574. /**
  40575. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40576. * @param sessionCreationOptions options for the XR session
  40577. * @param frameOfReference frame of reference of the XR session
  40578. * @returns promise that resolves after xr mode has entered
  40579. */
  40580. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40581. /**
  40582. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40583. * @param ray ray to cast into the environment
  40584. * @returns Promise which resolves with a collision point in the environment if it exists
  40585. */
  40586. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40587. /**
  40588. * Updates the global position of the camera by moving the camera's container
  40589. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40590. * @param position The desired global position of the camera
  40591. */
  40592. setPositionOfCameraUsingContainer(position: Vector3): void;
  40593. /**
  40594. * Rotates the xr camera by rotating the camera's container around the camera's position
  40595. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40596. * @param rotation the desired quaternion rotation to apply to the camera
  40597. */
  40598. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40599. /**
  40600. * Checks if the creation options are supported by the xr session
  40601. * @param options creation options
  40602. * @returns true if supported
  40603. */
  40604. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40605. /**
  40606. * Disposes of the experience helper
  40607. */
  40608. dispose(): void;
  40609. }
  40610. }
  40611. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40612. import { Nullable } from "babylonjs/types";
  40613. import { Observable } from "babylonjs/Misc/observable";
  40614. import { IDisposable, Scene } from "babylonjs/scene";
  40615. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40616. /**
  40617. * Button which can be used to enter a different mode of XR
  40618. */
  40619. export class WebXREnterExitUIButton {
  40620. /** button element */
  40621. element: HTMLElement;
  40622. /** XR initialization options for the button */
  40623. initializationOptions: XRSessionCreationOptions;
  40624. /**
  40625. * Creates a WebXREnterExitUIButton
  40626. * @param element button element
  40627. * @param initializationOptions XR initialization options for the button
  40628. */
  40629. constructor(
  40630. /** button element */
  40631. element: HTMLElement,
  40632. /** XR initialization options for the button */
  40633. initializationOptions: XRSessionCreationOptions);
  40634. /**
  40635. * Overwritable function which can be used to update the button's visuals when the state changes
  40636. * @param activeButton the current active button in the UI
  40637. */
  40638. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40639. }
  40640. /**
  40641. * Options to create the webXR UI
  40642. */
  40643. export class WebXREnterExitUIOptions {
  40644. /**
  40645. * Context to enter xr with
  40646. */
  40647. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40648. /**
  40649. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40650. */
  40651. customButtons?: Array<WebXREnterExitUIButton>;
  40652. }
  40653. /**
  40654. * UI to allow the user to enter/exit XR mode
  40655. */
  40656. export class WebXREnterExitUI implements IDisposable {
  40657. private scene;
  40658. private _overlay;
  40659. private _buttons;
  40660. private _activeButton;
  40661. /**
  40662. * Fired every time the active button is changed.
  40663. *
  40664. * When xr is entered via a button that launches xr that button will be the callback parameter
  40665. *
  40666. * When exiting xr the callback parameter will be null)
  40667. */
  40668. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40669. /**
  40670. * Creates UI to allow the user to enter/exit XR mode
  40671. * @param scene the scene to add the ui to
  40672. * @param helper the xr experience helper to enter/exit xr with
  40673. * @param options options to configure the UI
  40674. * @returns the created ui
  40675. */
  40676. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40677. private constructor();
  40678. private _updateButtons;
  40679. /**
  40680. * Disposes of the object
  40681. */
  40682. dispose(): void;
  40683. }
  40684. }
  40685. declare module "babylonjs/Cameras/XR/webXRInput" {
  40686. import { IDisposable, Scene } from "babylonjs/scene";
  40687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40688. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40689. /**
  40690. * Represents an XR input
  40691. */
  40692. export class WebXRController {
  40693. /**
  40694. * 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
  40695. */
  40696. grip?: AbstractMesh;
  40697. /**
  40698. * Pointer which can be used to select objects or attach a visible laser to
  40699. */
  40700. pointer: AbstractMesh;
  40701. /**
  40702. * Creates the controller
  40703. * @see https://doc.babylonjs.com/how_to/webxr
  40704. * @param scene the scene which the controller should be associated to
  40705. */
  40706. constructor(scene: Scene);
  40707. /**
  40708. * Disposes of the object
  40709. */
  40710. dispose(): void;
  40711. }
  40712. /**
  40713. * XR input used to track XR inputs such as controllers/rays
  40714. */
  40715. export class WebXRInput implements IDisposable {
  40716. private helper;
  40717. /**
  40718. * XR controllers being tracked
  40719. */
  40720. controllers: Array<WebXRController>;
  40721. private _tmpMatrix;
  40722. private _frameObserver;
  40723. /**
  40724. * Initializes the WebXRInput
  40725. * @param helper experience helper which the input should be created for
  40726. */
  40727. constructor(helper: WebXRExperienceHelper);
  40728. /**
  40729. * Disposes of the object
  40730. */
  40731. dispose(): void;
  40732. }
  40733. }
  40734. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40735. import { Nullable } from "babylonjs/types";
  40736. import { IDisposable } from "babylonjs/scene";
  40737. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40738. /**
  40739. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40740. */
  40741. export class WebXRManagedOutputCanvas implements IDisposable {
  40742. private _canvas;
  40743. /**
  40744. * xrpresent context of the canvas which can be used to display/mirror xr content
  40745. */
  40746. canvasContext: Nullable<WebGLRenderingContext>;
  40747. /**
  40748. * Initializes the canvas to be added/removed upon entering/exiting xr
  40749. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40750. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40751. */
  40752. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40753. /**
  40754. * Disposes of the object
  40755. */
  40756. dispose(): void;
  40757. private _setManagedOutputCanvas;
  40758. private _addCanvas;
  40759. private _removeCanvas;
  40760. }
  40761. }
  40762. declare module "babylonjs/Cameras/XR/index" {
  40763. export * from "babylonjs/Cameras/XR/webXRCamera";
  40764. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40765. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40766. export * from "babylonjs/Cameras/XR/webXRInput";
  40767. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40768. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40769. }
  40770. declare module "babylonjs/Cameras/RigModes/index" {
  40771. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40772. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40773. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40774. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40775. }
  40776. declare module "babylonjs/Cameras/index" {
  40777. export * from "babylonjs/Cameras/Inputs/index";
  40778. export * from "babylonjs/Cameras/cameraInputsManager";
  40779. export * from "babylonjs/Cameras/camera";
  40780. export * from "babylonjs/Cameras/targetCamera";
  40781. export * from "babylonjs/Cameras/freeCamera";
  40782. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40783. export * from "babylonjs/Cameras/touchCamera";
  40784. export * from "babylonjs/Cameras/arcRotateCamera";
  40785. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40786. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40787. export * from "babylonjs/Cameras/flyCamera";
  40788. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40789. export * from "babylonjs/Cameras/followCamera";
  40790. export * from "babylonjs/Cameras/gamepadCamera";
  40791. export * from "babylonjs/Cameras/Stereoscopic/index";
  40792. export * from "babylonjs/Cameras/universalCamera";
  40793. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40794. export * from "babylonjs/Cameras/VR/index";
  40795. export * from "babylonjs/Cameras/XR/index";
  40796. export * from "babylonjs/Cameras/RigModes/index";
  40797. }
  40798. declare module "babylonjs/Collisions/index" {
  40799. export * from "babylonjs/Collisions/collider";
  40800. export * from "babylonjs/Collisions/collisionCoordinator";
  40801. export * from "babylonjs/Collisions/pickingInfo";
  40802. export * from "babylonjs/Collisions/intersectionInfo";
  40803. }
  40804. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40805. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40806. import { Vector3, Plane } from "babylonjs/Maths/math";
  40807. import { Ray } from "babylonjs/Culling/ray";
  40808. /**
  40809. * Contains an array of blocks representing the octree
  40810. */
  40811. export interface IOctreeContainer<T> {
  40812. /**
  40813. * Blocks within the octree
  40814. */
  40815. blocks: Array<OctreeBlock<T>>;
  40816. }
  40817. /**
  40818. * Class used to store a cell in an octree
  40819. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40820. */
  40821. export class OctreeBlock<T> {
  40822. /**
  40823. * Gets the content of the current block
  40824. */
  40825. entries: T[];
  40826. /**
  40827. * Gets the list of block children
  40828. */
  40829. blocks: Array<OctreeBlock<T>>;
  40830. private _depth;
  40831. private _maxDepth;
  40832. private _capacity;
  40833. private _minPoint;
  40834. private _maxPoint;
  40835. private _boundingVectors;
  40836. private _creationFunc;
  40837. /**
  40838. * Creates a new block
  40839. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40840. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40841. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40842. * @param depth defines the current depth of this block in the octree
  40843. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40844. * @param creationFunc defines a callback to call when an element is added to the block
  40845. */
  40846. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40847. /**
  40848. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40849. */
  40850. readonly capacity: number;
  40851. /**
  40852. * Gets the minimum vector (in world space) of the block's bounding box
  40853. */
  40854. readonly minPoint: Vector3;
  40855. /**
  40856. * Gets the maximum vector (in world space) of the block's bounding box
  40857. */
  40858. readonly maxPoint: Vector3;
  40859. /**
  40860. * Add a new element to this block
  40861. * @param entry defines the element to add
  40862. */
  40863. addEntry(entry: T): void;
  40864. /**
  40865. * Remove an element from this block
  40866. * @param entry defines the element to remove
  40867. */
  40868. removeEntry(entry: T): void;
  40869. /**
  40870. * Add an array of elements to this block
  40871. * @param entries defines the array of elements to add
  40872. */
  40873. addEntries(entries: T[]): void;
  40874. /**
  40875. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40876. * @param frustumPlanes defines the frustum planes to test
  40877. * @param selection defines the array to store current content if selection is positive
  40878. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40879. */
  40880. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40881. /**
  40882. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40883. * @param sphereCenter defines the bounding sphere center
  40884. * @param sphereRadius defines the bounding sphere radius
  40885. * @param selection defines the array to store current content if selection is positive
  40886. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40887. */
  40888. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40889. /**
  40890. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40891. * @param ray defines the ray to test with
  40892. * @param selection defines the array to store current content if selection is positive
  40893. */
  40894. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40895. /**
  40896. * Subdivide the content into child blocks (this block will then be empty)
  40897. */
  40898. createInnerBlocks(): void;
  40899. /**
  40900. * @hidden
  40901. */
  40902. 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;
  40903. }
  40904. }
  40905. declare module "babylonjs/Culling/Octrees/octree" {
  40906. import { SmartArray } from "babylonjs/Misc/smartArray";
  40907. import { Vector3, Plane } from "babylonjs/Maths/math";
  40908. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40910. import { Ray } from "babylonjs/Culling/ray";
  40911. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40912. /**
  40913. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40914. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40915. */
  40916. export class Octree<T> {
  40917. /** 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.) */
  40918. maxDepth: number;
  40919. /**
  40920. * Blocks within the octree containing objects
  40921. */
  40922. blocks: Array<OctreeBlock<T>>;
  40923. /**
  40924. * Content stored in the octree
  40925. */
  40926. dynamicContent: T[];
  40927. private _maxBlockCapacity;
  40928. private _selectionContent;
  40929. private _creationFunc;
  40930. /**
  40931. * Creates a octree
  40932. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40933. * @param creationFunc function to be used to instatiate the octree
  40934. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40935. * @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.)
  40936. */
  40937. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40938. /** 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.) */
  40939. maxDepth?: number);
  40940. /**
  40941. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40942. * @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);
  40943. * @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);
  40944. * @param entries meshes to be added to the octree blocks
  40945. */
  40946. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40947. /**
  40948. * Adds a mesh to the octree
  40949. * @param entry Mesh to add to the octree
  40950. */
  40951. addMesh(entry: T): void;
  40952. /**
  40953. * Remove an element from the octree
  40954. * @param entry defines the element to remove
  40955. */
  40956. removeMesh(entry: T): void;
  40957. /**
  40958. * Selects an array of meshes within the frustum
  40959. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40960. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40961. * @returns array of meshes within the frustum
  40962. */
  40963. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40964. /**
  40965. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40966. * @param sphereCenter defines the bounding sphere center
  40967. * @param sphereRadius defines the bounding sphere radius
  40968. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40969. * @returns an array of objects that intersect the sphere
  40970. */
  40971. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40972. /**
  40973. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40974. * @param ray defines the ray to test with
  40975. * @returns array of intersected objects
  40976. */
  40977. intersectsRay(ray: Ray): SmartArray<T>;
  40978. /**
  40979. * Adds a mesh into the octree block if it intersects the block
  40980. */
  40981. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40982. /**
  40983. * Adds a submesh into the octree block if it intersects the block
  40984. */
  40985. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40986. }
  40987. }
  40988. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40989. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40990. import { Scene } from "babylonjs/scene";
  40991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40993. import { Ray } from "babylonjs/Culling/ray";
  40994. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40995. import { Collider } from "babylonjs/Collisions/collider";
  40996. module "babylonjs/scene" {
  40997. interface Scene {
  40998. /**
  40999. * @hidden
  41000. * Backing Filed
  41001. */
  41002. _selectionOctree: Octree<AbstractMesh>;
  41003. /**
  41004. * Gets the octree used to boost mesh selection (picking)
  41005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41006. */
  41007. selectionOctree: Octree<AbstractMesh>;
  41008. /**
  41009. * Creates or updates the octree used to boost selection (picking)
  41010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41011. * @param maxCapacity defines the maximum capacity per leaf
  41012. * @param maxDepth defines the maximum depth of the octree
  41013. * @returns an octree of AbstractMesh
  41014. */
  41015. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41016. }
  41017. }
  41018. module "babylonjs/Meshes/abstractMesh" {
  41019. interface AbstractMesh {
  41020. /**
  41021. * @hidden
  41022. * Backing Field
  41023. */
  41024. _submeshesOctree: Octree<SubMesh>;
  41025. /**
  41026. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41027. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41028. * @param maxCapacity defines the maximum size of each block (64 by default)
  41029. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41030. * @returns the new octree
  41031. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41033. */
  41034. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41035. }
  41036. }
  41037. /**
  41038. * Defines the octree scene component responsible to manage any octrees
  41039. * in a given scene.
  41040. */
  41041. export class OctreeSceneComponent {
  41042. /**
  41043. * The component name helpfull to identify the component in the list of scene components.
  41044. */
  41045. readonly name: string;
  41046. /**
  41047. * The scene the component belongs to.
  41048. */
  41049. scene: Scene;
  41050. /**
  41051. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41052. */
  41053. readonly checksIsEnabled: boolean;
  41054. /**
  41055. * Creates a new instance of the component for the given scene
  41056. * @param scene Defines the scene to register the component in
  41057. */
  41058. constructor(scene: Scene);
  41059. /**
  41060. * Registers the component in a given scene
  41061. */
  41062. register(): void;
  41063. /**
  41064. * Return the list of active meshes
  41065. * @returns the list of active meshes
  41066. */
  41067. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41068. /**
  41069. * Return the list of active sub meshes
  41070. * @param mesh The mesh to get the candidates sub meshes from
  41071. * @returns the list of active sub meshes
  41072. */
  41073. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41074. private _tempRay;
  41075. /**
  41076. * Return the list of sub meshes intersecting with a given local ray
  41077. * @param mesh defines the mesh to find the submesh for
  41078. * @param localRay defines the ray in local space
  41079. * @returns the list of intersecting sub meshes
  41080. */
  41081. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41082. /**
  41083. * Return the list of sub meshes colliding with a collider
  41084. * @param mesh defines the mesh to find the submesh for
  41085. * @param collider defines the collider to evaluate the collision against
  41086. * @returns the list of colliding sub meshes
  41087. */
  41088. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41089. /**
  41090. * Rebuilds the elements related to this component in case of
  41091. * context lost for instance.
  41092. */
  41093. rebuild(): void;
  41094. /**
  41095. * Disposes the component and the associated ressources.
  41096. */
  41097. dispose(): void;
  41098. }
  41099. }
  41100. declare module "babylonjs/Culling/Octrees/index" {
  41101. export * from "babylonjs/Culling/Octrees/octree";
  41102. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41103. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41104. }
  41105. declare module "babylonjs/Culling/index" {
  41106. export * from "babylonjs/Culling/boundingBox";
  41107. export * from "babylonjs/Culling/boundingInfo";
  41108. export * from "babylonjs/Culling/boundingSphere";
  41109. export * from "babylonjs/Culling/Octrees/index";
  41110. export * from "babylonjs/Culling/ray";
  41111. }
  41112. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41113. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41114. import { Nullable } from "babylonjs/types";
  41115. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41116. import { Scene } from "babylonjs/scene";
  41117. /**
  41118. * Class containing static functions to help procedurally build meshes
  41119. */
  41120. export class LinesBuilder {
  41121. /**
  41122. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41123. * * 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
  41124. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41125. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41126. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41127. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41128. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41129. * * 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
  41130. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41133. * @param name defines the name of the new line system
  41134. * @param options defines the options used to create the line system
  41135. * @param scene defines the hosting scene
  41136. * @returns a new line system mesh
  41137. */
  41138. static CreateLineSystem(name: string, options: {
  41139. lines: Vector3[][];
  41140. updatable?: boolean;
  41141. instance?: Nullable<LinesMesh>;
  41142. colors?: Nullable<Color4[][]>;
  41143. useVertexAlpha?: boolean;
  41144. }, scene: Nullable<Scene>): LinesMesh;
  41145. /**
  41146. * Creates a line mesh
  41147. * 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
  41148. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41149. * * The parameter `points` is an array successive Vector3
  41150. * * 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
  41151. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41152. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41153. * * When updating an instance, remember that only point positions can change, not the number of points
  41154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41156. * @param name defines the name of the new line system
  41157. * @param options defines the options used to create the line system
  41158. * @param scene defines the hosting scene
  41159. * @returns a new line mesh
  41160. */
  41161. static CreateLines(name: string, options: {
  41162. points: Vector3[];
  41163. updatable?: boolean;
  41164. instance?: Nullable<LinesMesh>;
  41165. colors?: Color4[];
  41166. useVertexAlpha?: boolean;
  41167. }, scene?: Nullable<Scene>): LinesMesh;
  41168. /**
  41169. * Creates a dashed line mesh
  41170. * * 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
  41171. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41172. * * The parameter `points` is an array successive Vector3
  41173. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41174. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41175. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41176. * * 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
  41177. * * When updating an instance, remember that only point positions can change, not the number of points
  41178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41179. * @param name defines the name of the mesh
  41180. * @param options defines the options used to create the mesh
  41181. * @param scene defines the hosting scene
  41182. * @returns the dashed line mesh
  41183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41184. */
  41185. static CreateDashedLines(name: string, options: {
  41186. points: Vector3[];
  41187. dashSize?: number;
  41188. gapSize?: number;
  41189. dashNb?: number;
  41190. updatable?: boolean;
  41191. instance?: LinesMesh;
  41192. }, scene?: Nullable<Scene>): LinesMesh;
  41193. }
  41194. }
  41195. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41196. import { IDisposable, Scene } from "babylonjs/scene";
  41197. import { Nullable } from "babylonjs/types";
  41198. import { Observable } from "babylonjs/Misc/observable";
  41199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41200. /**
  41201. * Renders a layer on top of an existing scene
  41202. */
  41203. export class UtilityLayerRenderer implements IDisposable {
  41204. /** the original scene that will be rendered on top of */
  41205. originalScene: Scene;
  41206. private _pointerCaptures;
  41207. private _lastPointerEvents;
  41208. private static _DefaultUtilityLayer;
  41209. private static _DefaultKeepDepthUtilityLayer;
  41210. /**
  41211. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41212. */
  41213. pickUtilitySceneFirst: boolean;
  41214. /**
  41215. * 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)
  41216. */
  41217. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41218. /**
  41219. * 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)
  41220. */
  41221. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41222. /**
  41223. * The scene that is rendered on top of the original scene
  41224. */
  41225. utilityLayerScene: Scene;
  41226. /**
  41227. * If the utility layer should automatically be rendered on top of existing scene
  41228. */
  41229. shouldRender: boolean;
  41230. /**
  41231. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41232. */
  41233. onlyCheckPointerDownEvents: boolean;
  41234. /**
  41235. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41236. */
  41237. processAllEvents: boolean;
  41238. /**
  41239. * Observable raised when the pointer move from the utility layer scene to the main scene
  41240. */
  41241. onPointerOutObservable: Observable<number>;
  41242. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41243. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41244. private _afterRenderObserver;
  41245. private _sceneDisposeObserver;
  41246. private _originalPointerObserver;
  41247. /**
  41248. * Instantiates a UtilityLayerRenderer
  41249. * @param originalScene the original scene that will be rendered on top of
  41250. * @param handleEvents boolean indicating if the utility layer should handle events
  41251. */
  41252. constructor(
  41253. /** the original scene that will be rendered on top of */
  41254. originalScene: Scene, handleEvents?: boolean);
  41255. private _notifyObservers;
  41256. /**
  41257. * Renders the utility layers scene on top of the original scene
  41258. */
  41259. render(): void;
  41260. /**
  41261. * Disposes of the renderer
  41262. */
  41263. dispose(): void;
  41264. private _updateCamera;
  41265. }
  41266. }
  41267. declare module "babylonjs/Gizmos/gizmo" {
  41268. import { Nullable } from "babylonjs/types";
  41269. import { IDisposable } from "babylonjs/scene";
  41270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41271. import { Mesh } from "babylonjs/Meshes/mesh";
  41272. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41273. /**
  41274. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41275. */
  41276. export class Gizmo implements IDisposable {
  41277. /** The utility layer the gizmo will be added to */
  41278. gizmoLayer: UtilityLayerRenderer;
  41279. /**
  41280. * The root mesh of the gizmo
  41281. */
  41282. _rootMesh: Mesh;
  41283. private _attachedMesh;
  41284. /**
  41285. * Ratio for the scale of the gizmo (Default: 1)
  41286. */
  41287. scaleRatio: number;
  41288. private _tmpMatrix;
  41289. /**
  41290. * If a custom mesh has been set (Default: false)
  41291. */
  41292. protected _customMeshSet: boolean;
  41293. /**
  41294. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41295. * * When set, interactions will be enabled
  41296. */
  41297. attachedMesh: Nullable<AbstractMesh>;
  41298. /**
  41299. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41300. * @param mesh The mesh to replace the default mesh of the gizmo
  41301. */
  41302. setCustomMesh(mesh: Mesh): void;
  41303. /**
  41304. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41305. */
  41306. updateGizmoRotationToMatchAttachedMesh: boolean;
  41307. /**
  41308. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41309. */
  41310. updateGizmoPositionToMatchAttachedMesh: boolean;
  41311. /**
  41312. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41313. */
  41314. protected _updateScale: boolean;
  41315. protected _interactionsEnabled: boolean;
  41316. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41317. private _beforeRenderObserver;
  41318. /**
  41319. * Creates a gizmo
  41320. * @param gizmoLayer The utility layer the gizmo will be added to
  41321. */
  41322. constructor(
  41323. /** The utility layer the gizmo will be added to */
  41324. gizmoLayer?: UtilityLayerRenderer);
  41325. private _tempVector;
  41326. /**
  41327. * @hidden
  41328. * Updates the gizmo to match the attached mesh's position/rotation
  41329. */
  41330. protected _update(): void;
  41331. /**
  41332. * Disposes of the gizmo
  41333. */
  41334. dispose(): void;
  41335. }
  41336. }
  41337. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41338. import { Observable } from "babylonjs/Misc/observable";
  41339. import { Nullable } from "babylonjs/types";
  41340. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41341. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41343. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41344. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41345. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41346. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41347. import { Scene } from "babylonjs/scene";
  41348. /**
  41349. * Single axis drag gizmo
  41350. */
  41351. export class AxisDragGizmo extends Gizmo {
  41352. /**
  41353. * Drag behavior responsible for the gizmos dragging interactions
  41354. */
  41355. dragBehavior: PointerDragBehavior;
  41356. private _pointerObserver;
  41357. /**
  41358. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41359. */
  41360. snapDistance: number;
  41361. /**
  41362. * Event that fires each time the gizmo snaps to a new location.
  41363. * * snapDistance is the the change in distance
  41364. */
  41365. onSnapObservable: Observable<{
  41366. snapDistance: number;
  41367. }>;
  41368. /** @hidden */
  41369. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41370. /** @hidden */
  41371. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41372. /**
  41373. * Creates an AxisDragGizmo
  41374. * @param gizmoLayer The utility layer the gizmo will be added to
  41375. * @param dragAxis The axis which the gizmo will be able to drag on
  41376. * @param color The color of the gizmo
  41377. */
  41378. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41379. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41380. /**
  41381. * Disposes of the gizmo
  41382. */
  41383. dispose(): void;
  41384. }
  41385. }
  41386. declare module "babylonjs/Debug/axesViewer" {
  41387. import { Vector3 } from "babylonjs/Maths/math";
  41388. import { Nullable } from "babylonjs/types";
  41389. import { Scene } from "babylonjs/scene";
  41390. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41391. /**
  41392. * The Axes viewer will show 3 axes in a specific point in space
  41393. */
  41394. export class AxesViewer {
  41395. private _xAxis;
  41396. private _yAxis;
  41397. private _zAxis;
  41398. private _scaleLinesFactor;
  41399. private _instanced;
  41400. /**
  41401. * Gets the hosting scene
  41402. */
  41403. scene: Scene;
  41404. /**
  41405. * Gets or sets a number used to scale line length
  41406. */
  41407. scaleLines: number;
  41408. /** Gets the node hierarchy used to render x-axis */
  41409. readonly xAxis: TransformNode;
  41410. /** Gets the node hierarchy used to render y-axis */
  41411. readonly yAxis: TransformNode;
  41412. /** Gets the node hierarchy used to render z-axis */
  41413. readonly zAxis: TransformNode;
  41414. /**
  41415. * Creates a new AxesViewer
  41416. * @param scene defines the hosting scene
  41417. * @param scaleLines defines a number used to scale line length (1 by default)
  41418. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41419. * @param xAxis defines the node hierarchy used to render the x-axis
  41420. * @param yAxis defines the node hierarchy used to render the y-axis
  41421. * @param zAxis defines the node hierarchy used to render the z-axis
  41422. */
  41423. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41424. /**
  41425. * Force the viewer to update
  41426. * @param position defines the position of the viewer
  41427. * @param xaxis defines the x axis of the viewer
  41428. * @param yaxis defines the y axis of the viewer
  41429. * @param zaxis defines the z axis of the viewer
  41430. */
  41431. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41432. /**
  41433. * Creates an instance of this axes viewer.
  41434. * @returns a new axes viewer with instanced meshes
  41435. */
  41436. createInstance(): AxesViewer;
  41437. /** Releases resources */
  41438. dispose(): void;
  41439. private static _SetRenderingGroupId;
  41440. }
  41441. }
  41442. declare module "babylonjs/Debug/boneAxesViewer" {
  41443. import { Nullable } from "babylonjs/types";
  41444. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41445. import { Vector3 } from "babylonjs/Maths/math";
  41446. import { Mesh } from "babylonjs/Meshes/mesh";
  41447. import { Bone } from "babylonjs/Bones/bone";
  41448. import { Scene } from "babylonjs/scene";
  41449. /**
  41450. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41451. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41452. */
  41453. export class BoneAxesViewer extends AxesViewer {
  41454. /**
  41455. * Gets or sets the target mesh where to display the axes viewer
  41456. */
  41457. mesh: Nullable<Mesh>;
  41458. /**
  41459. * Gets or sets the target bone where to display the axes viewer
  41460. */
  41461. bone: Nullable<Bone>;
  41462. /** Gets current position */
  41463. pos: Vector3;
  41464. /** Gets direction of X axis */
  41465. xaxis: Vector3;
  41466. /** Gets direction of Y axis */
  41467. yaxis: Vector3;
  41468. /** Gets direction of Z axis */
  41469. zaxis: Vector3;
  41470. /**
  41471. * Creates a new BoneAxesViewer
  41472. * @param scene defines the hosting scene
  41473. * @param bone defines the target bone
  41474. * @param mesh defines the target mesh
  41475. * @param scaleLines defines a scaling factor for line length (1 by default)
  41476. */
  41477. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41478. /**
  41479. * Force the viewer to update
  41480. */
  41481. update(): void;
  41482. /** Releases resources */
  41483. dispose(): void;
  41484. }
  41485. }
  41486. declare module "babylonjs/Debug/debugLayer" {
  41487. import { Observable } from "babylonjs/Misc/observable";
  41488. import { Scene } from "babylonjs/scene";
  41489. /**
  41490. * Interface used to define scene explorer extensibility option
  41491. */
  41492. export interface IExplorerExtensibilityOption {
  41493. /**
  41494. * Define the option label
  41495. */
  41496. label: string;
  41497. /**
  41498. * Defines the action to execute on click
  41499. */
  41500. action: (entity: any) => void;
  41501. }
  41502. /**
  41503. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41504. */
  41505. export interface IExplorerExtensibilityGroup {
  41506. /**
  41507. * Defines a predicate to test if a given type mut be extended
  41508. */
  41509. predicate: (entity: any) => boolean;
  41510. /**
  41511. * Gets the list of options added to a type
  41512. */
  41513. entries: IExplorerExtensibilityOption[];
  41514. }
  41515. /**
  41516. * Interface used to define the options to use to create the Inspector
  41517. */
  41518. export interface IInspectorOptions {
  41519. /**
  41520. * Display in overlay mode (default: false)
  41521. */
  41522. overlay?: boolean;
  41523. /**
  41524. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41525. */
  41526. globalRoot?: HTMLElement;
  41527. /**
  41528. * Display the Scene explorer
  41529. */
  41530. showExplorer?: boolean;
  41531. /**
  41532. * Display the property inspector
  41533. */
  41534. showInspector?: boolean;
  41535. /**
  41536. * Display in embed mode (both panes on the right)
  41537. */
  41538. embedMode?: boolean;
  41539. /**
  41540. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41541. */
  41542. handleResize?: boolean;
  41543. /**
  41544. * Allow the panes to popup (default: true)
  41545. */
  41546. enablePopup?: boolean;
  41547. /**
  41548. * Allow the panes to be closed by users (default: true)
  41549. */
  41550. enableClose?: boolean;
  41551. /**
  41552. * Optional list of extensibility entries
  41553. */
  41554. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41555. /**
  41556. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41557. */
  41558. inspectorURL?: string;
  41559. }
  41560. module "babylonjs/scene" {
  41561. interface Scene {
  41562. /**
  41563. * @hidden
  41564. * Backing field
  41565. */
  41566. _debugLayer: DebugLayer;
  41567. /**
  41568. * Gets the debug layer (aka Inspector) associated with the scene
  41569. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41570. */
  41571. debugLayer: DebugLayer;
  41572. }
  41573. }
  41574. /**
  41575. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41576. * what is happening in your scene
  41577. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41578. */
  41579. export class DebugLayer {
  41580. /**
  41581. * Define the url to get the inspector script from.
  41582. * By default it uses the babylonjs CDN.
  41583. * @ignoreNaming
  41584. */
  41585. static InspectorURL: string;
  41586. private _scene;
  41587. private BJSINSPECTOR;
  41588. /**
  41589. * Observable triggered when a property is changed through the inspector.
  41590. */
  41591. onPropertyChangedObservable: Observable<{
  41592. object: any;
  41593. property: string;
  41594. value: any;
  41595. initialValue: any;
  41596. }>;
  41597. /**
  41598. * Instantiates a new debug layer.
  41599. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41600. * what is happening in your scene
  41601. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41602. * @param scene Defines the scene to inspect
  41603. */
  41604. constructor(scene: Scene);
  41605. /** Creates the inspector window. */
  41606. private _createInspector;
  41607. /**
  41608. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41609. * @param entity defines the entity to select
  41610. * @param lineContainerTitle defines the specific block to highlight
  41611. */
  41612. select(entity: any, lineContainerTitle?: string): void;
  41613. /** Get the inspector from bundle or global */
  41614. private _getGlobalInspector;
  41615. /**
  41616. * Get if the inspector is visible or not.
  41617. * @returns true if visible otherwise, false
  41618. */
  41619. isVisible(): boolean;
  41620. /**
  41621. * Hide the inspector and close its window.
  41622. */
  41623. hide(): void;
  41624. /**
  41625. * Launch the debugLayer.
  41626. * @param config Define the configuration of the inspector
  41627. * @return a promise fulfilled when the debug layer is visible
  41628. */
  41629. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41630. }
  41631. }
  41632. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41633. import { Nullable } from "babylonjs/types";
  41634. import { Scene } from "babylonjs/scene";
  41635. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41636. import { Mesh } from "babylonjs/Meshes/mesh";
  41637. /**
  41638. * Class containing static functions to help procedurally build meshes
  41639. */
  41640. export class BoxBuilder {
  41641. /**
  41642. * Creates a box mesh
  41643. * * The parameter `size` sets the size (float) of each box side (default 1)
  41644. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41645. * * 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)
  41646. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41650. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  41655. */
  41656. static CreateBox(name: string, options: {
  41657. size?: number;
  41658. width?: number;
  41659. height?: number;
  41660. depth?: number;
  41661. faceUV?: Vector4[];
  41662. faceColors?: Color4[];
  41663. sideOrientation?: number;
  41664. frontUVs?: Vector4;
  41665. backUVs?: Vector4;
  41666. updatable?: boolean;
  41667. }, scene?: Nullable<Scene>): Mesh;
  41668. }
  41669. }
  41670. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41671. import { Vector4 } from "babylonjs/Maths/math";
  41672. import { Mesh } from "babylonjs/Meshes/mesh";
  41673. /**
  41674. * Class containing static functions to help procedurally build meshes
  41675. */
  41676. export class SphereBuilder {
  41677. /**
  41678. * Creates a sphere mesh
  41679. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41680. * * 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`)
  41681. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41682. * * 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
  41683. * * 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)
  41684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41687. * @param name defines the name of the mesh
  41688. * @param options defines the options used to create the mesh
  41689. * @param scene defines the hosting scene
  41690. * @returns the sphere mesh
  41691. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41692. */
  41693. static CreateSphere(name: string, options: {
  41694. segments?: number;
  41695. diameter?: number;
  41696. diameterX?: number;
  41697. diameterY?: number;
  41698. diameterZ?: number;
  41699. arc?: number;
  41700. slice?: number;
  41701. sideOrientation?: number;
  41702. frontUVs?: Vector4;
  41703. backUVs?: Vector4;
  41704. updatable?: boolean;
  41705. }, scene: any): Mesh;
  41706. }
  41707. }
  41708. declare module "babylonjs/Debug/physicsViewer" {
  41709. import { Nullable } from "babylonjs/types";
  41710. import { Scene } from "babylonjs/scene";
  41711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41712. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41713. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41714. /**
  41715. * Used to show the physics impostor around the specific mesh
  41716. */
  41717. export class PhysicsViewer {
  41718. /** @hidden */
  41719. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41720. /** @hidden */
  41721. protected _meshes: Array<Nullable<AbstractMesh>>;
  41722. /** @hidden */
  41723. protected _scene: Nullable<Scene>;
  41724. /** @hidden */
  41725. protected _numMeshes: number;
  41726. /** @hidden */
  41727. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41728. private _renderFunction;
  41729. private _utilityLayer;
  41730. private _debugBoxMesh;
  41731. private _debugSphereMesh;
  41732. private _debugMaterial;
  41733. /**
  41734. * Creates a new PhysicsViewer
  41735. * @param scene defines the hosting scene
  41736. */
  41737. constructor(scene: Scene);
  41738. /** @hidden */
  41739. protected _updateDebugMeshes(): void;
  41740. /**
  41741. * Renders a specified physic impostor
  41742. * @param impostor defines the impostor to render
  41743. * @returns the new debug mesh used to render the impostor
  41744. */
  41745. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41746. /**
  41747. * Hides a specified physic impostor
  41748. * @param impostor defines the impostor to hide
  41749. */
  41750. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41751. private _getDebugMaterial;
  41752. private _getDebugBoxMesh;
  41753. private _getDebugSphereMesh;
  41754. private _getDebugMesh;
  41755. /** Releases all resources */
  41756. dispose(): void;
  41757. }
  41758. }
  41759. declare module "babylonjs/Debug/rayHelper" {
  41760. import { Nullable } from "babylonjs/types";
  41761. import { Ray } from "babylonjs/Culling/ray";
  41762. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41763. import { Scene } from "babylonjs/scene";
  41764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41765. import "babylonjs/Meshes/Builders/linesBuilder";
  41766. /**
  41767. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41768. * in order to better appreciate the issue one might have.
  41769. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41770. */
  41771. export class RayHelper {
  41772. /**
  41773. * Defines the ray we are currently tryin to visualize.
  41774. */
  41775. ray: Nullable<Ray>;
  41776. private _renderPoints;
  41777. private _renderLine;
  41778. private _renderFunction;
  41779. private _scene;
  41780. private _updateToMeshFunction;
  41781. private _attachedToMesh;
  41782. private _meshSpaceDirection;
  41783. private _meshSpaceOrigin;
  41784. /**
  41785. * Helper function to create a colored helper in a scene in one line.
  41786. * @param ray Defines the ray we are currently tryin to visualize
  41787. * @param scene Defines the scene the ray is used in
  41788. * @param color Defines the color we want to see the ray in
  41789. * @returns The newly created ray helper.
  41790. */
  41791. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41792. /**
  41793. * Instantiate a new ray helper.
  41794. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41795. * in order to better appreciate the issue one might have.
  41796. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41797. * @param ray Defines the ray we are currently tryin to visualize
  41798. */
  41799. constructor(ray: Ray);
  41800. /**
  41801. * Shows the ray we are willing to debug.
  41802. * @param scene Defines the scene the ray needs to be rendered in
  41803. * @param color Defines the color the ray needs to be rendered in
  41804. */
  41805. show(scene: Scene, color?: Color3): void;
  41806. /**
  41807. * Hides the ray we are debugging.
  41808. */
  41809. hide(): void;
  41810. private _render;
  41811. /**
  41812. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41813. * @param mesh Defines the mesh we want the helper attached to
  41814. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41815. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41816. * @param length Defines the length of the ray
  41817. */
  41818. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41819. /**
  41820. * Detach the ray helper from the mesh it has previously been attached to.
  41821. */
  41822. detachFromMesh(): void;
  41823. private _updateToMesh;
  41824. /**
  41825. * Dispose the helper and release its associated resources.
  41826. */
  41827. dispose(): void;
  41828. }
  41829. }
  41830. declare module "babylonjs/Debug/skeletonViewer" {
  41831. import { Color3 } from "babylonjs/Maths/math";
  41832. import { Scene } from "babylonjs/scene";
  41833. import { Nullable } from "babylonjs/types";
  41834. import { Skeleton } from "babylonjs/Bones/skeleton";
  41835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41836. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41837. /**
  41838. * Class used to render a debug view of a given skeleton
  41839. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41840. */
  41841. export class SkeletonViewer {
  41842. /** defines the skeleton to render */
  41843. skeleton: Skeleton;
  41844. /** defines the mesh attached to the skeleton */
  41845. mesh: AbstractMesh;
  41846. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41847. autoUpdateBonesMatrices: boolean;
  41848. /** defines the rendering group id to use with the viewer */
  41849. renderingGroupId: number;
  41850. /** Gets or sets the color used to render the skeleton */
  41851. color: Color3;
  41852. private _scene;
  41853. private _debugLines;
  41854. private _debugMesh;
  41855. private _isEnabled;
  41856. private _renderFunction;
  41857. private _utilityLayer;
  41858. /**
  41859. * Returns the mesh used to render the bones
  41860. */
  41861. readonly debugMesh: Nullable<LinesMesh>;
  41862. /**
  41863. * Creates a new SkeletonViewer
  41864. * @param skeleton defines the skeleton to render
  41865. * @param mesh defines the mesh attached to the skeleton
  41866. * @param scene defines the hosting scene
  41867. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41868. * @param renderingGroupId defines the rendering group id to use with the viewer
  41869. */
  41870. constructor(
  41871. /** defines the skeleton to render */
  41872. skeleton: Skeleton,
  41873. /** defines the mesh attached to the skeleton */
  41874. mesh: AbstractMesh, scene: Scene,
  41875. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41876. autoUpdateBonesMatrices?: boolean,
  41877. /** defines the rendering group id to use with the viewer */
  41878. renderingGroupId?: number);
  41879. /** Gets or sets a boolean indicating if the viewer is enabled */
  41880. isEnabled: boolean;
  41881. private _getBonePosition;
  41882. private _getLinesForBonesWithLength;
  41883. private _getLinesForBonesNoLength;
  41884. /** Update the viewer to sync with current skeleton state */
  41885. update(): void;
  41886. /** Release associated resources */
  41887. dispose(): void;
  41888. }
  41889. }
  41890. declare module "babylonjs/Debug/index" {
  41891. export * from "babylonjs/Debug/axesViewer";
  41892. export * from "babylonjs/Debug/boneAxesViewer";
  41893. export * from "babylonjs/Debug/debugLayer";
  41894. export * from "babylonjs/Debug/physicsViewer";
  41895. export * from "babylonjs/Debug/rayHelper";
  41896. export * from "babylonjs/Debug/skeletonViewer";
  41897. }
  41898. declare module "babylonjs/Engines/nullEngine" {
  41899. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41900. import { Scene } from "babylonjs/scene";
  41901. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41902. import { Engine } from "babylonjs/Engines/engine";
  41903. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41904. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41905. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41906. import { Effect } from "babylonjs/Materials/effect";
  41907. /**
  41908. * Options to create the null engine
  41909. */
  41910. export class NullEngineOptions {
  41911. /**
  41912. * Render width (Default: 512)
  41913. */
  41914. renderWidth: number;
  41915. /**
  41916. * Render height (Default: 256)
  41917. */
  41918. renderHeight: number;
  41919. /**
  41920. * Texture size (Default: 512)
  41921. */
  41922. textureSize: number;
  41923. /**
  41924. * If delta time between frames should be constant
  41925. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41926. */
  41927. deterministicLockstep: boolean;
  41928. /**
  41929. * Maximum about of steps between frames (Default: 4)
  41930. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41931. */
  41932. lockstepMaxSteps: number;
  41933. }
  41934. /**
  41935. * The null engine class provides support for headless version of babylon.js.
  41936. * This can be used in server side scenario or for testing purposes
  41937. */
  41938. export class NullEngine extends Engine {
  41939. private _options;
  41940. /**
  41941. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41942. */
  41943. isDeterministicLockStep(): boolean;
  41944. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41945. getLockstepMaxSteps(): number;
  41946. /**
  41947. * Sets hardware scaling, used to save performance if needed
  41948. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41949. */
  41950. getHardwareScalingLevel(): number;
  41951. constructor(options?: NullEngineOptions);
  41952. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41953. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41954. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41955. getRenderWidth(useScreen?: boolean): number;
  41956. getRenderHeight(useScreen?: boolean): number;
  41957. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41958. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41959. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41960. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41961. bindSamplers(effect: Effect): void;
  41962. enableEffect(effect: Effect): void;
  41963. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41964. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41965. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41966. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41967. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41968. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41969. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41970. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41971. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41972. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41973. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41974. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41975. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41976. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41977. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41978. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41979. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41980. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41981. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41982. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41983. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41984. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41985. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41986. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41987. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41988. bindBuffers(vertexBuffers: {
  41989. [key: string]: VertexBuffer;
  41990. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41991. wipeCaches(bruteForce?: boolean): void;
  41992. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41993. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41994. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41995. /** @hidden */
  41996. _createTexture(): WebGLTexture;
  41997. /** @hidden */
  41998. _releaseTexture(texture: InternalTexture): void;
  41999. 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;
  42000. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42001. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42002. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42003. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42004. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42005. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42006. areAllEffectsReady(): boolean;
  42007. /**
  42008. * @hidden
  42009. * Get the current error code of the webGL context
  42010. * @returns the error code
  42011. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42012. */
  42013. getError(): number;
  42014. /** @hidden */
  42015. _getUnpackAlignement(): number;
  42016. /** @hidden */
  42017. _unpackFlipY(value: boolean): void;
  42018. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42019. /**
  42020. * Updates a dynamic vertex buffer.
  42021. * @param vertexBuffer the vertex buffer to update
  42022. * @param data the data used to update the vertex buffer
  42023. * @param byteOffset the byte offset of the data (optional)
  42024. * @param byteLength the byte length of the data (optional)
  42025. */
  42026. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42027. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42028. /** @hidden */
  42029. _bindTexture(channel: number, texture: InternalTexture): void;
  42030. /** @hidden */
  42031. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42032. releaseEffects(): void;
  42033. displayLoadingUI(): void;
  42034. hideLoadingUI(): void;
  42035. /** @hidden */
  42036. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42037. /** @hidden */
  42038. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42039. /** @hidden */
  42040. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42041. /** @hidden */
  42042. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42043. }
  42044. }
  42045. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42046. import { Nullable, int } from "babylonjs/types";
  42047. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42048. /** @hidden */
  42049. export class _OcclusionDataStorage {
  42050. /** @hidden */
  42051. occlusionInternalRetryCounter: number;
  42052. /** @hidden */
  42053. isOcclusionQueryInProgress: boolean;
  42054. /** @hidden */
  42055. isOccluded: boolean;
  42056. /** @hidden */
  42057. occlusionRetryCount: number;
  42058. /** @hidden */
  42059. occlusionType: number;
  42060. /** @hidden */
  42061. occlusionQueryAlgorithmType: number;
  42062. }
  42063. module "babylonjs/Engines/engine" {
  42064. interface Engine {
  42065. /**
  42066. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42067. * @return the new query
  42068. */
  42069. createQuery(): WebGLQuery;
  42070. /**
  42071. * Delete and release a webGL query
  42072. * @param query defines the query to delete
  42073. * @return the current engine
  42074. */
  42075. deleteQuery(query: WebGLQuery): Engine;
  42076. /**
  42077. * Check if a given query has resolved and got its value
  42078. * @param query defines the query to check
  42079. * @returns true if the query got its value
  42080. */
  42081. isQueryResultAvailable(query: WebGLQuery): boolean;
  42082. /**
  42083. * Gets the value of a given query
  42084. * @param query defines the query to check
  42085. * @returns the value of the query
  42086. */
  42087. getQueryResult(query: WebGLQuery): number;
  42088. /**
  42089. * Initiates an occlusion query
  42090. * @param algorithmType defines the algorithm to use
  42091. * @param query defines the query to use
  42092. * @returns the current engine
  42093. * @see http://doc.babylonjs.com/features/occlusionquery
  42094. */
  42095. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42096. /**
  42097. * Ends an occlusion query
  42098. * @see http://doc.babylonjs.com/features/occlusionquery
  42099. * @param algorithmType defines the algorithm to use
  42100. * @returns the current engine
  42101. */
  42102. endOcclusionQuery(algorithmType: number): Engine;
  42103. /**
  42104. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42105. * Please note that only one query can be issued at a time
  42106. * @returns a time token used to track the time span
  42107. */
  42108. startTimeQuery(): Nullable<_TimeToken>;
  42109. /**
  42110. * Ends a time query
  42111. * @param token defines the token used to measure the time span
  42112. * @returns the time spent (in ns)
  42113. */
  42114. endTimeQuery(token: _TimeToken): int;
  42115. /** @hidden */
  42116. _currentNonTimestampToken: Nullable<_TimeToken>;
  42117. /** @hidden */
  42118. _createTimeQuery(): WebGLQuery;
  42119. /** @hidden */
  42120. _deleteTimeQuery(query: WebGLQuery): void;
  42121. /** @hidden */
  42122. _getGlAlgorithmType(algorithmType: number): number;
  42123. /** @hidden */
  42124. _getTimeQueryResult(query: WebGLQuery): any;
  42125. /** @hidden */
  42126. _getTimeQueryAvailability(query: WebGLQuery): any;
  42127. }
  42128. }
  42129. module "babylonjs/Meshes/abstractMesh" {
  42130. interface AbstractMesh {
  42131. /**
  42132. * Backing filed
  42133. * @hidden
  42134. */
  42135. __occlusionDataStorage: _OcclusionDataStorage;
  42136. /**
  42137. * Access property
  42138. * @hidden
  42139. */
  42140. _occlusionDataStorage: _OcclusionDataStorage;
  42141. /**
  42142. * 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.
  42143. * The default value is -1 which means don't break the query and wait till the result
  42144. * @see http://doc.babylonjs.com/features/occlusionquery
  42145. */
  42146. occlusionRetryCount: number;
  42147. /**
  42148. * 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:
  42149. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42150. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42151. * * 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.
  42152. * @see http://doc.babylonjs.com/features/occlusionquery
  42153. */
  42154. occlusionType: number;
  42155. /**
  42156. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42157. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42158. * * 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.
  42159. * @see http://doc.babylonjs.com/features/occlusionquery
  42160. */
  42161. occlusionQueryAlgorithmType: number;
  42162. /**
  42163. * 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
  42164. * @see http://doc.babylonjs.com/features/occlusionquery
  42165. */
  42166. isOccluded: boolean;
  42167. /**
  42168. * Flag to check the progress status of the query
  42169. * @see http://doc.babylonjs.com/features/occlusionquery
  42170. */
  42171. isOcclusionQueryInProgress: boolean;
  42172. }
  42173. }
  42174. }
  42175. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42176. import { Nullable } from "babylonjs/types";
  42177. /** @hidden */
  42178. export var _forceTransformFeedbackToBundle: boolean;
  42179. module "babylonjs/Engines/engine" {
  42180. interface Engine {
  42181. /**
  42182. * Creates a webGL transform feedback object
  42183. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42184. * @returns the webGL transform feedback object
  42185. */
  42186. createTransformFeedback(): WebGLTransformFeedback;
  42187. /**
  42188. * Delete a webGL transform feedback object
  42189. * @param value defines the webGL transform feedback object to delete
  42190. */
  42191. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42192. /**
  42193. * Bind a webGL transform feedback object to the webgl context
  42194. * @param value defines the webGL transform feedback object to bind
  42195. */
  42196. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42197. /**
  42198. * Begins a transform feedback operation
  42199. * @param usePoints defines if points or triangles must be used
  42200. */
  42201. beginTransformFeedback(usePoints: boolean): void;
  42202. /**
  42203. * Ends a transform feedback operation
  42204. */
  42205. endTransformFeedback(): void;
  42206. /**
  42207. * Specify the varyings to use with transform feedback
  42208. * @param program defines the associated webGL program
  42209. * @param value defines the list of strings representing the varying names
  42210. */
  42211. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42212. /**
  42213. * Bind a webGL buffer for a transform feedback operation
  42214. * @param value defines the webGL buffer to bind
  42215. */
  42216. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42217. }
  42218. }
  42219. }
  42220. declare module "babylonjs/Engines/Extensions/index" {
  42221. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42222. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42223. }
  42224. declare module "babylonjs/Engines/index" {
  42225. export * from "babylonjs/Engines/constants";
  42226. export * from "babylonjs/Engines/engine";
  42227. export * from "babylonjs/Engines/engineStore";
  42228. export * from "babylonjs/Engines/nullEngine";
  42229. export * from "babylonjs/Engines/Extensions/index";
  42230. }
  42231. declare module "babylonjs/Events/clipboardEvents" {
  42232. /**
  42233. * Gather the list of clipboard event types as constants.
  42234. */
  42235. export class ClipboardEventTypes {
  42236. /**
  42237. * The clipboard event is fired when a copy command is active (pressed).
  42238. */
  42239. static readonly COPY: number;
  42240. /**
  42241. * The clipboard event is fired when a cut command is active (pressed).
  42242. */
  42243. static readonly CUT: number;
  42244. /**
  42245. * The clipboard event is fired when a paste command is active (pressed).
  42246. */
  42247. static readonly PASTE: number;
  42248. }
  42249. /**
  42250. * This class is used to store clipboard related info for the onClipboardObservable event.
  42251. */
  42252. export class ClipboardInfo {
  42253. /**
  42254. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42255. */
  42256. type: number;
  42257. /**
  42258. * Defines the related dom event
  42259. */
  42260. event: ClipboardEvent;
  42261. /**
  42262. *Creates an instance of ClipboardInfo.
  42263. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42264. * @param event Defines the related dom event
  42265. */
  42266. constructor(
  42267. /**
  42268. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42269. */
  42270. type: number,
  42271. /**
  42272. * Defines the related dom event
  42273. */
  42274. event: ClipboardEvent);
  42275. /**
  42276. * Get the clipboard event's type from the keycode.
  42277. * @param keyCode Defines the keyCode for the current keyboard event.
  42278. * @return {number}
  42279. */
  42280. static GetTypeFromCharacter(keyCode: number): number;
  42281. }
  42282. }
  42283. declare module "babylonjs/Events/index" {
  42284. export * from "babylonjs/Events/keyboardEvents";
  42285. export * from "babylonjs/Events/pointerEvents";
  42286. export * from "babylonjs/Events/clipboardEvents";
  42287. }
  42288. declare module "babylonjs/Loading/sceneLoader" {
  42289. import { Observable } from "babylonjs/Misc/observable";
  42290. import { Nullable } from "babylonjs/types";
  42291. import { Scene } from "babylonjs/scene";
  42292. import { Engine } from "babylonjs/Engines/engine";
  42293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42294. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42295. import { AssetContainer } from "babylonjs/assetContainer";
  42296. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42297. import { Skeleton } from "babylonjs/Bones/skeleton";
  42298. /**
  42299. * Class used to represent data loading progression
  42300. */
  42301. export class SceneLoaderProgressEvent {
  42302. /** defines if data length to load can be evaluated */
  42303. readonly lengthComputable: boolean;
  42304. /** defines the loaded data length */
  42305. readonly loaded: number;
  42306. /** defines the data length to load */
  42307. readonly total: number;
  42308. /**
  42309. * Create a new progress event
  42310. * @param lengthComputable defines if data length to load can be evaluated
  42311. * @param loaded defines the loaded data length
  42312. * @param total defines the data length to load
  42313. */
  42314. constructor(
  42315. /** defines if data length to load can be evaluated */
  42316. lengthComputable: boolean,
  42317. /** defines the loaded data length */
  42318. loaded: number,
  42319. /** defines the data length to load */
  42320. total: number);
  42321. /**
  42322. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42323. * @param event defines the source event
  42324. * @returns a new SceneLoaderProgressEvent
  42325. */
  42326. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42327. }
  42328. /**
  42329. * Interface used by SceneLoader plugins to define supported file extensions
  42330. */
  42331. export interface ISceneLoaderPluginExtensions {
  42332. /**
  42333. * Defines the list of supported extensions
  42334. */
  42335. [extension: string]: {
  42336. isBinary: boolean;
  42337. };
  42338. }
  42339. /**
  42340. * Interface used by SceneLoader plugin factory
  42341. */
  42342. export interface ISceneLoaderPluginFactory {
  42343. /**
  42344. * Defines the name of the factory
  42345. */
  42346. name: string;
  42347. /**
  42348. * Function called to create a new plugin
  42349. * @return the new plugin
  42350. */
  42351. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42352. /**
  42353. * Boolean indicating if the plugin can direct load specific data
  42354. */
  42355. canDirectLoad?: (data: string) => boolean;
  42356. }
  42357. /**
  42358. * Interface used to define a SceneLoader plugin
  42359. */
  42360. export interface ISceneLoaderPlugin {
  42361. /**
  42362. * The friendly name of this plugin.
  42363. */
  42364. name: string;
  42365. /**
  42366. * The file extensions supported by this plugin.
  42367. */
  42368. extensions: string | ISceneLoaderPluginExtensions;
  42369. /**
  42370. * Import meshes into a scene.
  42371. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42372. * @param scene The scene to import into
  42373. * @param data The data to import
  42374. * @param rootUrl The root url for scene and resources
  42375. * @param meshes The meshes array to import into
  42376. * @param particleSystems The particle systems array to import into
  42377. * @param skeletons The skeletons array to import into
  42378. * @param onError The callback when import fails
  42379. * @returns True if successful or false otherwise
  42380. */
  42381. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42382. /**
  42383. * Load into a scene.
  42384. * @param scene The scene to load into
  42385. * @param data The data to import
  42386. * @param rootUrl The root url for scene and resources
  42387. * @param onError The callback when import fails
  42388. * @returns true if successful or false otherwise
  42389. */
  42390. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42391. /**
  42392. * The callback that returns true if the data can be directly loaded.
  42393. */
  42394. canDirectLoad?: (data: string) => boolean;
  42395. /**
  42396. * The callback that allows custom handling of the root url based on the response url.
  42397. */
  42398. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42399. /**
  42400. * Load into an asset container.
  42401. * @param scene The scene to load into
  42402. * @param data The data to import
  42403. * @param rootUrl The root url for scene and resources
  42404. * @param onError The callback when import fails
  42405. * @returns The loaded asset container
  42406. */
  42407. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42408. }
  42409. /**
  42410. * Interface used to define an async SceneLoader plugin
  42411. */
  42412. export interface ISceneLoaderPluginAsync {
  42413. /**
  42414. * The friendly name of this plugin.
  42415. */
  42416. name: string;
  42417. /**
  42418. * The file extensions supported by this plugin.
  42419. */
  42420. extensions: string | ISceneLoaderPluginExtensions;
  42421. /**
  42422. * Import meshes into a scene.
  42423. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42424. * @param scene The scene to import into
  42425. * @param data The data to import
  42426. * @param rootUrl The root url for scene and resources
  42427. * @param onProgress The callback when the load progresses
  42428. * @param fileName Defines the name of the file to load
  42429. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42430. */
  42431. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42432. meshes: AbstractMesh[];
  42433. particleSystems: IParticleSystem[];
  42434. skeletons: Skeleton[];
  42435. animationGroups: AnimationGroup[];
  42436. }>;
  42437. /**
  42438. * Load into a scene.
  42439. * @param scene The scene to load into
  42440. * @param data The data to import
  42441. * @param rootUrl The root url for scene and resources
  42442. * @param onProgress The callback when the load progresses
  42443. * @param fileName Defines the name of the file to load
  42444. * @returns Nothing
  42445. */
  42446. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42447. /**
  42448. * The callback that returns true if the data can be directly loaded.
  42449. */
  42450. canDirectLoad?: (data: string) => boolean;
  42451. /**
  42452. * The callback that allows custom handling of the root url based on the response url.
  42453. */
  42454. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42455. /**
  42456. * Load into an asset container.
  42457. * @param scene The scene to load into
  42458. * @param data The data to import
  42459. * @param rootUrl The root url for scene and resources
  42460. * @param onProgress The callback when the load progresses
  42461. * @param fileName Defines the name of the file to load
  42462. * @returns The loaded asset container
  42463. */
  42464. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42465. }
  42466. /**
  42467. * Class used to load scene from various file formats using registered plugins
  42468. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42469. */
  42470. export class SceneLoader {
  42471. /**
  42472. * No logging while loading
  42473. */
  42474. static readonly NO_LOGGING: number;
  42475. /**
  42476. * Minimal logging while loading
  42477. */
  42478. static readonly MINIMAL_LOGGING: number;
  42479. /**
  42480. * Summary logging while loading
  42481. */
  42482. static readonly SUMMARY_LOGGING: number;
  42483. /**
  42484. * Detailled logging while loading
  42485. */
  42486. static readonly DETAILED_LOGGING: number;
  42487. /**
  42488. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42489. */
  42490. static ForceFullSceneLoadingForIncremental: boolean;
  42491. /**
  42492. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42493. */
  42494. static ShowLoadingScreen: boolean;
  42495. /**
  42496. * Defines the current logging level (while loading the scene)
  42497. * @ignorenaming
  42498. */
  42499. static loggingLevel: number;
  42500. /**
  42501. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42502. */
  42503. static CleanBoneMatrixWeights: boolean;
  42504. /**
  42505. * Event raised when a plugin is used to load a scene
  42506. */
  42507. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42508. private static _registeredPlugins;
  42509. private static _getDefaultPlugin;
  42510. private static _getPluginForExtension;
  42511. private static _getPluginForDirectLoad;
  42512. private static _getPluginForFilename;
  42513. private static _getDirectLoad;
  42514. private static _loadData;
  42515. private static _getFileInfo;
  42516. /**
  42517. * Gets a plugin that can load the given extension
  42518. * @param extension defines the extension to load
  42519. * @returns a plugin or null if none works
  42520. */
  42521. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42522. /**
  42523. * Gets a boolean indicating that the given extension can be loaded
  42524. * @param extension defines the extension to load
  42525. * @returns true if the extension is supported
  42526. */
  42527. static IsPluginForExtensionAvailable(extension: string): boolean;
  42528. /**
  42529. * Adds a new plugin to the list of registered plugins
  42530. * @param plugin defines the plugin to add
  42531. */
  42532. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42533. /**
  42534. * Import meshes into a scene
  42535. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42536. * @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)
  42537. * @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)
  42538. * @param scene the instance of BABYLON.Scene to append to
  42539. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42540. * @param onProgress a callback with a progress event for each file being loaded
  42541. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42542. * @param pluginExtension the extension used to determine the plugin
  42543. * @returns The loaded plugin
  42544. */
  42545. 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>;
  42546. /**
  42547. * Import meshes into a scene
  42548. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42549. * @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)
  42550. * @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)
  42551. * @param scene the instance of BABYLON.Scene to append to
  42552. * @param onProgress a callback with a progress event for each file being loaded
  42553. * @param pluginExtension the extension used to determine the plugin
  42554. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42555. */
  42556. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42557. meshes: AbstractMesh[];
  42558. particleSystems: IParticleSystem[];
  42559. skeletons: Skeleton[];
  42560. animationGroups: AnimationGroup[];
  42561. }>;
  42562. /**
  42563. * Load a scene
  42564. * @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)
  42565. * @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)
  42566. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42567. * @param onSuccess a callback with the scene when import succeeds
  42568. * @param onProgress a callback with a progress event for each file being loaded
  42569. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42570. * @param pluginExtension the extension used to determine the plugin
  42571. * @returns The loaded plugin
  42572. */
  42573. 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>;
  42574. /**
  42575. * Load a scene
  42576. * @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)
  42577. * @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)
  42578. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42579. * @param onProgress a callback with a progress event for each file being loaded
  42580. * @param pluginExtension the extension used to determine the plugin
  42581. * @returns The loaded scene
  42582. */
  42583. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42584. /**
  42585. * Append a scene
  42586. * @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)
  42587. * @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)
  42588. * @param scene is the instance of BABYLON.Scene to append to
  42589. * @param onSuccess a callback with the scene when import succeeds
  42590. * @param onProgress a callback with a progress event for each file being loaded
  42591. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42592. * @param pluginExtension the extension used to determine the plugin
  42593. * @returns The loaded plugin
  42594. */
  42595. 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>;
  42596. /**
  42597. * Append a scene
  42598. * @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)
  42599. * @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)
  42600. * @param scene is the instance of BABYLON.Scene to append to
  42601. * @param onProgress a callback with a progress event for each file being loaded
  42602. * @param pluginExtension the extension used to determine the plugin
  42603. * @returns The given scene
  42604. */
  42605. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42606. /**
  42607. * Load a scene into an asset container
  42608. * @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)
  42609. * @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)
  42610. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42611. * @param onSuccess a callback with the scene when import succeeds
  42612. * @param onProgress a callback with a progress event for each file being loaded
  42613. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42614. * @param pluginExtension the extension used to determine the plugin
  42615. * @returns The loaded plugin
  42616. */
  42617. 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>;
  42618. /**
  42619. * Load a scene into an asset container
  42620. * @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)
  42621. * @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)
  42622. * @param scene is the instance of Scene to append to
  42623. * @param onProgress a callback with a progress event for each file being loaded
  42624. * @param pluginExtension the extension used to determine the plugin
  42625. * @returns The loaded asset container
  42626. */
  42627. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42628. }
  42629. }
  42630. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42631. import { Scene } from "babylonjs/scene";
  42632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42633. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42634. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42635. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42636. /**
  42637. * Google Daydream controller
  42638. */
  42639. export class DaydreamController extends WebVRController {
  42640. /**
  42641. * Base Url for the controller model.
  42642. */
  42643. static MODEL_BASE_URL: string;
  42644. /**
  42645. * File name for the controller model.
  42646. */
  42647. static MODEL_FILENAME: string;
  42648. /**
  42649. * Gamepad Id prefix used to identify Daydream Controller.
  42650. */
  42651. static readonly GAMEPAD_ID_PREFIX: string;
  42652. /**
  42653. * Creates a new DaydreamController from a gamepad
  42654. * @param vrGamepad the gamepad that the controller should be created from
  42655. */
  42656. constructor(vrGamepad: any);
  42657. /**
  42658. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42659. * @param scene scene in which to add meshes
  42660. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42661. */
  42662. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42663. /**
  42664. * Called once for each button that changed state since the last frame
  42665. * @param buttonIdx Which button index changed
  42666. * @param state New state of the button
  42667. * @param changes Which properties on the state changed since last frame
  42668. */
  42669. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42670. }
  42671. }
  42672. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42673. import { Scene } from "babylonjs/scene";
  42674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42675. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42676. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42677. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42678. /**
  42679. * Gear VR Controller
  42680. */
  42681. export class GearVRController extends WebVRController {
  42682. /**
  42683. * Base Url for the controller model.
  42684. */
  42685. static MODEL_BASE_URL: string;
  42686. /**
  42687. * File name for the controller model.
  42688. */
  42689. static MODEL_FILENAME: string;
  42690. /**
  42691. * Gamepad Id prefix used to identify this controller.
  42692. */
  42693. static readonly GAMEPAD_ID_PREFIX: string;
  42694. private readonly _buttonIndexToObservableNameMap;
  42695. /**
  42696. * Creates a new GearVRController from a gamepad
  42697. * @param vrGamepad the gamepad that the controller should be created from
  42698. */
  42699. constructor(vrGamepad: any);
  42700. /**
  42701. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42702. * @param scene scene in which to add meshes
  42703. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42704. */
  42705. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42706. /**
  42707. * Called once for each button that changed state since the last frame
  42708. * @param buttonIdx Which button index changed
  42709. * @param state New state of the button
  42710. * @param changes Which properties on the state changed since last frame
  42711. */
  42712. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42713. }
  42714. }
  42715. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42716. import { Scene } from "babylonjs/scene";
  42717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42718. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42719. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42720. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42721. /**
  42722. * Generic Controller
  42723. */
  42724. export class GenericController extends WebVRController {
  42725. /**
  42726. * Base Url for the controller model.
  42727. */
  42728. static readonly MODEL_BASE_URL: string;
  42729. /**
  42730. * File name for the controller model.
  42731. */
  42732. static readonly MODEL_FILENAME: string;
  42733. /**
  42734. * Creates a new GenericController from a gamepad
  42735. * @param vrGamepad the gamepad that the controller should be created from
  42736. */
  42737. constructor(vrGamepad: any);
  42738. /**
  42739. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42740. * @param scene scene in which to add meshes
  42741. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42742. */
  42743. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42744. /**
  42745. * Called once for each button that changed state since the last frame
  42746. * @param buttonIdx Which button index changed
  42747. * @param state New state of the button
  42748. * @param changes Which properties on the state changed since last frame
  42749. */
  42750. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42751. }
  42752. }
  42753. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42754. import { Observable } from "babylonjs/Misc/observable";
  42755. import { Scene } from "babylonjs/scene";
  42756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42757. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42758. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42759. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42760. /**
  42761. * Oculus Touch Controller
  42762. */
  42763. export class OculusTouchController extends WebVRController {
  42764. /**
  42765. * Base Url for the controller model.
  42766. */
  42767. static MODEL_BASE_URL: string;
  42768. /**
  42769. * File name for the left controller model.
  42770. */
  42771. static MODEL_LEFT_FILENAME: string;
  42772. /**
  42773. * File name for the right controller model.
  42774. */
  42775. static MODEL_RIGHT_FILENAME: string;
  42776. /**
  42777. * Fired when the secondary trigger on this controller is modified
  42778. */
  42779. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42780. /**
  42781. * Fired when the thumb rest on this controller is modified
  42782. */
  42783. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42784. /**
  42785. * Creates a new OculusTouchController from a gamepad
  42786. * @param vrGamepad the gamepad that the controller should be created from
  42787. */
  42788. constructor(vrGamepad: any);
  42789. /**
  42790. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42791. * @param scene scene in which to add meshes
  42792. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42793. */
  42794. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42795. /**
  42796. * Fired when the A button on this controller is modified
  42797. */
  42798. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42799. /**
  42800. * Fired when the B button on this controller is modified
  42801. */
  42802. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42803. /**
  42804. * Fired when the X button on this controller is modified
  42805. */
  42806. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42807. /**
  42808. * Fired when the Y button on this controller is modified
  42809. */
  42810. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42811. /**
  42812. * Called once for each button that changed state since the last frame
  42813. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42814. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42815. * 2) secondary trigger (same)
  42816. * 3) A (right) X (left), touch, pressed = value
  42817. * 4) B / Y
  42818. * 5) thumb rest
  42819. * @param buttonIdx Which button index changed
  42820. * @param state New state of the button
  42821. * @param changes Which properties on the state changed since last frame
  42822. */
  42823. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42824. }
  42825. }
  42826. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42827. import { Scene } from "babylonjs/scene";
  42828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42829. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42830. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42831. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42832. import { Observable } from "babylonjs/Misc/observable";
  42833. /**
  42834. * Vive Controller
  42835. */
  42836. export class ViveController extends WebVRController {
  42837. /**
  42838. * Base Url for the controller model.
  42839. */
  42840. static MODEL_BASE_URL: string;
  42841. /**
  42842. * File name for the controller model.
  42843. */
  42844. static MODEL_FILENAME: string;
  42845. /**
  42846. * Creates a new ViveController from a gamepad
  42847. * @param vrGamepad the gamepad that the controller should be created from
  42848. */
  42849. constructor(vrGamepad: any);
  42850. /**
  42851. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42852. * @param scene scene in which to add meshes
  42853. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42854. */
  42855. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42856. /**
  42857. * Fired when the left button on this controller is modified
  42858. */
  42859. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42860. /**
  42861. * Fired when the right button on this controller is modified
  42862. */
  42863. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42864. /**
  42865. * Fired when the menu button on this controller is modified
  42866. */
  42867. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42868. /**
  42869. * Called once for each button that changed state since the last frame
  42870. * Vive mapping:
  42871. * 0: touchpad
  42872. * 1: trigger
  42873. * 2: left AND right buttons
  42874. * 3: menu button
  42875. * @param buttonIdx Which button index changed
  42876. * @param state New state of the button
  42877. * @param changes Which properties on the state changed since last frame
  42878. */
  42879. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42880. }
  42881. }
  42882. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42883. import { Observable } from "babylonjs/Misc/observable";
  42884. import { Scene } from "babylonjs/scene";
  42885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42886. import { Ray } from "babylonjs/Culling/ray";
  42887. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42888. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42889. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42890. /**
  42891. * Defines the WindowsMotionController object that the state of the windows motion controller
  42892. */
  42893. export class WindowsMotionController extends WebVRController {
  42894. /**
  42895. * The base url used to load the left and right controller models
  42896. */
  42897. static MODEL_BASE_URL: string;
  42898. /**
  42899. * The name of the left controller model file
  42900. */
  42901. static MODEL_LEFT_FILENAME: string;
  42902. /**
  42903. * The name of the right controller model file
  42904. */
  42905. static MODEL_RIGHT_FILENAME: string;
  42906. /**
  42907. * The controller name prefix for this controller type
  42908. */
  42909. static readonly GAMEPAD_ID_PREFIX: string;
  42910. /**
  42911. * The controller id pattern for this controller type
  42912. */
  42913. private static readonly GAMEPAD_ID_PATTERN;
  42914. private _loadedMeshInfo;
  42915. private readonly _mapping;
  42916. /**
  42917. * Fired when the trackpad on this controller is clicked
  42918. */
  42919. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42920. /**
  42921. * Fired when the trackpad on this controller is modified
  42922. */
  42923. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42924. /**
  42925. * The current x and y values of this controller's trackpad
  42926. */
  42927. trackpad: StickValues;
  42928. /**
  42929. * Creates a new WindowsMotionController from a gamepad
  42930. * @param vrGamepad the gamepad that the controller should be created from
  42931. */
  42932. constructor(vrGamepad: any);
  42933. /**
  42934. * Fired when the trigger on this controller is modified
  42935. */
  42936. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42937. /**
  42938. * Fired when the menu button on this controller is modified
  42939. */
  42940. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42941. /**
  42942. * Fired when the grip button on this controller is modified
  42943. */
  42944. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42945. /**
  42946. * Fired when the thumbstick button on this controller is modified
  42947. */
  42948. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42949. /**
  42950. * Fired when the touchpad button on this controller is modified
  42951. */
  42952. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42953. /**
  42954. * Fired when the touchpad values on this controller are modified
  42955. */
  42956. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42957. private _updateTrackpad;
  42958. /**
  42959. * Called once per frame by the engine.
  42960. */
  42961. update(): void;
  42962. /**
  42963. * Called once for each button that changed state since the last frame
  42964. * @param buttonIdx Which button index changed
  42965. * @param state New state of the button
  42966. * @param changes Which properties on the state changed since last frame
  42967. */
  42968. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42969. /**
  42970. * Moves the buttons on the controller mesh based on their current state
  42971. * @param buttonName the name of the button to move
  42972. * @param buttonValue the value of the button which determines the buttons new position
  42973. */
  42974. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42975. /**
  42976. * Moves the axis on the controller mesh based on its current state
  42977. * @param axis the index of the axis
  42978. * @param axisValue the value of the axis which determines the meshes new position
  42979. * @hidden
  42980. */
  42981. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42982. /**
  42983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42984. * @param scene scene in which to add meshes
  42985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42986. */
  42987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42988. /**
  42989. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42990. * can be transformed by button presses and axes values, based on this._mapping.
  42991. *
  42992. * @param scene scene in which the meshes exist
  42993. * @param meshes list of meshes that make up the controller model to process
  42994. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42995. */
  42996. private processModel;
  42997. private createMeshInfo;
  42998. /**
  42999. * Gets the ray of the controller in the direction the controller is pointing
  43000. * @param length the length the resulting ray should be
  43001. * @returns a ray in the direction the controller is pointing
  43002. */
  43003. getForwardRay(length?: number): Ray;
  43004. /**
  43005. * Disposes of the controller
  43006. */
  43007. dispose(): void;
  43008. }
  43009. }
  43010. declare module "babylonjs/Gamepads/Controllers/index" {
  43011. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43012. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43013. export * from "babylonjs/Gamepads/Controllers/genericController";
  43014. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43015. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43016. export * from "babylonjs/Gamepads/Controllers/viveController";
  43017. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43018. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43019. }
  43020. declare module "babylonjs/Gamepads/index" {
  43021. export * from "babylonjs/Gamepads/Controllers/index";
  43022. export * from "babylonjs/Gamepads/gamepad";
  43023. export * from "babylonjs/Gamepads/gamepadManager";
  43024. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43025. export * from "babylonjs/Gamepads/xboxGamepad";
  43026. }
  43027. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43028. import { Observable } from "babylonjs/Misc/observable";
  43029. import { Nullable } from "babylonjs/types";
  43030. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43032. import { Mesh } from "babylonjs/Meshes/mesh";
  43033. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43034. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43035. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43036. /**
  43037. * Single axis scale gizmo
  43038. */
  43039. export class AxisScaleGizmo extends Gizmo {
  43040. private _coloredMaterial;
  43041. /**
  43042. * Drag behavior responsible for the gizmos dragging interactions
  43043. */
  43044. dragBehavior: PointerDragBehavior;
  43045. private _pointerObserver;
  43046. /**
  43047. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43048. */
  43049. snapDistance: number;
  43050. /**
  43051. * Event that fires each time the gizmo snaps to a new location.
  43052. * * snapDistance is the the change in distance
  43053. */
  43054. onSnapObservable: Observable<{
  43055. snapDistance: number;
  43056. }>;
  43057. /**
  43058. * If the scaling operation should be done on all axis (default: false)
  43059. */
  43060. uniformScaling: boolean;
  43061. /**
  43062. * Creates an AxisScaleGizmo
  43063. * @param gizmoLayer The utility layer the gizmo will be added to
  43064. * @param dragAxis The axis which the gizmo will be able to scale on
  43065. * @param color The color of the gizmo
  43066. */
  43067. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43068. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43069. /**
  43070. * Disposes of the gizmo
  43071. */
  43072. dispose(): void;
  43073. /**
  43074. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43075. * @param mesh The mesh to replace the default mesh of the gizmo
  43076. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43077. */
  43078. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43079. }
  43080. }
  43081. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43082. import { Observable } from "babylonjs/Misc/observable";
  43083. import { Nullable } from "babylonjs/types";
  43084. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43086. import { Mesh } from "babylonjs/Meshes/mesh";
  43087. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43088. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43089. import "babylonjs/Meshes/Builders/boxBuilder";
  43090. /**
  43091. * Bounding box gizmo
  43092. */
  43093. export class BoundingBoxGizmo extends Gizmo {
  43094. private _lineBoundingBox;
  43095. private _rotateSpheresParent;
  43096. private _scaleBoxesParent;
  43097. private _boundingDimensions;
  43098. private _renderObserver;
  43099. private _pointerObserver;
  43100. private _scaleDragSpeed;
  43101. private _tmpQuaternion;
  43102. private _tmpVector;
  43103. private _tmpRotationMatrix;
  43104. /**
  43105. * 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)
  43106. */
  43107. ignoreChildren: boolean;
  43108. /**
  43109. * 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)
  43110. */
  43111. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43112. /**
  43113. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43114. */
  43115. rotationSphereSize: number;
  43116. /**
  43117. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43118. */
  43119. scaleBoxSize: number;
  43120. /**
  43121. * 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)
  43122. */
  43123. fixedDragMeshScreenSize: boolean;
  43124. /**
  43125. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43126. */
  43127. fixedDragMeshScreenSizeDistanceFactor: number;
  43128. /**
  43129. * Fired when a rotation sphere or scale box is dragged
  43130. */
  43131. onDragStartObservable: Observable<{}>;
  43132. /**
  43133. * Fired when a scale box is dragged
  43134. */
  43135. onScaleBoxDragObservable: Observable<{}>;
  43136. /**
  43137. * Fired when a scale box drag is ended
  43138. */
  43139. onScaleBoxDragEndObservable: Observable<{}>;
  43140. /**
  43141. * Fired when a rotation sphere is dragged
  43142. */
  43143. onRotationSphereDragObservable: Observable<{}>;
  43144. /**
  43145. * Fired when a rotation sphere drag is ended
  43146. */
  43147. onRotationSphereDragEndObservable: Observable<{}>;
  43148. /**
  43149. * 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)
  43150. */
  43151. scalePivot: Nullable<Vector3>;
  43152. private _anchorMesh;
  43153. private _existingMeshScale;
  43154. private _dragMesh;
  43155. private pointerDragBehavior;
  43156. private coloredMaterial;
  43157. private hoverColoredMaterial;
  43158. /**
  43159. * Sets the color of the bounding box gizmo
  43160. * @param color the color to set
  43161. */
  43162. setColor(color: Color3): void;
  43163. /**
  43164. * Creates an BoundingBoxGizmo
  43165. * @param gizmoLayer The utility layer the gizmo will be added to
  43166. * @param color The color of the gizmo
  43167. */
  43168. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43169. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43170. private _selectNode;
  43171. /**
  43172. * Updates the bounding box information for the Gizmo
  43173. */
  43174. updateBoundingBox(): void;
  43175. private _updateRotationSpheres;
  43176. private _updateScaleBoxes;
  43177. /**
  43178. * Enables rotation on the specified axis and disables rotation on the others
  43179. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43180. */
  43181. setEnabledRotationAxis(axis: string): void;
  43182. /**
  43183. * Enables/disables scaling
  43184. * @param enable if scaling should be enabled
  43185. */
  43186. setEnabledScaling(enable: boolean): void;
  43187. private _updateDummy;
  43188. /**
  43189. * Enables a pointer drag behavior on the bounding box of the gizmo
  43190. */
  43191. enableDragBehavior(): void;
  43192. /**
  43193. * Disposes of the gizmo
  43194. */
  43195. dispose(): void;
  43196. /**
  43197. * 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)
  43198. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43199. * @returns the bounding box mesh with the passed in mesh as a child
  43200. */
  43201. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43202. /**
  43203. * CustomMeshes are not supported by this gizmo
  43204. * @param mesh The mesh to replace the default mesh of the gizmo
  43205. */
  43206. setCustomMesh(mesh: Mesh): void;
  43207. }
  43208. }
  43209. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43210. import { Observable } from "babylonjs/Misc/observable";
  43211. import { Nullable } from "babylonjs/types";
  43212. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43214. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43215. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43216. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43217. import "babylonjs/Meshes/Builders/linesBuilder";
  43218. /**
  43219. * Single plane rotation gizmo
  43220. */
  43221. export class PlaneRotationGizmo extends Gizmo {
  43222. /**
  43223. * Drag behavior responsible for the gizmos dragging interactions
  43224. */
  43225. dragBehavior: PointerDragBehavior;
  43226. private _pointerObserver;
  43227. /**
  43228. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43229. */
  43230. snapDistance: number;
  43231. /**
  43232. * Event that fires each time the gizmo snaps to a new location.
  43233. * * snapDistance is the the change in distance
  43234. */
  43235. onSnapObservable: Observable<{
  43236. snapDistance: number;
  43237. }>;
  43238. /**
  43239. * Creates a PlaneRotationGizmo
  43240. * @param gizmoLayer The utility layer the gizmo will be added to
  43241. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43242. * @param color The color of the gizmo
  43243. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43244. */
  43245. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43246. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43247. /**
  43248. * Disposes of the gizmo
  43249. */
  43250. dispose(): void;
  43251. }
  43252. }
  43253. declare module "babylonjs/Gizmos/rotationGizmo" {
  43254. import { Observable } from "babylonjs/Misc/observable";
  43255. import { Nullable } from "babylonjs/types";
  43256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43257. import { Mesh } from "babylonjs/Meshes/mesh";
  43258. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43259. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43260. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43261. /**
  43262. * Gizmo that enables rotating a mesh along 3 axis
  43263. */
  43264. export class RotationGizmo extends Gizmo {
  43265. /**
  43266. * Internal gizmo used for interactions on the x axis
  43267. */
  43268. xGizmo: PlaneRotationGizmo;
  43269. /**
  43270. * Internal gizmo used for interactions on the y axis
  43271. */
  43272. yGizmo: PlaneRotationGizmo;
  43273. /**
  43274. * Internal gizmo used for interactions on the z axis
  43275. */
  43276. zGizmo: PlaneRotationGizmo;
  43277. /** Fires an event when any of it's sub gizmos are dragged */
  43278. onDragStartObservable: Observable<{}>;
  43279. /** Fires an event when any of it's sub gizmos are released from dragging */
  43280. onDragEndObservable: Observable<{}>;
  43281. attachedMesh: Nullable<AbstractMesh>;
  43282. /**
  43283. * Creates a RotationGizmo
  43284. * @param gizmoLayer The utility layer the gizmo will be added to
  43285. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43286. */
  43287. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43288. updateGizmoRotationToMatchAttachedMesh: boolean;
  43289. /**
  43290. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43291. */
  43292. snapDistance: number;
  43293. /**
  43294. * Ratio for the scale of the gizmo (Default: 1)
  43295. */
  43296. scaleRatio: number;
  43297. /**
  43298. * Disposes of the gizmo
  43299. */
  43300. dispose(): void;
  43301. /**
  43302. * CustomMeshes are not supported by this gizmo
  43303. * @param mesh The mesh to replace the default mesh of the gizmo
  43304. */
  43305. setCustomMesh(mesh: Mesh): void;
  43306. }
  43307. }
  43308. declare module "babylonjs/Gizmos/positionGizmo" {
  43309. import { Observable } from "babylonjs/Misc/observable";
  43310. import { Nullable } from "babylonjs/types";
  43311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43312. import { Mesh } from "babylonjs/Meshes/mesh";
  43313. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43314. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43315. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43316. /**
  43317. * Gizmo that enables dragging a mesh along 3 axis
  43318. */
  43319. export class PositionGizmo extends Gizmo {
  43320. /**
  43321. * Internal gizmo used for interactions on the x axis
  43322. */
  43323. xGizmo: AxisDragGizmo;
  43324. /**
  43325. * Internal gizmo used for interactions on the y axis
  43326. */
  43327. yGizmo: AxisDragGizmo;
  43328. /**
  43329. * Internal gizmo used for interactions on the z axis
  43330. */
  43331. zGizmo: AxisDragGizmo;
  43332. /** Fires an event when any of it's sub gizmos are dragged */
  43333. onDragStartObservable: Observable<{}>;
  43334. /** Fires an event when any of it's sub gizmos are released from dragging */
  43335. onDragEndObservable: Observable<{}>;
  43336. attachedMesh: Nullable<AbstractMesh>;
  43337. /**
  43338. * Creates a PositionGizmo
  43339. * @param gizmoLayer The utility layer the gizmo will be added to
  43340. */
  43341. constructor(gizmoLayer?: UtilityLayerRenderer);
  43342. updateGizmoRotationToMatchAttachedMesh: boolean;
  43343. /**
  43344. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43345. */
  43346. snapDistance: number;
  43347. /**
  43348. * Ratio for the scale of the gizmo (Default: 1)
  43349. */
  43350. scaleRatio: number;
  43351. /**
  43352. * Disposes of the gizmo
  43353. */
  43354. dispose(): void;
  43355. /**
  43356. * CustomMeshes are not supported by this gizmo
  43357. * @param mesh The mesh to replace the default mesh of the gizmo
  43358. */
  43359. setCustomMesh(mesh: Mesh): void;
  43360. }
  43361. }
  43362. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43363. import { Scene } from "babylonjs/scene";
  43364. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43365. import { Mesh } from "babylonjs/Meshes/mesh";
  43366. /**
  43367. * Class containing static functions to help procedurally build meshes
  43368. */
  43369. export class PolyhedronBuilder {
  43370. /**
  43371. * Creates a polyhedron mesh
  43372. * * 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
  43373. * * The parameter `size` (positive float, default 1) sets the polygon size
  43374. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43375. * * 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`
  43376. * * 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
  43377. * * 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)`)
  43378. * * 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
  43379. * * 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
  43380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43383. * @param name defines the name of the mesh
  43384. * @param options defines the options used to create the mesh
  43385. * @param scene defines the hosting scene
  43386. * @returns the polyhedron mesh
  43387. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43388. */
  43389. static CreatePolyhedron(name: string, options: {
  43390. type?: number;
  43391. size?: number;
  43392. sizeX?: number;
  43393. sizeY?: number;
  43394. sizeZ?: number;
  43395. custom?: any;
  43396. faceUV?: Vector4[];
  43397. faceColors?: Color4[];
  43398. flat?: boolean;
  43399. updatable?: boolean;
  43400. sideOrientation?: number;
  43401. frontUVs?: Vector4;
  43402. backUVs?: Vector4;
  43403. }, scene: Scene): Mesh;
  43404. }
  43405. }
  43406. declare module "babylonjs/Gizmos/scaleGizmo" {
  43407. import { Observable } from "babylonjs/Misc/observable";
  43408. import { Nullable } from "babylonjs/types";
  43409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43410. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43411. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43412. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43413. /**
  43414. * Gizmo that enables scaling a mesh along 3 axis
  43415. */
  43416. export class ScaleGizmo extends Gizmo {
  43417. /**
  43418. * Internal gizmo used for interactions on the x axis
  43419. */
  43420. xGizmo: AxisScaleGizmo;
  43421. /**
  43422. * Internal gizmo used for interactions on the y axis
  43423. */
  43424. yGizmo: AxisScaleGizmo;
  43425. /**
  43426. * Internal gizmo used for interactions on the z axis
  43427. */
  43428. zGizmo: AxisScaleGizmo;
  43429. /**
  43430. * Internal gizmo used to scale all axis equally
  43431. */
  43432. uniformScaleGizmo: AxisScaleGizmo;
  43433. /** Fires an event when any of it's sub gizmos are dragged */
  43434. onDragStartObservable: Observable<{}>;
  43435. /** Fires an event when any of it's sub gizmos are released from dragging */
  43436. onDragEndObservable: Observable<{}>;
  43437. attachedMesh: Nullable<AbstractMesh>;
  43438. /**
  43439. * Creates a ScaleGizmo
  43440. * @param gizmoLayer The utility layer the gizmo will be added to
  43441. */
  43442. constructor(gizmoLayer?: UtilityLayerRenderer);
  43443. updateGizmoRotationToMatchAttachedMesh: boolean;
  43444. /**
  43445. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43446. */
  43447. snapDistance: number;
  43448. /**
  43449. * Ratio for the scale of the gizmo (Default: 1)
  43450. */
  43451. scaleRatio: number;
  43452. /**
  43453. * Disposes of the gizmo
  43454. */
  43455. dispose(): void;
  43456. }
  43457. }
  43458. declare module "babylonjs/Gizmos/gizmoManager" {
  43459. import { Observable } from "babylonjs/Misc/observable";
  43460. import { Nullable } from "babylonjs/types";
  43461. import { Scene, IDisposable } from "babylonjs/scene";
  43462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43463. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43464. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43465. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43466. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43467. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43468. /**
  43469. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43470. */
  43471. export class GizmoManager implements IDisposable {
  43472. private scene;
  43473. /**
  43474. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43475. */
  43476. gizmos: {
  43477. positionGizmo: Nullable<PositionGizmo>;
  43478. rotationGizmo: Nullable<RotationGizmo>;
  43479. scaleGizmo: Nullable<ScaleGizmo>;
  43480. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43481. };
  43482. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43483. clearGizmoOnEmptyPointerEvent: boolean;
  43484. /** Fires an event when the manager is attached to a mesh */
  43485. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43486. private _gizmosEnabled;
  43487. private _pointerObserver;
  43488. private _attachedMesh;
  43489. private _boundingBoxColor;
  43490. private _defaultUtilityLayer;
  43491. private _defaultKeepDepthUtilityLayer;
  43492. /**
  43493. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43494. */
  43495. boundingBoxDragBehavior: SixDofDragBehavior;
  43496. /**
  43497. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43498. */
  43499. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43500. /**
  43501. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43502. */
  43503. usePointerToAttachGizmos: boolean;
  43504. /**
  43505. * Instatiates a gizmo manager
  43506. * @param scene the scene to overlay the gizmos on top of
  43507. */
  43508. constructor(scene: Scene);
  43509. /**
  43510. * Attaches a set of gizmos to the specified mesh
  43511. * @param mesh The mesh the gizmo's should be attached to
  43512. */
  43513. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43514. /**
  43515. * If the position gizmo is enabled
  43516. */
  43517. positionGizmoEnabled: boolean;
  43518. /**
  43519. * If the rotation gizmo is enabled
  43520. */
  43521. rotationGizmoEnabled: boolean;
  43522. /**
  43523. * If the scale gizmo is enabled
  43524. */
  43525. scaleGizmoEnabled: boolean;
  43526. /**
  43527. * If the boundingBox gizmo is enabled
  43528. */
  43529. boundingBoxGizmoEnabled: boolean;
  43530. /**
  43531. * Disposes of the gizmo manager
  43532. */
  43533. dispose(): void;
  43534. }
  43535. }
  43536. declare module "babylonjs/Gizmos/lightGizmo" {
  43537. import { Nullable } from "babylonjs/types";
  43538. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43539. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43540. import { Light } from "babylonjs/Lights/light";
  43541. /**
  43542. * Gizmo that enables viewing a light
  43543. */
  43544. export class LightGizmo extends Gizmo {
  43545. private _box;
  43546. /**
  43547. * Creates a LightGizmo
  43548. * @param gizmoLayer The utility layer the gizmo will be added to
  43549. */
  43550. constructor(gizmoLayer?: UtilityLayerRenderer);
  43551. private _light;
  43552. /**
  43553. * The light that the gizmo is attached to
  43554. */
  43555. light: Nullable<Light>;
  43556. /**
  43557. * @hidden
  43558. * Updates the gizmo to match the attached mesh's position/rotation
  43559. */
  43560. protected _update(): void;
  43561. }
  43562. }
  43563. declare module "babylonjs/Gizmos/index" {
  43564. export * from "babylonjs/Gizmos/axisDragGizmo";
  43565. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43566. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43567. export * from "babylonjs/Gizmos/gizmo";
  43568. export * from "babylonjs/Gizmos/gizmoManager";
  43569. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43570. export * from "babylonjs/Gizmos/positionGizmo";
  43571. export * from "babylonjs/Gizmos/rotationGizmo";
  43572. export * from "babylonjs/Gizmos/scaleGizmo";
  43573. export * from "babylonjs/Gizmos/lightGizmo";
  43574. }
  43575. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43576. /** @hidden */
  43577. export var backgroundFragmentDeclaration: {
  43578. name: string;
  43579. shader: string;
  43580. };
  43581. }
  43582. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43583. /** @hidden */
  43584. export var backgroundUboDeclaration: {
  43585. name: string;
  43586. shader: string;
  43587. };
  43588. }
  43589. declare module "babylonjs/Shaders/background.fragment" {
  43590. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43591. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43592. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43593. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43594. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43595. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43596. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43597. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43598. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43599. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43600. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43601. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43602. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43603. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43604. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43605. /** @hidden */
  43606. export var backgroundPixelShader: {
  43607. name: string;
  43608. shader: string;
  43609. };
  43610. }
  43611. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43612. /** @hidden */
  43613. export var backgroundVertexDeclaration: {
  43614. name: string;
  43615. shader: string;
  43616. };
  43617. }
  43618. declare module "babylonjs/Shaders/background.vertex" {
  43619. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43620. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43621. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43622. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43623. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43625. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43626. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43627. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43628. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43629. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43630. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43631. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43632. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43633. /** @hidden */
  43634. export var backgroundVertexShader: {
  43635. name: string;
  43636. shader: string;
  43637. };
  43638. }
  43639. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43640. import { Nullable, int, float } from "babylonjs/types";
  43641. import { Scene } from "babylonjs/scene";
  43642. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43645. import { Mesh } from "babylonjs/Meshes/mesh";
  43646. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43647. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43648. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43650. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43651. import "babylonjs/Shaders/background.fragment";
  43652. import "babylonjs/Shaders/background.vertex";
  43653. /**
  43654. * Background material used to create an efficient environement around your scene.
  43655. */
  43656. export class BackgroundMaterial extends PushMaterial {
  43657. /**
  43658. * Standard reflectance value at parallel view angle.
  43659. */
  43660. static StandardReflectance0: number;
  43661. /**
  43662. * Standard reflectance value at grazing angle.
  43663. */
  43664. static StandardReflectance90: number;
  43665. protected _primaryColor: Color3;
  43666. /**
  43667. * Key light Color (multiply against the environement texture)
  43668. */
  43669. primaryColor: Color3;
  43670. protected __perceptualColor: Nullable<Color3>;
  43671. /**
  43672. * Experimental Internal Use Only.
  43673. *
  43674. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43675. * This acts as a helper to set the primary color to a more "human friendly" value.
  43676. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43677. * output color as close as possible from the chosen value.
  43678. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43679. * part of lighting setup.)
  43680. */
  43681. _perceptualColor: Nullable<Color3>;
  43682. protected _primaryColorShadowLevel: float;
  43683. /**
  43684. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43685. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43686. */
  43687. primaryColorShadowLevel: float;
  43688. protected _primaryColorHighlightLevel: float;
  43689. /**
  43690. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43691. * The primary color is used at the level chosen to define what the white area would look.
  43692. */
  43693. primaryColorHighlightLevel: float;
  43694. protected _reflectionTexture: Nullable<BaseTexture>;
  43695. /**
  43696. * Reflection Texture used in the material.
  43697. * Should be author in a specific way for the best result (refer to the documentation).
  43698. */
  43699. reflectionTexture: Nullable<BaseTexture>;
  43700. protected _reflectionBlur: float;
  43701. /**
  43702. * Reflection Texture level of blur.
  43703. *
  43704. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43705. * texture twice.
  43706. */
  43707. reflectionBlur: float;
  43708. protected _diffuseTexture: Nullable<BaseTexture>;
  43709. /**
  43710. * Diffuse Texture used in the material.
  43711. * Should be author in a specific way for the best result (refer to the documentation).
  43712. */
  43713. diffuseTexture: Nullable<BaseTexture>;
  43714. protected _shadowLights: Nullable<IShadowLight[]>;
  43715. /**
  43716. * Specify the list of lights casting shadow on the material.
  43717. * All scene shadow lights will be included if null.
  43718. */
  43719. shadowLights: Nullable<IShadowLight[]>;
  43720. protected _shadowLevel: float;
  43721. /**
  43722. * Helps adjusting the shadow to a softer level if required.
  43723. * 0 means black shadows and 1 means no shadows.
  43724. */
  43725. shadowLevel: float;
  43726. protected _sceneCenter: Vector3;
  43727. /**
  43728. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43729. * It is usually zero but might be interesting to modify according to your setup.
  43730. */
  43731. sceneCenter: Vector3;
  43732. protected _opacityFresnel: boolean;
  43733. /**
  43734. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43735. * This helps ensuring a nice transition when the camera goes under the ground.
  43736. */
  43737. opacityFresnel: boolean;
  43738. protected _reflectionFresnel: boolean;
  43739. /**
  43740. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43741. * This helps adding a mirror texture on the ground.
  43742. */
  43743. reflectionFresnel: boolean;
  43744. protected _reflectionFalloffDistance: number;
  43745. /**
  43746. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43747. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43748. */
  43749. reflectionFalloffDistance: number;
  43750. protected _reflectionAmount: number;
  43751. /**
  43752. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43753. */
  43754. reflectionAmount: number;
  43755. protected _reflectionReflectance0: number;
  43756. /**
  43757. * This specifies the weight of the reflection at grazing angle.
  43758. */
  43759. reflectionReflectance0: number;
  43760. protected _reflectionReflectance90: number;
  43761. /**
  43762. * This specifies the weight of the reflection at a perpendicular point of view.
  43763. */
  43764. reflectionReflectance90: number;
  43765. /**
  43766. * Sets the reflection reflectance fresnel values according to the default standard
  43767. * empirically know to work well :-)
  43768. */
  43769. reflectionStandardFresnelWeight: number;
  43770. protected _useRGBColor: boolean;
  43771. /**
  43772. * Helps to directly use the maps channels instead of their level.
  43773. */
  43774. useRGBColor: boolean;
  43775. protected _enableNoise: boolean;
  43776. /**
  43777. * This helps reducing the banding effect that could occur on the background.
  43778. */
  43779. enableNoise: boolean;
  43780. /**
  43781. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43782. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43783. * Recommended to be keep at 1.0 except for special cases.
  43784. */
  43785. fovMultiplier: number;
  43786. private _fovMultiplier;
  43787. /**
  43788. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43789. */
  43790. useEquirectangularFOV: boolean;
  43791. private _maxSimultaneousLights;
  43792. /**
  43793. * Number of Simultaneous lights allowed on the material.
  43794. */
  43795. maxSimultaneousLights: int;
  43796. /**
  43797. * Default configuration related to image processing available in the Background Material.
  43798. */
  43799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43800. /**
  43801. * Keep track of the image processing observer to allow dispose and replace.
  43802. */
  43803. private _imageProcessingObserver;
  43804. /**
  43805. * Attaches a new image processing configuration to the PBR Material.
  43806. * @param configuration (if null the scene configuration will be use)
  43807. */
  43808. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43809. /**
  43810. * Gets the image processing configuration used either in this material.
  43811. */
  43812. /**
  43813. * Sets the Default image processing configuration used either in the this material.
  43814. *
  43815. * If sets to null, the scene one is in use.
  43816. */
  43817. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43818. /**
  43819. * Gets wether the color curves effect is enabled.
  43820. */
  43821. /**
  43822. * Sets wether the color curves effect is enabled.
  43823. */
  43824. cameraColorCurvesEnabled: boolean;
  43825. /**
  43826. * Gets wether the color grading effect is enabled.
  43827. */
  43828. /**
  43829. * Gets wether the color grading effect is enabled.
  43830. */
  43831. cameraColorGradingEnabled: boolean;
  43832. /**
  43833. * Gets wether tonemapping is enabled or not.
  43834. */
  43835. /**
  43836. * Sets wether tonemapping is enabled or not
  43837. */
  43838. cameraToneMappingEnabled: boolean;
  43839. /**
  43840. * The camera exposure used on this material.
  43841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43842. * This corresponds to a photographic exposure.
  43843. */
  43844. /**
  43845. * The camera exposure used on this material.
  43846. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43847. * This corresponds to a photographic exposure.
  43848. */
  43849. cameraExposure: float;
  43850. /**
  43851. * Gets The camera contrast used on this material.
  43852. */
  43853. /**
  43854. * Sets The camera contrast used on this material.
  43855. */
  43856. cameraContrast: float;
  43857. /**
  43858. * Gets the Color Grading 2D Lookup Texture.
  43859. */
  43860. /**
  43861. * Sets the Color Grading 2D Lookup Texture.
  43862. */
  43863. cameraColorGradingTexture: Nullable<BaseTexture>;
  43864. /**
  43865. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43866. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43867. * 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;
  43868. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43869. */
  43870. /**
  43871. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43872. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43873. * 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;
  43874. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43875. */
  43876. cameraColorCurves: Nullable<ColorCurves>;
  43877. /**
  43878. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43879. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43880. */
  43881. switchToBGR: boolean;
  43882. private _renderTargets;
  43883. private _reflectionControls;
  43884. private _white;
  43885. private _primaryShadowColor;
  43886. private _primaryHighlightColor;
  43887. /**
  43888. * Instantiates a Background Material in the given scene
  43889. * @param name The friendly name of the material
  43890. * @param scene The scene to add the material to
  43891. */
  43892. constructor(name: string, scene: Scene);
  43893. /**
  43894. * Gets a boolean indicating that current material needs to register RTT
  43895. */
  43896. readonly hasRenderTargetTextures: boolean;
  43897. /**
  43898. * The entire material has been created in order to prevent overdraw.
  43899. * @returns false
  43900. */
  43901. needAlphaTesting(): boolean;
  43902. /**
  43903. * The entire material has been created in order to prevent overdraw.
  43904. * @returns true if blending is enable
  43905. */
  43906. needAlphaBlending(): boolean;
  43907. /**
  43908. * Checks wether the material is ready to be rendered for a given mesh.
  43909. * @param mesh The mesh to render
  43910. * @param subMesh The submesh to check against
  43911. * @param useInstances Specify wether or not the material is used with instances
  43912. * @returns true if all the dependencies are ready (Textures, Effects...)
  43913. */
  43914. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43915. /**
  43916. * Compute the primary color according to the chosen perceptual color.
  43917. */
  43918. private _computePrimaryColorFromPerceptualColor;
  43919. /**
  43920. * Compute the highlights and shadow colors according to their chosen levels.
  43921. */
  43922. private _computePrimaryColors;
  43923. /**
  43924. * Build the uniform buffer used in the material.
  43925. */
  43926. buildUniformLayout(): void;
  43927. /**
  43928. * Unbind the material.
  43929. */
  43930. unbind(): void;
  43931. /**
  43932. * Bind only the world matrix to the material.
  43933. * @param world The world matrix to bind.
  43934. */
  43935. bindOnlyWorldMatrix(world: Matrix): void;
  43936. /**
  43937. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43938. * @param world The world matrix to bind.
  43939. * @param subMesh The submesh to bind for.
  43940. */
  43941. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43942. /**
  43943. * Dispose the material.
  43944. * @param forceDisposeEffect Force disposal of the associated effect.
  43945. * @param forceDisposeTextures Force disposal of the associated textures.
  43946. */
  43947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43948. /**
  43949. * Clones the material.
  43950. * @param name The cloned name.
  43951. * @returns The cloned material.
  43952. */
  43953. clone(name: string): BackgroundMaterial;
  43954. /**
  43955. * Serializes the current material to its JSON representation.
  43956. * @returns The JSON representation.
  43957. */
  43958. serialize(): any;
  43959. /**
  43960. * Gets the class name of the material
  43961. * @returns "BackgroundMaterial"
  43962. */
  43963. getClassName(): string;
  43964. /**
  43965. * Parse a JSON input to create back a background material.
  43966. * @param source The JSON data to parse
  43967. * @param scene The scene to create the parsed material in
  43968. * @param rootUrl The root url of the assets the material depends upon
  43969. * @returns the instantiated BackgroundMaterial.
  43970. */
  43971. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43972. }
  43973. }
  43974. declare module "babylonjs/Helpers/environmentHelper" {
  43975. import { Observable } from "babylonjs/Misc/observable";
  43976. import { Nullable } from "babylonjs/types";
  43977. import { Scene } from "babylonjs/scene";
  43978. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43980. import { Mesh } from "babylonjs/Meshes/mesh";
  43981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43982. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43983. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43984. import "babylonjs/Meshes/Builders/planeBuilder";
  43985. import "babylonjs/Meshes/Builders/boxBuilder";
  43986. /**
  43987. * Represents the different options available during the creation of
  43988. * a Environment helper.
  43989. *
  43990. * This can control the default ground, skybox and image processing setup of your scene.
  43991. */
  43992. export interface IEnvironmentHelperOptions {
  43993. /**
  43994. * Specifies wether or not to create a ground.
  43995. * True by default.
  43996. */
  43997. createGround: boolean;
  43998. /**
  43999. * Specifies the ground size.
  44000. * 15 by default.
  44001. */
  44002. groundSize: number;
  44003. /**
  44004. * The texture used on the ground for the main color.
  44005. * Comes from the BabylonJS CDN by default.
  44006. *
  44007. * Remarks: Can be either a texture or a url.
  44008. */
  44009. groundTexture: string | BaseTexture;
  44010. /**
  44011. * The color mixed in the ground texture by default.
  44012. * BabylonJS clearColor by default.
  44013. */
  44014. groundColor: Color3;
  44015. /**
  44016. * Specifies the ground opacity.
  44017. * 1 by default.
  44018. */
  44019. groundOpacity: number;
  44020. /**
  44021. * Enables the ground to receive shadows.
  44022. * True by default.
  44023. */
  44024. enableGroundShadow: boolean;
  44025. /**
  44026. * Helps preventing the shadow to be fully black on the ground.
  44027. * 0.5 by default.
  44028. */
  44029. groundShadowLevel: number;
  44030. /**
  44031. * Creates a mirror texture attach to the ground.
  44032. * false by default.
  44033. */
  44034. enableGroundMirror: boolean;
  44035. /**
  44036. * Specifies the ground mirror size ratio.
  44037. * 0.3 by default as the default kernel is 64.
  44038. */
  44039. groundMirrorSizeRatio: number;
  44040. /**
  44041. * Specifies the ground mirror blur kernel size.
  44042. * 64 by default.
  44043. */
  44044. groundMirrorBlurKernel: number;
  44045. /**
  44046. * Specifies the ground mirror visibility amount.
  44047. * 1 by default
  44048. */
  44049. groundMirrorAmount: number;
  44050. /**
  44051. * Specifies the ground mirror reflectance weight.
  44052. * This uses the standard weight of the background material to setup the fresnel effect
  44053. * of the mirror.
  44054. * 1 by default.
  44055. */
  44056. groundMirrorFresnelWeight: number;
  44057. /**
  44058. * Specifies the ground mirror Falloff distance.
  44059. * This can helps reducing the size of the reflection.
  44060. * 0 by Default.
  44061. */
  44062. groundMirrorFallOffDistance: number;
  44063. /**
  44064. * Specifies the ground mirror texture type.
  44065. * Unsigned Int by Default.
  44066. */
  44067. groundMirrorTextureType: number;
  44068. /**
  44069. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44070. * the shown objects.
  44071. */
  44072. groundYBias: number;
  44073. /**
  44074. * Specifies wether or not to create a skybox.
  44075. * True by default.
  44076. */
  44077. createSkybox: boolean;
  44078. /**
  44079. * Specifies the skybox size.
  44080. * 20 by default.
  44081. */
  44082. skyboxSize: number;
  44083. /**
  44084. * The texture used on the skybox for the main color.
  44085. * Comes from the BabylonJS CDN by default.
  44086. *
  44087. * Remarks: Can be either a texture or a url.
  44088. */
  44089. skyboxTexture: string | BaseTexture;
  44090. /**
  44091. * The color mixed in the skybox texture by default.
  44092. * BabylonJS clearColor by default.
  44093. */
  44094. skyboxColor: Color3;
  44095. /**
  44096. * The background rotation around the Y axis of the scene.
  44097. * This helps aligning the key lights of your scene with the background.
  44098. * 0 by default.
  44099. */
  44100. backgroundYRotation: number;
  44101. /**
  44102. * Compute automatically the size of the elements to best fit with the scene.
  44103. */
  44104. sizeAuto: boolean;
  44105. /**
  44106. * Default position of the rootMesh if autoSize is not true.
  44107. */
  44108. rootPosition: Vector3;
  44109. /**
  44110. * Sets up the image processing in the scene.
  44111. * true by default.
  44112. */
  44113. setupImageProcessing: boolean;
  44114. /**
  44115. * The texture used as your environment texture in the scene.
  44116. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44117. *
  44118. * Remarks: Can be either a texture or a url.
  44119. */
  44120. environmentTexture: string | BaseTexture;
  44121. /**
  44122. * The value of the exposure to apply to the scene.
  44123. * 0.6 by default if setupImageProcessing is true.
  44124. */
  44125. cameraExposure: number;
  44126. /**
  44127. * The value of the contrast to apply to the scene.
  44128. * 1.6 by default if setupImageProcessing is true.
  44129. */
  44130. cameraContrast: number;
  44131. /**
  44132. * Specifies wether or not tonemapping should be enabled in the scene.
  44133. * true by default if setupImageProcessing is true.
  44134. */
  44135. toneMappingEnabled: boolean;
  44136. }
  44137. /**
  44138. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44139. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44140. * It also helps with the default setup of your imageProcessing configuration.
  44141. */
  44142. export class EnvironmentHelper {
  44143. /**
  44144. * Default ground texture URL.
  44145. */
  44146. private static _groundTextureCDNUrl;
  44147. /**
  44148. * Default skybox texture URL.
  44149. */
  44150. private static _skyboxTextureCDNUrl;
  44151. /**
  44152. * Default environment texture URL.
  44153. */
  44154. private static _environmentTextureCDNUrl;
  44155. /**
  44156. * Creates the default options for the helper.
  44157. */
  44158. private static _getDefaultOptions;
  44159. private _rootMesh;
  44160. /**
  44161. * Gets the root mesh created by the helper.
  44162. */
  44163. readonly rootMesh: Mesh;
  44164. private _skybox;
  44165. /**
  44166. * Gets the skybox created by the helper.
  44167. */
  44168. readonly skybox: Nullable<Mesh>;
  44169. private _skyboxTexture;
  44170. /**
  44171. * Gets the skybox texture created by the helper.
  44172. */
  44173. readonly skyboxTexture: Nullable<BaseTexture>;
  44174. private _skyboxMaterial;
  44175. /**
  44176. * Gets the skybox material created by the helper.
  44177. */
  44178. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44179. private _ground;
  44180. /**
  44181. * Gets the ground mesh created by the helper.
  44182. */
  44183. readonly ground: Nullable<Mesh>;
  44184. private _groundTexture;
  44185. /**
  44186. * Gets the ground texture created by the helper.
  44187. */
  44188. readonly groundTexture: Nullable<BaseTexture>;
  44189. private _groundMirror;
  44190. /**
  44191. * Gets the ground mirror created by the helper.
  44192. */
  44193. readonly groundMirror: Nullable<MirrorTexture>;
  44194. /**
  44195. * Gets the ground mirror render list to helps pushing the meshes
  44196. * you wish in the ground reflection.
  44197. */
  44198. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44199. private _groundMaterial;
  44200. /**
  44201. * Gets the ground material created by the helper.
  44202. */
  44203. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44204. /**
  44205. * Stores the creation options.
  44206. */
  44207. private readonly _scene;
  44208. private _options;
  44209. /**
  44210. * This observable will be notified with any error during the creation of the environment,
  44211. * mainly texture creation errors.
  44212. */
  44213. onErrorObservable: Observable<{
  44214. message?: string;
  44215. exception?: any;
  44216. }>;
  44217. /**
  44218. * constructor
  44219. * @param options Defines the options we want to customize the helper
  44220. * @param scene The scene to add the material to
  44221. */
  44222. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44223. /**
  44224. * Updates the background according to the new options
  44225. * @param options
  44226. */
  44227. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44228. /**
  44229. * Sets the primary color of all the available elements.
  44230. * @param color the main color to affect to the ground and the background
  44231. */
  44232. setMainColor(color: Color3): void;
  44233. /**
  44234. * Setup the image processing according to the specified options.
  44235. */
  44236. private _setupImageProcessing;
  44237. /**
  44238. * Setup the environment texture according to the specified options.
  44239. */
  44240. private _setupEnvironmentTexture;
  44241. /**
  44242. * Setup the background according to the specified options.
  44243. */
  44244. private _setupBackground;
  44245. /**
  44246. * Get the scene sizes according to the setup.
  44247. */
  44248. private _getSceneSize;
  44249. /**
  44250. * Setup the ground according to the specified options.
  44251. */
  44252. private _setupGround;
  44253. /**
  44254. * Setup the ground material according to the specified options.
  44255. */
  44256. private _setupGroundMaterial;
  44257. /**
  44258. * Setup the ground diffuse texture according to the specified options.
  44259. */
  44260. private _setupGroundDiffuseTexture;
  44261. /**
  44262. * Setup the ground mirror texture according to the specified options.
  44263. */
  44264. private _setupGroundMirrorTexture;
  44265. /**
  44266. * Setup the ground to receive the mirror texture.
  44267. */
  44268. private _setupMirrorInGroundMaterial;
  44269. /**
  44270. * Setup the skybox according to the specified options.
  44271. */
  44272. private _setupSkybox;
  44273. /**
  44274. * Setup the skybox material according to the specified options.
  44275. */
  44276. private _setupSkyboxMaterial;
  44277. /**
  44278. * Setup the skybox reflection texture according to the specified options.
  44279. */
  44280. private _setupSkyboxReflectionTexture;
  44281. private _errorHandler;
  44282. /**
  44283. * Dispose all the elements created by the Helper.
  44284. */
  44285. dispose(): void;
  44286. }
  44287. }
  44288. declare module "babylonjs/Helpers/photoDome" {
  44289. import { Observable } from "babylonjs/Misc/observable";
  44290. import { Nullable } from "babylonjs/types";
  44291. import { Scene } from "babylonjs/scene";
  44292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44293. import { Mesh } from "babylonjs/Meshes/mesh";
  44294. import { Texture } from "babylonjs/Materials/Textures/texture";
  44295. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44296. import "babylonjs/Meshes/Builders/sphereBuilder";
  44297. /**
  44298. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44299. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44300. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44301. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44302. */
  44303. export class PhotoDome extends TransformNode {
  44304. private _useDirectMapping;
  44305. /**
  44306. * The texture being displayed on the sphere
  44307. */
  44308. protected _photoTexture: Texture;
  44309. /**
  44310. * Gets or sets the texture being displayed on the sphere
  44311. */
  44312. photoTexture: Texture;
  44313. /**
  44314. * Observable raised when an error occured while loading the 360 image
  44315. */
  44316. onLoadErrorObservable: Observable<string>;
  44317. /**
  44318. * The skybox material
  44319. */
  44320. protected _material: BackgroundMaterial;
  44321. /**
  44322. * The surface used for the skybox
  44323. */
  44324. protected _mesh: Mesh;
  44325. /**
  44326. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44327. * Also see the options.resolution property.
  44328. */
  44329. fovMultiplier: number;
  44330. /**
  44331. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44332. * @param name Element's name, child elements will append suffixes for their own names.
  44333. * @param urlsOfPhoto defines the url of the photo to display
  44334. * @param options defines an object containing optional or exposed sub element properties
  44335. * @param onError defines a callback called when an error occured while loading the texture
  44336. */
  44337. constructor(name: string, urlOfPhoto: string, options: {
  44338. resolution?: number;
  44339. size?: number;
  44340. useDirectMapping?: boolean;
  44341. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44342. /**
  44343. * Releases resources associated with this node.
  44344. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44345. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44346. */
  44347. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44348. }
  44349. }
  44350. declare module "babylonjs/Misc/textureTools" {
  44351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44352. import { Texture } from "babylonjs/Materials/Textures/texture";
  44353. import { Scene } from "babylonjs/scene";
  44354. /**
  44355. * Class used to host texture specific utilities
  44356. */
  44357. export class TextureTools {
  44358. /**
  44359. * Uses the GPU to create a copy texture rescaled at a given size
  44360. * @param texture Texture to copy from
  44361. * @param width defines the desired width
  44362. * @param height defines the desired height
  44363. * @param useBilinearMode defines if bilinear mode has to be used
  44364. * @return the generated texture
  44365. */
  44366. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44367. /**
  44368. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44369. * @param scene defines the hosting scene
  44370. * @returns the environment BRDF texture
  44371. */
  44372. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44373. private static _environmentBRDFBase64Texture;
  44374. }
  44375. }
  44376. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44377. import { Nullable } from "babylonjs/types";
  44378. import { IAnimatable } from "babylonjs/Misc/tools";
  44379. import { Color3 } from "babylonjs/Maths/math";
  44380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44381. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44382. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44383. import { Engine } from "babylonjs/Engines/engine";
  44384. import { Scene } from "babylonjs/scene";
  44385. /**
  44386. * @hidden
  44387. */
  44388. export interface IMaterialClearCoatDefines {
  44389. CLEARCOAT: boolean;
  44390. CLEARCOAT_DEFAULTIOR: boolean;
  44391. CLEARCOAT_TEXTURE: boolean;
  44392. CLEARCOAT_TEXTUREDIRECTUV: number;
  44393. CLEARCOAT_BUMP: boolean;
  44394. CLEARCOAT_BUMPDIRECTUV: number;
  44395. CLEARCOAT_TINT: boolean;
  44396. CLEARCOAT_TINT_TEXTURE: boolean;
  44397. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44398. /** @hidden */
  44399. _areTexturesDirty: boolean;
  44400. }
  44401. /**
  44402. * Define the code related to the clear coat parameters of the pbr material.
  44403. */
  44404. export class PBRClearCoatConfiguration {
  44405. /**
  44406. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44407. * The default fits with a polyurethane material.
  44408. */
  44409. private static readonly _DefaultIndiceOfRefraction;
  44410. private _isEnabled;
  44411. /**
  44412. * Defines if the clear coat is enabled in the material.
  44413. */
  44414. isEnabled: boolean;
  44415. /**
  44416. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44417. */
  44418. intensity: number;
  44419. /**
  44420. * Defines the clear coat layer roughness.
  44421. */
  44422. roughness: number;
  44423. private _indiceOfRefraction;
  44424. /**
  44425. * Defines the indice of refraction of the clear coat.
  44426. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44427. * The default fits with a polyurethane material.
  44428. * Changing the default value is more performance intensive.
  44429. */
  44430. indiceOfRefraction: number;
  44431. private _texture;
  44432. /**
  44433. * Stores the clear coat values in a texture.
  44434. */
  44435. texture: Nullable<BaseTexture>;
  44436. private _bumpTexture;
  44437. /**
  44438. * Define the clear coat specific bump texture.
  44439. */
  44440. bumpTexture: Nullable<BaseTexture>;
  44441. private _isTintEnabled;
  44442. /**
  44443. * Defines if the clear coat tint is enabled in the material.
  44444. */
  44445. isTintEnabled: boolean;
  44446. /**
  44447. * Defines if the clear coat tint is enabled in the material.
  44448. * This is only use if tint is enabled
  44449. */
  44450. tintColor: Color3;
  44451. /**
  44452. * Defines if the distance at which the tint color should be found in the
  44453. * clear coat media.
  44454. * This is only use if tint is enabled
  44455. */
  44456. tintColorAtDistance: number;
  44457. /**
  44458. * Defines the clear coat layer thickness.
  44459. * This is only use if tint is enabled
  44460. */
  44461. tintThickness: number;
  44462. private _tintTexture;
  44463. /**
  44464. * Stores the clear tint values in a texture.
  44465. * rgb is tint
  44466. * a is a thickness factor
  44467. */
  44468. tintTexture: Nullable<BaseTexture>;
  44469. /** @hidden */
  44470. private _internalMarkAllSubMeshesAsTexturesDirty;
  44471. /** @hidden */
  44472. _markAllSubMeshesAsTexturesDirty(): void;
  44473. /**
  44474. * Instantiate a new istance of clear coat configuration.
  44475. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44476. */
  44477. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44478. /**
  44479. * Specifies that the submesh is ready to be used.
  44480. * @param defines the list of "defines" to update.
  44481. * @param scene defines the scene the material belongs to.
  44482. * @param engine defines the engine the material belongs to.
  44483. * @param disableBumpMap defines wether the material disables bump or not.
  44484. * @returns - boolean indicating that the submesh is ready or not.
  44485. */
  44486. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44487. /**
  44488. * Checks to see if a texture is used in the material.
  44489. * @param defines the list of "defines" to update.
  44490. * @param scene defines the scene to the material belongs to.
  44491. */
  44492. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44493. /**
  44494. * Binds the material data.
  44495. * @param uniformBuffer defines the Uniform buffer to fill in.
  44496. * @param scene defines the scene the material belongs to.
  44497. * @param engine defines the engine the material belongs to.
  44498. * @param disableBumpMap defines wether the material disables bump or not.
  44499. * @param isFrozen defines wether the material is frozen or not.
  44500. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44501. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44502. */
  44503. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44504. /**
  44505. * Checks to see if a texture is used in the material.
  44506. * @param texture - Base texture to use.
  44507. * @returns - Boolean specifying if a texture is used in the material.
  44508. */
  44509. hasTexture(texture: BaseTexture): boolean;
  44510. /**
  44511. * Returns an array of the actively used textures.
  44512. * @param activeTextures Array of BaseTextures
  44513. */
  44514. getActiveTextures(activeTextures: BaseTexture[]): void;
  44515. /**
  44516. * Returns the animatable textures.
  44517. * @param animatables Array of animatable textures.
  44518. */
  44519. getAnimatables(animatables: IAnimatable[]): void;
  44520. /**
  44521. * Disposes the resources of the material.
  44522. * @param forceDisposeTextures - Forces the disposal of all textures.
  44523. */
  44524. dispose(forceDisposeTextures?: boolean): void;
  44525. /**
  44526. * Get the current class name of the texture useful for serialization or dynamic coding.
  44527. * @returns "PBRClearCoatConfiguration"
  44528. */
  44529. getClassName(): string;
  44530. /**
  44531. * Add fallbacks to the effect fallbacks list.
  44532. * @param defines defines the Base texture to use.
  44533. * @param fallbacks defines the current fallback list.
  44534. * @param currentRank defines the current fallback rank.
  44535. * @returns the new fallback rank.
  44536. */
  44537. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44538. /**
  44539. * Add the required uniforms to the current list.
  44540. * @param uniforms defines the current uniform list.
  44541. */
  44542. static AddUniforms(uniforms: string[]): void;
  44543. /**
  44544. * Add the required samplers to the current list.
  44545. * @param samplers defines the current sampler list.
  44546. */
  44547. static AddSamplers(samplers: string[]): void;
  44548. /**
  44549. * Add the required uniforms to the current buffer.
  44550. * @param uniformBuffer defines the current uniform buffer.
  44551. */
  44552. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44553. /**
  44554. * Makes a duplicate of the current configuration into another one.
  44555. * @param clearCoatConfiguration define the config where to copy the info
  44556. */
  44557. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44558. /**
  44559. * Serializes this clear coat configuration.
  44560. * @returns - An object with the serialized config.
  44561. */
  44562. serialize(): any;
  44563. /**
  44564. * Parses a Clear Coat Configuration from a serialized object.
  44565. * @param source - Serialized object.
  44566. */
  44567. parse(source: any): void;
  44568. }
  44569. }
  44570. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44571. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44572. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44574. import { Vector2 } from "babylonjs/Maths/math";
  44575. import { Scene } from "babylonjs/scene";
  44576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44577. import { IAnimatable } from "babylonjs/Misc/tools";
  44578. import { Nullable } from "babylonjs/types";
  44579. /**
  44580. * @hidden
  44581. */
  44582. export interface IMaterialAnisotropicDefines {
  44583. ANISOTROPIC: boolean;
  44584. ANISOTROPIC_TEXTURE: boolean;
  44585. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44586. MAINUV1: boolean;
  44587. _areTexturesDirty: boolean;
  44588. _needUVs: boolean;
  44589. }
  44590. /**
  44591. * Define the code related to the anisotropic parameters of the pbr material.
  44592. */
  44593. export class PBRAnisotropicConfiguration {
  44594. private _isEnabled;
  44595. /**
  44596. * Defines if the anisotropy is enabled in the material.
  44597. */
  44598. isEnabled: boolean;
  44599. /**
  44600. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44601. */
  44602. intensity: number;
  44603. /**
  44604. * Defines if the effect is along the tangents, bitangents or in between.
  44605. * By default, the effect is "strectching" the highlights along the tangents.
  44606. */
  44607. direction: Vector2;
  44608. private _texture;
  44609. /**
  44610. * Stores the anisotropy values in a texture.
  44611. * rg is direction (like normal from -1 to 1)
  44612. * b is a intensity
  44613. */
  44614. texture: Nullable<BaseTexture>;
  44615. /** @hidden */
  44616. private _internalMarkAllSubMeshesAsTexturesDirty;
  44617. /** @hidden */
  44618. _markAllSubMeshesAsTexturesDirty(): void;
  44619. /**
  44620. * Instantiate a new istance of anisotropy configuration.
  44621. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44622. */
  44623. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44624. /**
  44625. * Specifies that the submesh is ready to be used.
  44626. * @param defines the list of "defines" to update.
  44627. * @param scene defines the scene the material belongs to.
  44628. * @returns - boolean indicating that the submesh is ready or not.
  44629. */
  44630. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44631. /**
  44632. * Checks to see if a texture is used in the material.
  44633. * @param defines the list of "defines" to update.
  44634. * @param mesh the mesh we are preparing the defines for.
  44635. * @param scene defines the scene the material belongs to.
  44636. */
  44637. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44638. /**
  44639. * Binds the material data.
  44640. * @param uniformBuffer defines the Uniform buffer to fill in.
  44641. * @param scene defines the scene the material belongs to.
  44642. * @param isFrozen defines wether the material is frozen or not.
  44643. */
  44644. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44645. /**
  44646. * Checks to see if a texture is used in the material.
  44647. * @param texture - Base texture to use.
  44648. * @returns - Boolean specifying if a texture is used in the material.
  44649. */
  44650. hasTexture(texture: BaseTexture): boolean;
  44651. /**
  44652. * Returns an array of the actively used textures.
  44653. * @param activeTextures Array of BaseTextures
  44654. */
  44655. getActiveTextures(activeTextures: BaseTexture[]): void;
  44656. /**
  44657. * Returns the animatable textures.
  44658. * @param animatables Array of animatable textures.
  44659. */
  44660. getAnimatables(animatables: IAnimatable[]): void;
  44661. /**
  44662. * Disposes the resources of the material.
  44663. * @param forceDisposeTextures - Forces the disposal of all textures.
  44664. */
  44665. dispose(forceDisposeTextures?: boolean): void;
  44666. /**
  44667. * Get the current class name of the texture useful for serialization or dynamic coding.
  44668. * @returns "PBRAnisotropicConfiguration"
  44669. */
  44670. getClassName(): string;
  44671. /**
  44672. * Add fallbacks to the effect fallbacks list.
  44673. * @param defines defines the Base texture to use.
  44674. * @param fallbacks defines the current fallback list.
  44675. * @param currentRank defines the current fallback rank.
  44676. * @returns the new fallback rank.
  44677. */
  44678. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44679. /**
  44680. * Add the required uniforms to the current list.
  44681. * @param uniforms defines the current uniform list.
  44682. */
  44683. static AddUniforms(uniforms: string[]): void;
  44684. /**
  44685. * Add the required uniforms to the current buffer.
  44686. * @param uniformBuffer defines the current uniform buffer.
  44687. */
  44688. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44689. /**
  44690. * Add the required samplers to the current list.
  44691. * @param samplers defines the current sampler list.
  44692. */
  44693. static AddSamplers(samplers: string[]): void;
  44694. /**
  44695. * Makes a duplicate of the current configuration into another one.
  44696. * @param anisotropicConfiguration define the config where to copy the info
  44697. */
  44698. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44699. /**
  44700. * Serializes this anisotropy configuration.
  44701. * @returns - An object with the serialized config.
  44702. */
  44703. serialize(): any;
  44704. /**
  44705. * Parses a anisotropy Configuration from a serialized object.
  44706. * @param source - Serialized object.
  44707. */
  44708. parse(source: any): void;
  44709. }
  44710. }
  44711. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44712. /**
  44713. * @hidden
  44714. */
  44715. export interface IMaterialBRDFDefines {
  44716. BRDF_V_HEIGHT_CORRELATED: boolean;
  44717. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44718. /** @hidden */
  44719. _areMiscDirty: boolean;
  44720. }
  44721. /**
  44722. * Define the code related to the BRDF parameters of the pbr material.
  44723. */
  44724. export class PBRBRDFConfiguration {
  44725. private _useEnergyConservation;
  44726. /**
  44727. * Defines if the material uses energy conservation.
  44728. */
  44729. useEnergyConservation: boolean;
  44730. private _useSmithVisibilityHeightCorrelated;
  44731. /**
  44732. * LEGACY Mode set to false
  44733. * Defines if the material uses height smith correlated visibility term.
  44734. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44735. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44736. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44737. * Not relying on height correlated will also disable energy conservation.
  44738. */
  44739. useSmithVisibilityHeightCorrelated: boolean;
  44740. /** @hidden */
  44741. private _internalMarkAllSubMeshesAsMiscDirty;
  44742. /** @hidden */
  44743. _markAllSubMeshesAsMiscDirty(): void;
  44744. /**
  44745. * Instantiate a new istance of clear coat configuration.
  44746. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44747. */
  44748. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44749. /**
  44750. * Checks to see if a texture is used in the material.
  44751. * @param defines the list of "defines" to update.
  44752. */
  44753. prepareDefines(defines: IMaterialBRDFDefines): void;
  44754. /**
  44755. * Get the current class name of the texture useful for serialization or dynamic coding.
  44756. * @returns "PBRClearCoatConfiguration"
  44757. */
  44758. getClassName(): string;
  44759. /**
  44760. * Makes a duplicate of the current configuration into another one.
  44761. * @param brdfConfiguration define the config where to copy the info
  44762. */
  44763. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44764. /**
  44765. * Serializes this BRDF configuration.
  44766. * @returns - An object with the serialized config.
  44767. */
  44768. serialize(): any;
  44769. /**
  44770. * Parses a BRDF Configuration from a serialized object.
  44771. * @param source - Serialized object.
  44772. */
  44773. parse(source: any): void;
  44774. }
  44775. }
  44776. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44777. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44778. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44779. import { Color3 } from "babylonjs/Maths/math";
  44780. import { Scene } from "babylonjs/scene";
  44781. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44782. import { IAnimatable } from "babylonjs/Misc/tools";
  44783. import { Nullable } from "babylonjs/types";
  44784. /**
  44785. * @hidden
  44786. */
  44787. export interface IMaterialSheenDefines {
  44788. SHEEN: boolean;
  44789. SHEEN_TEXTURE: boolean;
  44790. SHEEN_TEXTUREDIRECTUV: number;
  44791. SHEEN_LINKWITHALBEDO: boolean;
  44792. /** @hidden */
  44793. _areTexturesDirty: boolean;
  44794. }
  44795. /**
  44796. * Define the code related to the Sheen parameters of the pbr material.
  44797. */
  44798. export class PBRSheenConfiguration {
  44799. private _isEnabled;
  44800. /**
  44801. * Defines if the material uses sheen.
  44802. */
  44803. isEnabled: boolean;
  44804. private _linkSheenWithAlbedo;
  44805. /**
  44806. * Defines if the sheen is linked to the sheen color.
  44807. */
  44808. linkSheenWithAlbedo: boolean;
  44809. /**
  44810. * Defines the sheen intensity.
  44811. */
  44812. intensity: number;
  44813. /**
  44814. * Defines the sheen color.
  44815. */
  44816. color: Color3;
  44817. private _texture;
  44818. /**
  44819. * Stores the sheen tint values in a texture.
  44820. * rgb is tint
  44821. * a is a intensity
  44822. */
  44823. texture: Nullable<BaseTexture>;
  44824. /** @hidden */
  44825. private _internalMarkAllSubMeshesAsTexturesDirty;
  44826. /** @hidden */
  44827. _markAllSubMeshesAsTexturesDirty(): void;
  44828. /**
  44829. * Instantiate a new istance of clear coat configuration.
  44830. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44831. */
  44832. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44833. /**
  44834. * Specifies that the submesh is ready to be used.
  44835. * @param defines the list of "defines" to update.
  44836. * @param scene defines the scene the material belongs to.
  44837. * @returns - boolean indicating that the submesh is ready or not.
  44838. */
  44839. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44840. /**
  44841. * Checks to see if a texture is used in the material.
  44842. * @param defines the list of "defines" to update.
  44843. * @param scene defines the scene the material belongs to.
  44844. */
  44845. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44846. /**
  44847. * Binds the material data.
  44848. * @param uniformBuffer defines the Uniform buffer to fill in.
  44849. * @param scene defines the scene the material belongs to.
  44850. * @param isFrozen defines wether the material is frozen or not.
  44851. */
  44852. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44853. /**
  44854. * Checks to see if a texture is used in the material.
  44855. * @param texture - Base texture to use.
  44856. * @returns - Boolean specifying if a texture is used in the material.
  44857. */
  44858. hasTexture(texture: BaseTexture): boolean;
  44859. /**
  44860. * Returns an array of the actively used textures.
  44861. * @param activeTextures Array of BaseTextures
  44862. */
  44863. getActiveTextures(activeTextures: BaseTexture[]): void;
  44864. /**
  44865. * Returns the animatable textures.
  44866. * @param animatables Array of animatable textures.
  44867. */
  44868. getAnimatables(animatables: IAnimatable[]): void;
  44869. /**
  44870. * Disposes the resources of the material.
  44871. * @param forceDisposeTextures - Forces the disposal of all textures.
  44872. */
  44873. dispose(forceDisposeTextures?: boolean): void;
  44874. /**
  44875. * Get the current class name of the texture useful for serialization or dynamic coding.
  44876. * @returns "PBRSheenConfiguration"
  44877. */
  44878. getClassName(): string;
  44879. /**
  44880. * Add fallbacks to the effect fallbacks list.
  44881. * @param defines defines the Base texture to use.
  44882. * @param fallbacks defines the current fallback list.
  44883. * @param currentRank defines the current fallback rank.
  44884. * @returns the new fallback rank.
  44885. */
  44886. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44887. /**
  44888. * Add the required uniforms to the current list.
  44889. * @param uniforms defines the current uniform list.
  44890. */
  44891. static AddUniforms(uniforms: string[]): void;
  44892. /**
  44893. * Add the required uniforms to the current buffer.
  44894. * @param uniformBuffer defines the current uniform buffer.
  44895. */
  44896. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44897. /**
  44898. * Add the required samplers to the current list.
  44899. * @param samplers defines the current sampler list.
  44900. */
  44901. static AddSamplers(samplers: string[]): void;
  44902. /**
  44903. * Makes a duplicate of the current configuration into another one.
  44904. * @param sheenConfiguration define the config where to copy the info
  44905. */
  44906. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44907. /**
  44908. * Serializes this BRDF configuration.
  44909. * @returns - An object with the serialized config.
  44910. */
  44911. serialize(): any;
  44912. /**
  44913. * Parses a Sheen Configuration from a serialized object.
  44914. * @param source - Serialized object.
  44915. */
  44916. parse(source: any): void;
  44917. }
  44918. }
  44919. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44920. /** @hidden */
  44921. export var pbrFragmentDeclaration: {
  44922. name: string;
  44923. shader: string;
  44924. };
  44925. }
  44926. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44927. /** @hidden */
  44928. export var pbrUboDeclaration: {
  44929. name: string;
  44930. shader: string;
  44931. };
  44932. }
  44933. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44934. /** @hidden */
  44935. export var pbrFunctions: {
  44936. name: string;
  44937. shader: string;
  44938. };
  44939. }
  44940. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44941. /** @hidden */
  44942. export var harmonicsFunctions: {
  44943. name: string;
  44944. shader: string;
  44945. };
  44946. }
  44947. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44948. /** @hidden */
  44949. export var pbrPreLightingFunctions: {
  44950. name: string;
  44951. shader: string;
  44952. };
  44953. }
  44954. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44955. /** @hidden */
  44956. export var pbrFalloffLightingFunctions: {
  44957. name: string;
  44958. shader: string;
  44959. };
  44960. }
  44961. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44962. /** @hidden */
  44963. export var pbrLightingFunctions: {
  44964. name: string;
  44965. shader: string;
  44966. };
  44967. }
  44968. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44969. /** @hidden */
  44970. export var pbrDebug: {
  44971. name: string;
  44972. shader: string;
  44973. };
  44974. }
  44975. declare module "babylonjs/Shaders/pbr.fragment" {
  44976. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44977. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44978. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44979. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44980. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44981. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44983. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44984. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44985. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44986. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44987. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44988. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44989. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44990. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44991. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44992. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44993. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44995. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44996. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44997. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44998. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44999. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45000. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45001. /** @hidden */
  45002. export var pbrPixelShader: {
  45003. name: string;
  45004. shader: string;
  45005. };
  45006. }
  45007. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45008. /** @hidden */
  45009. export var pbrVertexDeclaration: {
  45010. name: string;
  45011. shader: string;
  45012. };
  45013. }
  45014. declare module "babylonjs/Shaders/pbr.vertex" {
  45015. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45016. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45017. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45018. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45019. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45020. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45021. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45022. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45023. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45025. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45026. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45028. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45029. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45030. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45031. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45032. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45033. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45034. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45035. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45036. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45037. /** @hidden */
  45038. export var pbrVertexShader: {
  45039. name: string;
  45040. shader: string;
  45041. };
  45042. }
  45043. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45044. import { IAnimatable } from "babylonjs/Misc/tools";
  45045. import { Nullable } from "babylonjs/types";
  45046. import { Scene } from "babylonjs/scene";
  45047. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45048. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45050. import { Mesh } from "babylonjs/Meshes/mesh";
  45051. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45052. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45053. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45054. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45055. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45056. import { Material } from "babylonjs/Materials/material";
  45057. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45058. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45059. import "babylonjs/Shaders/pbr.fragment";
  45060. import "babylonjs/Shaders/pbr.vertex";
  45061. /**
  45062. * The Physically based material base class of BJS.
  45063. *
  45064. * This offers the main features of a standard PBR material.
  45065. * For more information, please refer to the documentation :
  45066. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45067. */
  45068. export abstract class PBRBaseMaterial extends PushMaterial {
  45069. /**
  45070. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45071. */
  45072. static readonly PBRMATERIAL_OPAQUE: number;
  45073. /**
  45074. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45075. */
  45076. static readonly PBRMATERIAL_ALPHATEST: number;
  45077. /**
  45078. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45079. */
  45080. static readonly PBRMATERIAL_ALPHABLEND: number;
  45081. /**
  45082. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45083. * They are also discarded below the alpha cutoff threshold to improve performances.
  45084. */
  45085. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45086. /**
  45087. * Defines the default value of how much AO map is occluding the analytical lights
  45088. * (point spot...).
  45089. */
  45090. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45091. /**
  45092. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45093. */
  45094. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45095. /**
  45096. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45097. * to enhance interoperability with other engines.
  45098. */
  45099. static readonly LIGHTFALLOFF_GLTF: number;
  45100. /**
  45101. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45102. * to enhance interoperability with other materials.
  45103. */
  45104. static readonly LIGHTFALLOFF_STANDARD: number;
  45105. /**
  45106. * Intensity of the direct lights e.g. the four lights available in your scene.
  45107. * This impacts both the direct diffuse and specular highlights.
  45108. */
  45109. protected _directIntensity: number;
  45110. /**
  45111. * Intensity of the emissive part of the material.
  45112. * This helps controlling the emissive effect without modifying the emissive color.
  45113. */
  45114. protected _emissiveIntensity: number;
  45115. /**
  45116. * Intensity of the environment e.g. how much the environment will light the object
  45117. * either through harmonics for rough material or through the refelction for shiny ones.
  45118. */
  45119. protected _environmentIntensity: number;
  45120. /**
  45121. * This is a special control allowing the reduction of the specular highlights coming from the
  45122. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45123. */
  45124. protected _specularIntensity: number;
  45125. /**
  45126. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45127. */
  45128. private _lightingInfos;
  45129. /**
  45130. * Debug Control allowing disabling the bump map on this material.
  45131. */
  45132. protected _disableBumpMap: boolean;
  45133. /**
  45134. * AKA Diffuse Texture in standard nomenclature.
  45135. */
  45136. protected _albedoTexture: BaseTexture;
  45137. /**
  45138. * AKA Occlusion Texture in other nomenclature.
  45139. */
  45140. protected _ambientTexture: BaseTexture;
  45141. /**
  45142. * AKA Occlusion Texture Intensity in other nomenclature.
  45143. */
  45144. protected _ambientTextureStrength: number;
  45145. /**
  45146. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45147. * 1 means it completely occludes it
  45148. * 0 mean it has no impact
  45149. */
  45150. protected _ambientTextureImpactOnAnalyticalLights: number;
  45151. /**
  45152. * Stores the alpha values in a texture.
  45153. */
  45154. protected _opacityTexture: BaseTexture;
  45155. /**
  45156. * Stores the reflection values in a texture.
  45157. */
  45158. protected _reflectionTexture: BaseTexture;
  45159. /**
  45160. * Stores the refraction values in a texture.
  45161. */
  45162. protected _refractionTexture: BaseTexture;
  45163. /**
  45164. * Stores the emissive values in a texture.
  45165. */
  45166. protected _emissiveTexture: BaseTexture;
  45167. /**
  45168. * AKA Specular texture in other nomenclature.
  45169. */
  45170. protected _reflectivityTexture: BaseTexture;
  45171. /**
  45172. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45173. */
  45174. protected _metallicTexture: BaseTexture;
  45175. /**
  45176. * Specifies the metallic scalar of the metallic/roughness workflow.
  45177. * Can also be used to scale the metalness values of the metallic texture.
  45178. */
  45179. protected _metallic: Nullable<number>;
  45180. /**
  45181. * Specifies the roughness scalar of the metallic/roughness workflow.
  45182. * Can also be used to scale the roughness values of the metallic texture.
  45183. */
  45184. protected _roughness: Nullable<number>;
  45185. /**
  45186. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45187. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45188. */
  45189. protected _microSurfaceTexture: BaseTexture;
  45190. /**
  45191. * Stores surface normal data used to displace a mesh in a texture.
  45192. */
  45193. protected _bumpTexture: BaseTexture;
  45194. /**
  45195. * Stores the pre-calculated light information of a mesh in a texture.
  45196. */
  45197. protected _lightmapTexture: BaseTexture;
  45198. /**
  45199. * The color of a material in ambient lighting.
  45200. */
  45201. protected _ambientColor: Color3;
  45202. /**
  45203. * AKA Diffuse Color in other nomenclature.
  45204. */
  45205. protected _albedoColor: Color3;
  45206. /**
  45207. * AKA Specular Color in other nomenclature.
  45208. */
  45209. protected _reflectivityColor: Color3;
  45210. /**
  45211. * The color applied when light is reflected from a material.
  45212. */
  45213. protected _reflectionColor: Color3;
  45214. /**
  45215. * The color applied when light is emitted from a material.
  45216. */
  45217. protected _emissiveColor: Color3;
  45218. /**
  45219. * AKA Glossiness in other nomenclature.
  45220. */
  45221. protected _microSurface: number;
  45222. /**
  45223. * source material index of refraction (IOR)' / 'destination material IOR.
  45224. */
  45225. protected _indexOfRefraction: number;
  45226. /**
  45227. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45228. */
  45229. protected _invertRefractionY: boolean;
  45230. /**
  45231. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45232. * Materials half opaque for instance using refraction could benefit from this control.
  45233. */
  45234. protected _linkRefractionWithTransparency: boolean;
  45235. /**
  45236. * Specifies that the material will use the light map as a show map.
  45237. */
  45238. protected _useLightmapAsShadowmap: boolean;
  45239. /**
  45240. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45241. * makes the reflect vector face the model (under horizon).
  45242. */
  45243. protected _useHorizonOcclusion: boolean;
  45244. /**
  45245. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45246. * too much the area relying on ambient texture to define their ambient occlusion.
  45247. */
  45248. protected _useRadianceOcclusion: boolean;
  45249. /**
  45250. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45251. */
  45252. protected _useAlphaFromAlbedoTexture: boolean;
  45253. /**
  45254. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45255. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45256. */
  45257. protected _useSpecularOverAlpha: boolean;
  45258. /**
  45259. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45260. */
  45261. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45262. /**
  45263. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45264. */
  45265. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45266. /**
  45267. * Specifies if the metallic texture contains the roughness information in its green channel.
  45268. */
  45269. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45270. /**
  45271. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45272. */
  45273. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45274. /**
  45275. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45276. */
  45277. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45278. /**
  45279. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45280. */
  45281. protected _useAmbientInGrayScale: boolean;
  45282. /**
  45283. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45284. * The material will try to infer what glossiness each pixel should be.
  45285. */
  45286. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45287. /**
  45288. * Defines the falloff type used in this material.
  45289. * It by default is Physical.
  45290. */
  45291. protected _lightFalloff: number;
  45292. /**
  45293. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45294. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45295. */
  45296. protected _useRadianceOverAlpha: boolean;
  45297. /**
  45298. * Allows using an object space normal map (instead of tangent space).
  45299. */
  45300. protected _useObjectSpaceNormalMap: boolean;
  45301. /**
  45302. * Allows using the bump map in parallax mode.
  45303. */
  45304. protected _useParallax: boolean;
  45305. /**
  45306. * Allows using the bump map in parallax occlusion mode.
  45307. */
  45308. protected _useParallaxOcclusion: boolean;
  45309. /**
  45310. * Controls the scale bias of the parallax mode.
  45311. */
  45312. protected _parallaxScaleBias: number;
  45313. /**
  45314. * If sets to true, disables all the lights affecting the material.
  45315. */
  45316. protected _disableLighting: boolean;
  45317. /**
  45318. * Number of Simultaneous lights allowed on the material.
  45319. */
  45320. protected _maxSimultaneousLights: number;
  45321. /**
  45322. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45323. */
  45324. protected _invertNormalMapX: boolean;
  45325. /**
  45326. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45327. */
  45328. protected _invertNormalMapY: boolean;
  45329. /**
  45330. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45331. */
  45332. protected _twoSidedLighting: boolean;
  45333. /**
  45334. * Defines the alpha limits in alpha test mode.
  45335. */
  45336. protected _alphaCutOff: number;
  45337. /**
  45338. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45339. */
  45340. protected _forceAlphaTest: boolean;
  45341. /**
  45342. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45343. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45344. */
  45345. protected _useAlphaFresnel: boolean;
  45346. /**
  45347. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45348. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45349. */
  45350. protected _useLinearAlphaFresnel: boolean;
  45351. /**
  45352. * The transparency mode of the material.
  45353. */
  45354. protected _transparencyMode: Nullable<number>;
  45355. /**
  45356. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45357. * from cos thetav and roughness:
  45358. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45359. */
  45360. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45361. /**
  45362. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45363. */
  45364. protected _forceIrradianceInFragment: boolean;
  45365. /**
  45366. * Force normal to face away from face.
  45367. */
  45368. protected _forceNormalForward: boolean;
  45369. /**
  45370. * Enables specular anti aliasing in the PBR shader.
  45371. * It will both interacts on the Geometry for analytical and IBL lighting.
  45372. * It also prefilter the roughness map based on the bump values.
  45373. */
  45374. protected _enableSpecularAntiAliasing: boolean;
  45375. /**
  45376. * Default configuration related to image processing available in the PBR Material.
  45377. */
  45378. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45379. /**
  45380. * Keep track of the image processing observer to allow dispose and replace.
  45381. */
  45382. private _imageProcessingObserver;
  45383. /**
  45384. * Attaches a new image processing configuration to the PBR Material.
  45385. * @param configuration
  45386. */
  45387. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45388. /**
  45389. * Stores the available render targets.
  45390. */
  45391. private _renderTargets;
  45392. /**
  45393. * Sets the global ambient color for the material used in lighting calculations.
  45394. */
  45395. private _globalAmbientColor;
  45396. /**
  45397. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45398. */
  45399. private _useLogarithmicDepth;
  45400. /**
  45401. * If set to true, no lighting calculations will be applied.
  45402. */
  45403. private _unlit;
  45404. private _debugMode;
  45405. /**
  45406. * @hidden
  45407. * This is reserved for the inspector.
  45408. * Defines the material debug mode.
  45409. * It helps seeing only some components of the material while troubleshooting.
  45410. */
  45411. debugMode: number;
  45412. /**
  45413. * @hidden
  45414. * This is reserved for the inspector.
  45415. * Specify from where on screen the debug mode should start.
  45416. * The value goes from -1 (full screen) to 1 (not visible)
  45417. * It helps with side by side comparison against the final render
  45418. * This defaults to -1
  45419. */
  45420. private debugLimit;
  45421. /**
  45422. * @hidden
  45423. * This is reserved for the inspector.
  45424. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45425. * You can use the factor to better multiply the final value.
  45426. */
  45427. private debugFactor;
  45428. /**
  45429. * Defines the clear coat layer parameters for the material.
  45430. */
  45431. readonly clearCoat: PBRClearCoatConfiguration;
  45432. /**
  45433. * Defines the anisotropic parameters for the material.
  45434. */
  45435. readonly anisotropy: PBRAnisotropicConfiguration;
  45436. /**
  45437. * Defines the BRDF parameters for the material.
  45438. */
  45439. readonly brdf: PBRBRDFConfiguration;
  45440. /**
  45441. * Defines the Sheen parameters for the material.
  45442. */
  45443. readonly sheen: PBRSheenConfiguration;
  45444. /**
  45445. * Instantiates a new PBRMaterial instance.
  45446. *
  45447. * @param name The material name
  45448. * @param scene The scene the material will be use in.
  45449. */
  45450. constructor(name: string, scene: Scene);
  45451. /**
  45452. * Gets a boolean indicating that current material needs to register RTT
  45453. */
  45454. readonly hasRenderTargetTextures: boolean;
  45455. /**
  45456. * Gets the name of the material class.
  45457. */
  45458. getClassName(): string;
  45459. /**
  45460. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45461. */
  45462. /**
  45463. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45464. */
  45465. useLogarithmicDepth: boolean;
  45466. /**
  45467. * Gets the current transparency mode.
  45468. */
  45469. /**
  45470. * Sets the transparency mode of the material.
  45471. *
  45472. * | Value | Type | Description |
  45473. * | ----- | ----------------------------------- | ----------- |
  45474. * | 0 | OPAQUE | |
  45475. * | 1 | ALPHATEST | |
  45476. * | 2 | ALPHABLEND | |
  45477. * | 3 | ALPHATESTANDBLEND | |
  45478. *
  45479. */
  45480. transparencyMode: Nullable<number>;
  45481. /**
  45482. * Returns true if alpha blending should be disabled.
  45483. */
  45484. private readonly _disableAlphaBlending;
  45485. /**
  45486. * Specifies whether or not this material should be rendered in alpha blend mode.
  45487. */
  45488. needAlphaBlending(): boolean;
  45489. /**
  45490. * Specifies if the mesh will require alpha blending.
  45491. * @param mesh - BJS mesh.
  45492. */
  45493. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45494. /**
  45495. * Specifies whether or not this material should be rendered in alpha test mode.
  45496. */
  45497. needAlphaTesting(): boolean;
  45498. /**
  45499. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45500. */
  45501. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45502. /**
  45503. * Gets the texture used for the alpha test.
  45504. */
  45505. getAlphaTestTexture(): BaseTexture;
  45506. /**
  45507. * Specifies that the submesh is ready to be used.
  45508. * @param mesh - BJS mesh.
  45509. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45510. * @param useInstances - Specifies that instances should be used.
  45511. * @returns - boolean indicating that the submesh is ready or not.
  45512. */
  45513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45514. /**
  45515. * Specifies if the material uses metallic roughness workflow.
  45516. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45517. */
  45518. isMetallicWorkflow(): boolean;
  45519. private _prepareEffect;
  45520. private _prepareDefines;
  45521. /**
  45522. * Force shader compilation
  45523. */
  45524. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45525. clipPlane: boolean;
  45526. }>): void;
  45527. /**
  45528. * Initializes the uniform buffer layout for the shader.
  45529. */
  45530. buildUniformLayout(): void;
  45531. /**
  45532. * Unbinds the textures.
  45533. */
  45534. unbind(): void;
  45535. /**
  45536. * Binds the submesh data.
  45537. * @param world - The world matrix.
  45538. * @param mesh - The BJS mesh.
  45539. * @param subMesh - A submesh of the BJS mesh.
  45540. */
  45541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45542. /**
  45543. * Returns the animatable textures.
  45544. * @returns - Array of animatable textures.
  45545. */
  45546. getAnimatables(): IAnimatable[];
  45547. /**
  45548. * Returns the texture used for reflections.
  45549. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45550. */
  45551. private _getReflectionTexture;
  45552. /**
  45553. * Returns the texture used for refraction or null if none is used.
  45554. * @returns - Refection texture if present. If no refraction texture and refraction
  45555. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45556. */
  45557. private _getRefractionTexture;
  45558. /**
  45559. * Returns an array of the actively used textures.
  45560. * @returns - Array of BaseTextures
  45561. */
  45562. getActiveTextures(): BaseTexture[];
  45563. /**
  45564. * Checks to see if a texture is used in the material.
  45565. * @param texture - Base texture to use.
  45566. * @returns - Boolean specifying if a texture is used in the material.
  45567. */
  45568. hasTexture(texture: BaseTexture): boolean;
  45569. /**
  45570. * Disposes the resources of the material.
  45571. * @param forceDisposeEffect - Forces the disposal of effects.
  45572. * @param forceDisposeTextures - Forces the disposal of all textures.
  45573. */
  45574. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45575. }
  45576. }
  45577. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45578. import { Nullable } from "babylonjs/types";
  45579. import { Scene } from "babylonjs/scene";
  45580. import { Color3 } from "babylonjs/Maths/math";
  45581. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45582. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45584. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45585. /**
  45586. * The Physically based material of BJS.
  45587. *
  45588. * This offers the main features of a standard PBR material.
  45589. * For more information, please refer to the documentation :
  45590. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45591. */
  45592. export class PBRMaterial extends PBRBaseMaterial {
  45593. /**
  45594. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45595. */
  45596. static readonly PBRMATERIAL_OPAQUE: number;
  45597. /**
  45598. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45599. */
  45600. static readonly PBRMATERIAL_ALPHATEST: number;
  45601. /**
  45602. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45603. */
  45604. static readonly PBRMATERIAL_ALPHABLEND: number;
  45605. /**
  45606. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45607. * They are also discarded below the alpha cutoff threshold to improve performances.
  45608. */
  45609. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45610. /**
  45611. * Defines the default value of how much AO map is occluding the analytical lights
  45612. * (point spot...).
  45613. */
  45614. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: 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. 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. 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. 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. specularIntensity: number;
  45635. /**
  45636. * Debug Control allowing disabling the bump map on this material.
  45637. */
  45638. disableBumpMap: boolean;
  45639. /**
  45640. * AKA Diffuse Texture in standard nomenclature.
  45641. */
  45642. albedoTexture: BaseTexture;
  45643. /**
  45644. * AKA Occlusion Texture in other nomenclature.
  45645. */
  45646. ambientTexture: BaseTexture;
  45647. /**
  45648. * AKA Occlusion Texture Intensity in other nomenclature.
  45649. */
  45650. ambientTextureStrength: number;
  45651. /**
  45652. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45653. * 1 means it completely occludes it
  45654. * 0 mean it has no impact
  45655. */
  45656. ambientTextureImpactOnAnalyticalLights: number;
  45657. /**
  45658. * Stores the alpha values in a texture.
  45659. */
  45660. opacityTexture: BaseTexture;
  45661. /**
  45662. * Stores the reflection values in a texture.
  45663. */
  45664. reflectionTexture: Nullable<BaseTexture>;
  45665. /**
  45666. * Stores the emissive values in a texture.
  45667. */
  45668. emissiveTexture: BaseTexture;
  45669. /**
  45670. * AKA Specular texture in other nomenclature.
  45671. */
  45672. reflectivityTexture: BaseTexture;
  45673. /**
  45674. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45675. */
  45676. metallicTexture: BaseTexture;
  45677. /**
  45678. * Specifies the metallic scalar of the metallic/roughness workflow.
  45679. * Can also be used to scale the metalness values of the metallic texture.
  45680. */
  45681. metallic: Nullable<number>;
  45682. /**
  45683. * Specifies the roughness scalar of the metallic/roughness workflow.
  45684. * Can also be used to scale the roughness values of the metallic texture.
  45685. */
  45686. roughness: Nullable<number>;
  45687. /**
  45688. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45689. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45690. */
  45691. microSurfaceTexture: BaseTexture;
  45692. /**
  45693. * Stores surface normal data used to displace a mesh in a texture.
  45694. */
  45695. bumpTexture: BaseTexture;
  45696. /**
  45697. * Stores the pre-calculated light information of a mesh in a texture.
  45698. */
  45699. lightmapTexture: BaseTexture;
  45700. /**
  45701. * Stores the refracted light information in a texture.
  45702. */
  45703. refractionTexture: BaseTexture;
  45704. /**
  45705. * The color of a material in ambient lighting.
  45706. */
  45707. ambientColor: Color3;
  45708. /**
  45709. * AKA Diffuse Color in other nomenclature.
  45710. */
  45711. albedoColor: Color3;
  45712. /**
  45713. * AKA Specular Color in other nomenclature.
  45714. */
  45715. reflectivityColor: Color3;
  45716. /**
  45717. * The color reflected from the material.
  45718. */
  45719. reflectionColor: Color3;
  45720. /**
  45721. * The color emitted from the material.
  45722. */
  45723. emissiveColor: Color3;
  45724. /**
  45725. * AKA Glossiness in other nomenclature.
  45726. */
  45727. microSurface: number;
  45728. /**
  45729. * source material index of refraction (IOR)' / 'destination material IOR.
  45730. */
  45731. indexOfRefraction: number;
  45732. /**
  45733. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45734. */
  45735. invertRefractionY: boolean;
  45736. /**
  45737. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45738. * Materials half opaque for instance using refraction could benefit from this control.
  45739. */
  45740. linkRefractionWithTransparency: boolean;
  45741. /**
  45742. * If true, the light map contains occlusion information instead of lighting info.
  45743. */
  45744. useLightmapAsShadowmap: boolean;
  45745. /**
  45746. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45747. */
  45748. useAlphaFromAlbedoTexture: boolean;
  45749. /**
  45750. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45751. */
  45752. forceAlphaTest: boolean;
  45753. /**
  45754. * Defines the alpha limits in alpha test mode.
  45755. */
  45756. alphaCutOff: number;
  45757. /**
  45758. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45759. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45760. */
  45761. useSpecularOverAlpha: boolean;
  45762. /**
  45763. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45764. */
  45765. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45766. /**
  45767. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45768. */
  45769. useRoughnessFromMetallicTextureAlpha: boolean;
  45770. /**
  45771. * Specifies if the metallic texture contains the roughness information in its green channel.
  45772. */
  45773. useRoughnessFromMetallicTextureGreen: boolean;
  45774. /**
  45775. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45776. */
  45777. useMetallnessFromMetallicTextureBlue: boolean;
  45778. /**
  45779. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45780. */
  45781. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45782. /**
  45783. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45784. */
  45785. useAmbientInGrayScale: boolean;
  45786. /**
  45787. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45788. * The material will try to infer what glossiness each pixel should be.
  45789. */
  45790. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45791. /**
  45792. * BJS is using an harcoded light falloff based on a manually sets up range.
  45793. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45794. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45795. */
  45796. /**
  45797. * BJS is using an harcoded light falloff based on a manually sets up range.
  45798. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45799. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45800. */
  45801. usePhysicalLightFalloff: boolean;
  45802. /**
  45803. * In order to support the falloff compatibility with gltf, a special mode has been added
  45804. * to reproduce the gltf light falloff.
  45805. */
  45806. /**
  45807. * In order to support the falloff compatibility with gltf, a special mode has been added
  45808. * to reproduce the gltf light falloff.
  45809. */
  45810. useGLTFLightFalloff: boolean;
  45811. /**
  45812. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45813. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45814. */
  45815. useRadianceOverAlpha: boolean;
  45816. /**
  45817. * Allows using an object space normal map (instead of tangent space).
  45818. */
  45819. useObjectSpaceNormalMap: boolean;
  45820. /**
  45821. * Allows using the bump map in parallax mode.
  45822. */
  45823. useParallax: boolean;
  45824. /**
  45825. * Allows using the bump map in parallax occlusion mode.
  45826. */
  45827. useParallaxOcclusion: boolean;
  45828. /**
  45829. * Controls the scale bias of the parallax mode.
  45830. */
  45831. parallaxScaleBias: number;
  45832. /**
  45833. * If sets to true, disables all the lights affecting the material.
  45834. */
  45835. disableLighting: boolean;
  45836. /**
  45837. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45838. */
  45839. forceIrradianceInFragment: boolean;
  45840. /**
  45841. * Number of Simultaneous lights allowed on the material.
  45842. */
  45843. maxSimultaneousLights: number;
  45844. /**
  45845. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45846. */
  45847. invertNormalMapX: boolean;
  45848. /**
  45849. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45850. */
  45851. invertNormalMapY: boolean;
  45852. /**
  45853. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45854. */
  45855. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  45859. */
  45860. useAlphaFresnel: boolean;
  45861. /**
  45862. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45863. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45864. */
  45865. useLinearAlphaFresnel: boolean;
  45866. /**
  45867. * Let user defines the brdf lookup texture used for IBL.
  45868. * A default 8bit version is embedded but you could point at :
  45869. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45870. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45871. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45872. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45873. */
  45874. environmentBRDFTexture: Nullable<BaseTexture>;
  45875. /**
  45876. * Force normal to face away from face.
  45877. */
  45878. 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. enableSpecularAntiAliasing: boolean;
  45885. /**
  45886. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45887. * makes the reflect vector face the model (under horizon).
  45888. */
  45889. useHorizonOcclusion: boolean;
  45890. /**
  45891. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45892. * too much the area relying on ambient texture to define their ambient occlusion.
  45893. */
  45894. useRadianceOcclusion: boolean;
  45895. /**
  45896. * If set to true, no lighting calculations will be applied.
  45897. */
  45898. unlit: boolean;
  45899. /**
  45900. * Gets the image processing configuration used either in this material.
  45901. */
  45902. /**
  45903. * Sets the Default image processing configuration used either in the this material.
  45904. *
  45905. * If sets to null, the scene one is in use.
  45906. */
  45907. imageProcessingConfiguration: ImageProcessingConfiguration;
  45908. /**
  45909. * Gets wether the color curves effect is enabled.
  45910. */
  45911. /**
  45912. * Sets wether the color curves effect is enabled.
  45913. */
  45914. cameraColorCurvesEnabled: boolean;
  45915. /**
  45916. * Gets wether the color grading effect is enabled.
  45917. */
  45918. /**
  45919. * Gets wether the color grading effect is enabled.
  45920. */
  45921. cameraColorGradingEnabled: boolean;
  45922. /**
  45923. * Gets wether tonemapping is enabled or not.
  45924. */
  45925. /**
  45926. * Sets wether tonemapping is enabled or not
  45927. */
  45928. cameraToneMappingEnabled: boolean;
  45929. /**
  45930. * The camera exposure used on this material.
  45931. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45932. * This corresponds to a photographic exposure.
  45933. */
  45934. /**
  45935. * The camera exposure used on this material.
  45936. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45937. * This corresponds to a photographic exposure.
  45938. */
  45939. cameraExposure: number;
  45940. /**
  45941. * Gets The camera contrast used on this material.
  45942. */
  45943. /**
  45944. * Sets The camera contrast used on this material.
  45945. */
  45946. cameraContrast: number;
  45947. /**
  45948. * Gets the Color Grading 2D Lookup Texture.
  45949. */
  45950. /**
  45951. * Sets the Color Grading 2D Lookup Texture.
  45952. */
  45953. cameraColorGradingTexture: Nullable<BaseTexture>;
  45954. /**
  45955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45957. * 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;
  45958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45959. */
  45960. /**
  45961. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45962. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45963. * 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;
  45964. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45965. */
  45966. cameraColorCurves: Nullable<ColorCurves>;
  45967. /**
  45968. * Instantiates a new PBRMaterial instance.
  45969. *
  45970. * @param name The material name
  45971. * @param scene The scene the material will be use in.
  45972. */
  45973. constructor(name: string, scene: Scene);
  45974. /**
  45975. * Returns the name of this material class.
  45976. */
  45977. getClassName(): string;
  45978. /**
  45979. * Makes a duplicate of the current material.
  45980. * @param name - name to use for the new material.
  45981. */
  45982. clone(name: string): PBRMaterial;
  45983. /**
  45984. * Serializes this PBR Material.
  45985. * @returns - An object with the serialized material.
  45986. */
  45987. serialize(): any;
  45988. /**
  45989. * Parses a PBR Material from a serialized object.
  45990. * @param source - Serialized object.
  45991. * @param scene - BJS scene instance.
  45992. * @param rootUrl - url for the scene object
  45993. * @returns - PBRMaterial
  45994. */
  45995. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45996. }
  45997. }
  45998. declare module "babylonjs/Misc/dds" {
  45999. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46000. import { Engine } from "babylonjs/Engines/engine";
  46001. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46002. import { Nullable } from "babylonjs/types";
  46003. import { Scene } from "babylonjs/scene";
  46004. /**
  46005. * Direct draw surface info
  46006. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46007. */
  46008. export interface DDSInfo {
  46009. /**
  46010. * Width of the texture
  46011. */
  46012. width: number;
  46013. /**
  46014. * Width of the texture
  46015. */
  46016. height: number;
  46017. /**
  46018. * Number of Mipmaps for the texture
  46019. * @see https://en.wikipedia.org/wiki/Mipmap
  46020. */
  46021. mipmapCount: number;
  46022. /**
  46023. * If the textures format is a known fourCC format
  46024. * @see https://www.fourcc.org/
  46025. */
  46026. isFourCC: boolean;
  46027. /**
  46028. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46029. */
  46030. isRGB: boolean;
  46031. /**
  46032. * If the texture is a lumincance format
  46033. */
  46034. isLuminance: boolean;
  46035. /**
  46036. * If this is a cube texture
  46037. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46038. */
  46039. isCube: boolean;
  46040. /**
  46041. * If the texture is a compressed format eg. FOURCC_DXT1
  46042. */
  46043. isCompressed: boolean;
  46044. /**
  46045. * The dxgiFormat of the texture
  46046. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46047. */
  46048. dxgiFormat: number;
  46049. /**
  46050. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46051. */
  46052. textureType: number;
  46053. /**
  46054. * Sphericle polynomial created for the dds texture
  46055. */
  46056. sphericalPolynomial?: SphericalPolynomial;
  46057. }
  46058. /**
  46059. * Class used to provide DDS decompression tools
  46060. */
  46061. export class DDSTools {
  46062. /**
  46063. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46064. */
  46065. static StoreLODInAlphaChannel: boolean;
  46066. /**
  46067. * Gets DDS information from an array buffer
  46068. * @param arrayBuffer defines the array buffer to read data from
  46069. * @returns the DDS information
  46070. */
  46071. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46072. private static _FloatView;
  46073. private static _Int32View;
  46074. private static _ToHalfFloat;
  46075. private static _FromHalfFloat;
  46076. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46077. private static _GetHalfFloatRGBAArrayBuffer;
  46078. private static _GetFloatRGBAArrayBuffer;
  46079. private static _GetFloatAsUIntRGBAArrayBuffer;
  46080. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46081. private static _GetRGBAArrayBuffer;
  46082. private static _ExtractLongWordOrder;
  46083. private static _GetRGBArrayBuffer;
  46084. private static _GetLuminanceArrayBuffer;
  46085. /**
  46086. * Uploads DDS Levels to a Babylon Texture
  46087. * @hidden
  46088. */
  46089. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46090. }
  46091. module "babylonjs/Engines/engine" {
  46092. interface Engine {
  46093. /**
  46094. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46095. * @param rootUrl defines the url where the file to load is located
  46096. * @param scene defines the current scene
  46097. * @param lodScale defines scale to apply to the mip map selection
  46098. * @param lodOffset defines offset to apply to the mip map selection
  46099. * @param onLoad defines an optional callback raised when the texture is loaded
  46100. * @param onError defines an optional callback raised if there is an issue to load the texture
  46101. * @param format defines the format of the data
  46102. * @param forcedExtension defines the extension to use to pick the right loader
  46103. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46104. * @returns the cube texture as an InternalTexture
  46105. */
  46106. 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;
  46107. }
  46108. }
  46109. }
  46110. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46111. import { Nullable } from "babylonjs/types";
  46112. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46113. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46114. /**
  46115. * Implementation of the DDS Texture Loader.
  46116. * @hidden
  46117. */
  46118. export class _DDSTextureLoader implements IInternalTextureLoader {
  46119. /**
  46120. * Defines wether the loader supports cascade loading the different faces.
  46121. */
  46122. readonly supportCascades: boolean;
  46123. /**
  46124. * This returns if the loader support the current file information.
  46125. * @param extension defines the file extension of the file being loaded
  46126. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46127. * @param fallback defines the fallback internal texture if any
  46128. * @param isBase64 defines whether the texture is encoded as a base64
  46129. * @param isBuffer defines whether the texture data are stored as a buffer
  46130. * @returns true if the loader can load the specified file
  46131. */
  46132. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46133. /**
  46134. * Transform the url before loading if required.
  46135. * @param rootUrl the url of the texture
  46136. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46137. * @returns the transformed texture
  46138. */
  46139. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46140. /**
  46141. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46142. * @param rootUrl the url of the texture
  46143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46144. * @returns the fallback texture
  46145. */
  46146. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46147. /**
  46148. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46149. * @param data contains the texture data
  46150. * @param texture defines the BabylonJS internal texture
  46151. * @param createPolynomials will be true if polynomials have been requested
  46152. * @param onLoad defines the callback to trigger once the texture is ready
  46153. * @param onError defines the callback to trigger in case of error
  46154. */
  46155. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46156. /**
  46157. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46158. * @param data contains the texture data
  46159. * @param texture defines the BabylonJS internal texture
  46160. * @param callback defines the method to call once ready to upload
  46161. */
  46162. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46163. }
  46164. }
  46165. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46166. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46167. /** @hidden */
  46168. export var rgbdEncodePixelShader: {
  46169. name: string;
  46170. shader: string;
  46171. };
  46172. }
  46173. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46174. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46175. /** @hidden */
  46176. export var rgbdDecodePixelShader: {
  46177. name: string;
  46178. shader: string;
  46179. };
  46180. }
  46181. declare module "babylonjs/Misc/environmentTextureTools" {
  46182. import { Nullable } from "babylonjs/types";
  46183. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46184. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46185. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46186. import "babylonjs/Shaders/rgbdEncode.fragment";
  46187. import "babylonjs/Shaders/rgbdDecode.fragment";
  46188. /**
  46189. * Raw texture data and descriptor sufficient for WebGL texture upload
  46190. */
  46191. export interface EnvironmentTextureInfo {
  46192. /**
  46193. * Version of the environment map
  46194. */
  46195. version: number;
  46196. /**
  46197. * Width of image
  46198. */
  46199. width: number;
  46200. /**
  46201. * Irradiance information stored in the file.
  46202. */
  46203. irradiance: any;
  46204. /**
  46205. * Specular information stored in the file.
  46206. */
  46207. specular: any;
  46208. }
  46209. /**
  46210. * Sets of helpers addressing the serialization and deserialization of environment texture
  46211. * stored in a BabylonJS env file.
  46212. * Those files are usually stored as .env files.
  46213. */
  46214. export class EnvironmentTextureTools {
  46215. /**
  46216. * Magic number identifying the env file.
  46217. */
  46218. private static _MagicBytes;
  46219. /**
  46220. * Gets the environment info from an env file.
  46221. * @param data The array buffer containing the .env bytes.
  46222. * @returns the environment file info (the json header) if successfully parsed.
  46223. */
  46224. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46225. /**
  46226. * Creates an environment texture from a loaded cube texture.
  46227. * @param texture defines the cube texture to convert in env file
  46228. * @return a promise containing the environment data if succesfull.
  46229. */
  46230. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46231. /**
  46232. * Creates a JSON representation of the spherical data.
  46233. * @param texture defines the texture containing the polynomials
  46234. * @return the JSON representation of the spherical info
  46235. */
  46236. private static _CreateEnvTextureIrradiance;
  46237. /**
  46238. * Uploads the texture info contained in the env file to the GPU.
  46239. * @param texture defines the internal texture to upload to
  46240. * @param arrayBuffer defines the buffer cotaining the data to load
  46241. * @param info defines the texture info retrieved through the GetEnvInfo method
  46242. * @returns a promise
  46243. */
  46244. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46245. /**
  46246. * Uploads the levels of image data to the GPU.
  46247. * @param texture defines the internal texture to upload to
  46248. * @param imageData defines the array buffer views of image data [mipmap][face]
  46249. * @returns a promise
  46250. */
  46251. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46252. /**
  46253. * Uploads spherical polynomials information to the texture.
  46254. * @param texture defines the texture we are trying to upload the information to
  46255. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46256. */
  46257. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46258. /** @hidden */
  46259. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46260. }
  46261. }
  46262. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46263. import { Nullable } from "babylonjs/types";
  46264. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46265. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46266. /**
  46267. * Implementation of the ENV Texture Loader.
  46268. * @hidden
  46269. */
  46270. export class _ENVTextureLoader implements IInternalTextureLoader {
  46271. /**
  46272. * Defines wether the loader supports cascade loading the different faces.
  46273. */
  46274. readonly supportCascades: boolean;
  46275. /**
  46276. * This returns if the loader support the current file information.
  46277. * @param extension defines the file extension of the file being loaded
  46278. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46279. * @param fallback defines the fallback internal texture if any
  46280. * @param isBase64 defines whether the texture is encoded as a base64
  46281. * @param isBuffer defines whether the texture data are stored as a buffer
  46282. * @returns true if the loader can load the specified file
  46283. */
  46284. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46285. /**
  46286. * Transform the url before loading if required.
  46287. * @param rootUrl the url of the texture
  46288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46289. * @returns the transformed texture
  46290. */
  46291. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46292. /**
  46293. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46294. * @param rootUrl the url of the texture
  46295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46296. * @returns the fallback texture
  46297. */
  46298. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46299. /**
  46300. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46301. * @param data contains the texture data
  46302. * @param texture defines the BabylonJS internal texture
  46303. * @param createPolynomials will be true if polynomials have been requested
  46304. * @param onLoad defines the callback to trigger once the texture is ready
  46305. * @param onError defines the callback to trigger in case of error
  46306. */
  46307. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46308. /**
  46309. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46310. * @param data contains the texture data
  46311. * @param texture defines the BabylonJS internal texture
  46312. * @param callback defines the method to call once ready to upload
  46313. */
  46314. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46315. }
  46316. }
  46317. declare module "babylonjs/Misc/khronosTextureContainer" {
  46318. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46319. /**
  46320. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46321. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46322. */
  46323. export class KhronosTextureContainer {
  46324. /** contents of the KTX container file */
  46325. arrayBuffer: any;
  46326. private static HEADER_LEN;
  46327. private static COMPRESSED_2D;
  46328. private static COMPRESSED_3D;
  46329. private static TEX_2D;
  46330. private static TEX_3D;
  46331. /**
  46332. * Gets the openGL type
  46333. */
  46334. glType: number;
  46335. /**
  46336. * Gets the openGL type size
  46337. */
  46338. glTypeSize: number;
  46339. /**
  46340. * Gets the openGL format
  46341. */
  46342. glFormat: number;
  46343. /**
  46344. * Gets the openGL internal format
  46345. */
  46346. glInternalFormat: number;
  46347. /**
  46348. * Gets the base internal format
  46349. */
  46350. glBaseInternalFormat: number;
  46351. /**
  46352. * Gets image width in pixel
  46353. */
  46354. pixelWidth: number;
  46355. /**
  46356. * Gets image height in pixel
  46357. */
  46358. pixelHeight: number;
  46359. /**
  46360. * Gets image depth in pixels
  46361. */
  46362. pixelDepth: number;
  46363. /**
  46364. * Gets the number of array elements
  46365. */
  46366. numberOfArrayElements: number;
  46367. /**
  46368. * Gets the number of faces
  46369. */
  46370. numberOfFaces: number;
  46371. /**
  46372. * Gets the number of mipmap levels
  46373. */
  46374. numberOfMipmapLevels: number;
  46375. /**
  46376. * Gets the bytes of key value data
  46377. */
  46378. bytesOfKeyValueData: number;
  46379. /**
  46380. * Gets the load type
  46381. */
  46382. loadType: number;
  46383. /**
  46384. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46385. */
  46386. isInvalid: boolean;
  46387. /**
  46388. * Creates a new KhronosTextureContainer
  46389. * @param arrayBuffer contents of the KTX container file
  46390. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46391. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46392. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46393. */
  46394. constructor(
  46395. /** contents of the KTX container file */
  46396. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46397. /**
  46398. * Uploads KTX content to a Babylon Texture.
  46399. * It is assumed that the texture has already been created & is currently bound
  46400. * @hidden
  46401. */
  46402. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46403. private _upload2DCompressedLevels;
  46404. }
  46405. }
  46406. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46407. import { Nullable } from "babylonjs/types";
  46408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46409. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46410. /**
  46411. * Implementation of the KTX Texture Loader.
  46412. * @hidden
  46413. */
  46414. export class _KTXTextureLoader implements IInternalTextureLoader {
  46415. /**
  46416. * Defines wether the loader supports cascade loading the different faces.
  46417. */
  46418. readonly supportCascades: boolean;
  46419. /**
  46420. * This returns if the loader support the current file information.
  46421. * @param extension defines the file extension of the file being loaded
  46422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46423. * @param fallback defines the fallback internal texture if any
  46424. * @param isBase64 defines whether the texture is encoded as a base64
  46425. * @param isBuffer defines whether the texture data are stored as a buffer
  46426. * @returns true if the loader can load the specified file
  46427. */
  46428. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46429. /**
  46430. * Transform the url before loading if required.
  46431. * @param rootUrl the url of the texture
  46432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46433. * @returns the transformed texture
  46434. */
  46435. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46436. /**
  46437. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46438. * @param rootUrl the url of the texture
  46439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46440. * @returns the fallback texture
  46441. */
  46442. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46443. /**
  46444. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46445. * @param data contains the texture data
  46446. * @param texture defines the BabylonJS internal texture
  46447. * @param createPolynomials will be true if polynomials have been requested
  46448. * @param onLoad defines the callback to trigger once the texture is ready
  46449. * @param onError defines the callback to trigger in case of error
  46450. */
  46451. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46452. /**
  46453. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46454. * @param data contains the texture data
  46455. * @param texture defines the BabylonJS internal texture
  46456. * @param callback defines the method to call once ready to upload
  46457. */
  46458. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46459. }
  46460. }
  46461. declare module "babylonjs/Helpers/sceneHelpers" {
  46462. import { Nullable } from "babylonjs/types";
  46463. import { Mesh } from "babylonjs/Meshes/mesh";
  46464. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46465. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46466. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46467. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46468. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46469. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46470. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46471. import "babylonjs/Meshes/Builders/boxBuilder";
  46472. /** @hidden */
  46473. export var _forceSceneHelpersToBundle: boolean;
  46474. module "babylonjs/scene" {
  46475. interface Scene {
  46476. /**
  46477. * Creates a default light for the scene.
  46478. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46479. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46480. */
  46481. createDefaultLight(replace?: boolean): void;
  46482. /**
  46483. * Creates a default camera for the scene.
  46484. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46485. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46486. * @param replace has default false, when true replaces the active camera in the scene
  46487. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46488. */
  46489. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46490. /**
  46491. * Creates a default camera and a default light.
  46492. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46493. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46494. * @param replace has the default false, when true replaces the active camera/light in the scene
  46495. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46496. */
  46497. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46498. /**
  46499. * Creates a new sky box
  46500. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46501. * @param environmentTexture defines the texture to use as environment texture
  46502. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46503. * @param scale defines the overall scale of the skybox
  46504. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46505. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46506. * @returns a new mesh holding the sky box
  46507. */
  46508. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46509. /**
  46510. * Creates a new environment
  46511. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46512. * @param options defines the options you can use to configure the environment
  46513. * @returns the new EnvironmentHelper
  46514. */
  46515. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46516. /**
  46517. * Creates a new VREXperienceHelper
  46518. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46519. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46520. * @returns a new VREXperienceHelper
  46521. */
  46522. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46523. /**
  46524. * Creates a new XREXperienceHelper
  46525. * @see http://doc.babylonjs.com/how_to/webxr
  46526. * @returns a promise for a new XREXperienceHelper
  46527. */
  46528. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46529. }
  46530. }
  46531. }
  46532. declare module "babylonjs/Helpers/videoDome" {
  46533. import { Scene } from "babylonjs/scene";
  46534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46535. import { Mesh } from "babylonjs/Meshes/mesh";
  46536. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46537. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46538. import "babylonjs/Meshes/Builders/sphereBuilder";
  46539. /**
  46540. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46541. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46542. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46543. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46544. */
  46545. export class VideoDome extends TransformNode {
  46546. /**
  46547. * Define the video source as a Monoscopic panoramic 360 video.
  46548. */
  46549. static readonly MODE_MONOSCOPIC: number;
  46550. /**
  46551. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46552. */
  46553. static readonly MODE_TOPBOTTOM: number;
  46554. /**
  46555. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46556. */
  46557. static readonly MODE_SIDEBYSIDE: number;
  46558. private _useDirectMapping;
  46559. /**
  46560. * The video texture being displayed on the sphere
  46561. */
  46562. protected _videoTexture: VideoTexture;
  46563. /**
  46564. * Gets the video texture being displayed on the sphere
  46565. */
  46566. readonly videoTexture: VideoTexture;
  46567. /**
  46568. * The skybox material
  46569. */
  46570. protected _material: BackgroundMaterial;
  46571. /**
  46572. * The surface used for the skybox
  46573. */
  46574. protected _mesh: Mesh;
  46575. /**
  46576. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46577. * Also see the options.resolution property.
  46578. */
  46579. fovMultiplier: number;
  46580. private _videoMode;
  46581. /**
  46582. * Gets or set the current video mode for the video. It can be:
  46583. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46584. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46585. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46586. */
  46587. videoMode: number;
  46588. /**
  46589. * Oberserver used in Stereoscopic VR Mode.
  46590. */
  46591. private _onBeforeCameraRenderObserver;
  46592. /**
  46593. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46594. * @param name Element's name, child elements will append suffixes for their own names.
  46595. * @param urlsOrVideo defines the url(s) or the video element to use
  46596. * @param options An object containing optional or exposed sub element properties
  46597. */
  46598. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46599. resolution?: number;
  46600. clickToPlay?: boolean;
  46601. autoPlay?: boolean;
  46602. loop?: boolean;
  46603. size?: number;
  46604. poster?: string;
  46605. useDirectMapping?: boolean;
  46606. }, scene: Scene);
  46607. private _changeVideoMode;
  46608. /**
  46609. * Releases resources associated with this node.
  46610. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46611. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46612. */
  46613. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46614. }
  46615. }
  46616. declare module "babylonjs/Helpers/index" {
  46617. export * from "babylonjs/Helpers/environmentHelper";
  46618. export * from "babylonjs/Helpers/photoDome";
  46619. export * from "babylonjs/Helpers/sceneHelpers";
  46620. export * from "babylonjs/Helpers/videoDome";
  46621. }
  46622. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46623. import { PerfCounter } from "babylonjs/Misc/tools";
  46624. import { IDisposable } from "babylonjs/scene";
  46625. import { Engine } from "babylonjs/Engines/engine";
  46626. /**
  46627. * This class can be used to get instrumentation data from a Babylon engine
  46628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46629. */
  46630. export class EngineInstrumentation implements IDisposable {
  46631. /**
  46632. * Define the instrumented engine.
  46633. */
  46634. engine: Engine;
  46635. private _captureGPUFrameTime;
  46636. private _gpuFrameTimeToken;
  46637. private _gpuFrameTime;
  46638. private _captureShaderCompilationTime;
  46639. private _shaderCompilationTime;
  46640. private _onBeginFrameObserver;
  46641. private _onEndFrameObserver;
  46642. private _onBeforeShaderCompilationObserver;
  46643. private _onAfterShaderCompilationObserver;
  46644. /**
  46645. * Gets the perf counter used for GPU frame time
  46646. */
  46647. readonly gpuFrameTimeCounter: PerfCounter;
  46648. /**
  46649. * Gets the GPU frame time capture status
  46650. */
  46651. /**
  46652. * Enable or disable the GPU frame time capture
  46653. */
  46654. captureGPUFrameTime: boolean;
  46655. /**
  46656. * Gets the perf counter used for shader compilation time
  46657. */
  46658. readonly shaderCompilationTimeCounter: PerfCounter;
  46659. /**
  46660. * Gets the shader compilation time capture status
  46661. */
  46662. /**
  46663. * Enable or disable the shader compilation time capture
  46664. */
  46665. captureShaderCompilationTime: boolean;
  46666. /**
  46667. * Instantiates a new engine instrumentation.
  46668. * This class can be used to get instrumentation data from a Babylon engine
  46669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46670. * @param engine Defines the engine to instrument
  46671. */
  46672. constructor(
  46673. /**
  46674. * Define the instrumented engine.
  46675. */
  46676. engine: Engine);
  46677. /**
  46678. * Dispose and release associated resources.
  46679. */
  46680. dispose(): void;
  46681. }
  46682. }
  46683. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46684. import { PerfCounter } from "babylonjs/Misc/tools";
  46685. import { Scene, IDisposable } from "babylonjs/scene";
  46686. /**
  46687. * This class can be used to get instrumentation data from a Babylon engine
  46688. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46689. */
  46690. export class SceneInstrumentation implements IDisposable {
  46691. /**
  46692. * Defines the scene to instrument
  46693. */
  46694. scene: Scene;
  46695. private _captureActiveMeshesEvaluationTime;
  46696. private _activeMeshesEvaluationTime;
  46697. private _captureRenderTargetsRenderTime;
  46698. private _renderTargetsRenderTime;
  46699. private _captureFrameTime;
  46700. private _frameTime;
  46701. private _captureRenderTime;
  46702. private _renderTime;
  46703. private _captureInterFrameTime;
  46704. private _interFrameTime;
  46705. private _captureParticlesRenderTime;
  46706. private _particlesRenderTime;
  46707. private _captureSpritesRenderTime;
  46708. private _spritesRenderTime;
  46709. private _capturePhysicsTime;
  46710. private _physicsTime;
  46711. private _captureAnimationsTime;
  46712. private _animationsTime;
  46713. private _captureCameraRenderTime;
  46714. private _cameraRenderTime;
  46715. private _onBeforeActiveMeshesEvaluationObserver;
  46716. private _onAfterActiveMeshesEvaluationObserver;
  46717. private _onBeforeRenderTargetsRenderObserver;
  46718. private _onAfterRenderTargetsRenderObserver;
  46719. private _onAfterRenderObserver;
  46720. private _onBeforeDrawPhaseObserver;
  46721. private _onAfterDrawPhaseObserver;
  46722. private _onBeforeAnimationsObserver;
  46723. private _onBeforeParticlesRenderingObserver;
  46724. private _onAfterParticlesRenderingObserver;
  46725. private _onBeforeSpritesRenderingObserver;
  46726. private _onAfterSpritesRenderingObserver;
  46727. private _onBeforePhysicsObserver;
  46728. private _onAfterPhysicsObserver;
  46729. private _onAfterAnimationsObserver;
  46730. private _onBeforeCameraRenderObserver;
  46731. private _onAfterCameraRenderObserver;
  46732. /**
  46733. * Gets the perf counter used for active meshes evaluation time
  46734. */
  46735. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46736. /**
  46737. * Gets the active meshes evaluation time capture status
  46738. */
  46739. /**
  46740. * Enable or disable the active meshes evaluation time capture
  46741. */
  46742. captureActiveMeshesEvaluationTime: boolean;
  46743. /**
  46744. * Gets the perf counter used for render targets render time
  46745. */
  46746. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46747. /**
  46748. * Gets the render targets render time capture status
  46749. */
  46750. /**
  46751. * Enable or disable the render targets render time capture
  46752. */
  46753. captureRenderTargetsRenderTime: boolean;
  46754. /**
  46755. * Gets the perf counter used for particles render time
  46756. */
  46757. readonly particlesRenderTimeCounter: PerfCounter;
  46758. /**
  46759. * Gets the particles render time capture status
  46760. */
  46761. /**
  46762. * Enable or disable the particles render time capture
  46763. */
  46764. captureParticlesRenderTime: boolean;
  46765. /**
  46766. * Gets the perf counter used for sprites render time
  46767. */
  46768. readonly spritesRenderTimeCounter: PerfCounter;
  46769. /**
  46770. * Gets the sprites render time capture status
  46771. */
  46772. /**
  46773. * Enable or disable the sprites render time capture
  46774. */
  46775. captureSpritesRenderTime: boolean;
  46776. /**
  46777. * Gets the perf counter used for physics time
  46778. */
  46779. readonly physicsTimeCounter: PerfCounter;
  46780. /**
  46781. * Gets the physics time capture status
  46782. */
  46783. /**
  46784. * Enable or disable the physics time capture
  46785. */
  46786. capturePhysicsTime: boolean;
  46787. /**
  46788. * Gets the perf counter used for animations time
  46789. */
  46790. readonly animationsTimeCounter: PerfCounter;
  46791. /**
  46792. * Gets the animations time capture status
  46793. */
  46794. /**
  46795. * Enable or disable the animations time capture
  46796. */
  46797. captureAnimationsTime: boolean;
  46798. /**
  46799. * Gets the perf counter used for frame time capture
  46800. */
  46801. readonly frameTimeCounter: PerfCounter;
  46802. /**
  46803. * Gets the frame time capture status
  46804. */
  46805. /**
  46806. * Enable or disable the frame time capture
  46807. */
  46808. captureFrameTime: boolean;
  46809. /**
  46810. * Gets the perf counter used for inter-frames time capture
  46811. */
  46812. readonly interFrameTimeCounter: PerfCounter;
  46813. /**
  46814. * Gets the inter-frames time capture status
  46815. */
  46816. /**
  46817. * Enable or disable the inter-frames time capture
  46818. */
  46819. captureInterFrameTime: boolean;
  46820. /**
  46821. * Gets the perf counter used for render time capture
  46822. */
  46823. readonly renderTimeCounter: PerfCounter;
  46824. /**
  46825. * Gets the render time capture status
  46826. */
  46827. /**
  46828. * Enable or disable the render time capture
  46829. */
  46830. captureRenderTime: boolean;
  46831. /**
  46832. * Gets the perf counter used for camera render time capture
  46833. */
  46834. readonly cameraRenderTimeCounter: PerfCounter;
  46835. /**
  46836. * Gets the camera render time capture status
  46837. */
  46838. /**
  46839. * Enable or disable the camera render time capture
  46840. */
  46841. captureCameraRenderTime: boolean;
  46842. /**
  46843. * Gets the perf counter used for draw calls
  46844. */
  46845. readonly drawCallsCounter: PerfCounter;
  46846. /**
  46847. * Gets the perf counter used for texture collisions
  46848. */
  46849. readonly textureCollisionsCounter: PerfCounter;
  46850. /**
  46851. * Instantiates a new scene instrumentation.
  46852. * This class can be used to get instrumentation data from a Babylon engine
  46853. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46854. * @param scene Defines the scene to instrument
  46855. */
  46856. constructor(
  46857. /**
  46858. * Defines the scene to instrument
  46859. */
  46860. scene: Scene);
  46861. /**
  46862. * Dispose and release associated resources.
  46863. */
  46864. dispose(): void;
  46865. }
  46866. }
  46867. declare module "babylonjs/Instrumentation/index" {
  46868. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46869. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46870. export * from "babylonjs/Instrumentation/timeToken";
  46871. }
  46872. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46873. /** @hidden */
  46874. export var glowMapGenerationPixelShader: {
  46875. name: string;
  46876. shader: string;
  46877. };
  46878. }
  46879. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46880. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46881. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46882. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46883. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46884. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46885. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46886. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46887. /** @hidden */
  46888. export var glowMapGenerationVertexShader: {
  46889. name: string;
  46890. shader: string;
  46891. };
  46892. }
  46893. declare module "babylonjs/Layers/effectLayer" {
  46894. import { Observable } from "babylonjs/Misc/observable";
  46895. import { Nullable } from "babylonjs/types";
  46896. import { Camera } from "babylonjs/Cameras/camera";
  46897. import { Scene } from "babylonjs/scene";
  46898. import { Color4, ISize } from "babylonjs/Maths/math";
  46899. import { Engine } from "babylonjs/Engines/engine";
  46900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46902. import { Mesh } from "babylonjs/Meshes/mesh";
  46903. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46906. import { Effect } from "babylonjs/Materials/effect";
  46907. import { Material } from "babylonjs/Materials/material";
  46908. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46909. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46910. /**
  46911. * Effect layer options. This helps customizing the behaviour
  46912. * of the effect layer.
  46913. */
  46914. export interface IEffectLayerOptions {
  46915. /**
  46916. * Multiplication factor apply to the canvas size to compute the render target size
  46917. * used to generated the objects (the smaller the faster).
  46918. */
  46919. mainTextureRatio: number;
  46920. /**
  46921. * Enforces a fixed size texture to ensure effect stability across devices.
  46922. */
  46923. mainTextureFixedSize?: number;
  46924. /**
  46925. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46926. */
  46927. alphaBlendingMode: number;
  46928. /**
  46929. * The camera attached to the layer.
  46930. */
  46931. camera: Nullable<Camera>;
  46932. /**
  46933. * The rendering group to draw the layer in.
  46934. */
  46935. renderingGroupId: number;
  46936. }
  46937. /**
  46938. * The effect layer Helps adding post process effect blended with the main pass.
  46939. *
  46940. * This can be for instance use to generate glow or higlight effects on the scene.
  46941. *
  46942. * The effect layer class can not be used directly and is intented to inherited from to be
  46943. * customized per effects.
  46944. */
  46945. export abstract class EffectLayer {
  46946. private _vertexBuffers;
  46947. private _indexBuffer;
  46948. private _cachedDefines;
  46949. private _effectLayerMapGenerationEffect;
  46950. private _effectLayerOptions;
  46951. private _mergeEffect;
  46952. protected _scene: Scene;
  46953. protected _engine: Engine;
  46954. protected _maxSize: number;
  46955. protected _mainTextureDesiredSize: ISize;
  46956. protected _mainTexture: RenderTargetTexture;
  46957. protected _shouldRender: boolean;
  46958. protected _postProcesses: PostProcess[];
  46959. protected _textures: BaseTexture[];
  46960. protected _emissiveTextureAndColor: {
  46961. texture: Nullable<BaseTexture>;
  46962. color: Color4;
  46963. };
  46964. /**
  46965. * The name of the layer
  46966. */
  46967. name: string;
  46968. /**
  46969. * The clear color of the texture used to generate the glow map.
  46970. */
  46971. neutralColor: Color4;
  46972. /**
  46973. * Specifies wether the highlight layer is enabled or not.
  46974. */
  46975. isEnabled: boolean;
  46976. /**
  46977. * Gets the camera attached to the layer.
  46978. */
  46979. readonly camera: Nullable<Camera>;
  46980. /**
  46981. * Gets the rendering group id the layer should render in.
  46982. */
  46983. readonly renderingGroupId: number;
  46984. /**
  46985. * An event triggered when the effect layer has been disposed.
  46986. */
  46987. onDisposeObservable: Observable<EffectLayer>;
  46988. /**
  46989. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46990. */
  46991. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46992. /**
  46993. * An event triggered when the generated texture is being merged in the scene.
  46994. */
  46995. onBeforeComposeObservable: Observable<EffectLayer>;
  46996. /**
  46997. * An event triggered when the generated texture has been merged in the scene.
  46998. */
  46999. onAfterComposeObservable: Observable<EffectLayer>;
  47000. /**
  47001. * An event triggered when the efffect layer changes its size.
  47002. */
  47003. onSizeChangedObservable: Observable<EffectLayer>;
  47004. /** @hidden */
  47005. static _SceneComponentInitialization: (scene: Scene) => void;
  47006. /**
  47007. * Instantiates a new effect Layer and references it in the scene.
  47008. * @param name The name of the layer
  47009. * @param scene The scene to use the layer in
  47010. */
  47011. constructor(
  47012. /** The Friendly of the effect in the scene */
  47013. name: string, scene: Scene);
  47014. /**
  47015. * Get the effect name of the layer.
  47016. * @return The effect name
  47017. */
  47018. abstract getEffectName(): string;
  47019. /**
  47020. * Checks for the readiness of the element composing the layer.
  47021. * @param subMesh the mesh to check for
  47022. * @param useInstances specify wether or not to use instances to render the mesh
  47023. * @return true if ready otherwise, false
  47024. */
  47025. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47026. /**
  47027. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47028. * @returns true if the effect requires stencil during the main canvas render pass.
  47029. */
  47030. abstract needStencil(): boolean;
  47031. /**
  47032. * Create the merge effect. This is the shader use to blit the information back
  47033. * to the main canvas at the end of the scene rendering.
  47034. * @returns The effect containing the shader used to merge the effect on the main canvas
  47035. */
  47036. protected abstract _createMergeEffect(): Effect;
  47037. /**
  47038. * Creates the render target textures and post processes used in the effect layer.
  47039. */
  47040. protected abstract _createTextureAndPostProcesses(): void;
  47041. /**
  47042. * Implementation specific of rendering the generating effect on the main canvas.
  47043. * @param effect The effect used to render through
  47044. */
  47045. protected abstract _internalRender(effect: Effect): void;
  47046. /**
  47047. * Sets the required values for both the emissive texture and and the main color.
  47048. */
  47049. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47050. /**
  47051. * Free any resources and references associated to a mesh.
  47052. * Internal use
  47053. * @param mesh The mesh to free.
  47054. */
  47055. abstract _disposeMesh(mesh: Mesh): void;
  47056. /**
  47057. * Serializes this layer (Glow or Highlight for example)
  47058. * @returns a serialized layer object
  47059. */
  47060. abstract serialize?(): any;
  47061. /**
  47062. * Initializes the effect layer with the required options.
  47063. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47064. */
  47065. protected _init(options: Partial<IEffectLayerOptions>): void;
  47066. /**
  47067. * Generates the index buffer of the full screen quad blending to the main canvas.
  47068. */
  47069. private _generateIndexBuffer;
  47070. /**
  47071. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47072. */
  47073. private _genrateVertexBuffer;
  47074. /**
  47075. * Sets the main texture desired size which is the closest power of two
  47076. * of the engine canvas size.
  47077. */
  47078. private _setMainTextureSize;
  47079. /**
  47080. * Creates the main texture for the effect layer.
  47081. */
  47082. protected _createMainTexture(): void;
  47083. /**
  47084. * Adds specific effects defines.
  47085. * @param defines The defines to add specifics to.
  47086. */
  47087. protected _addCustomEffectDefines(defines: string[]): void;
  47088. /**
  47089. * Checks for the readiness of the element composing the layer.
  47090. * @param subMesh the mesh to check for
  47091. * @param useInstances specify wether or not to use instances to render the mesh
  47092. * @param emissiveTexture the associated emissive texture used to generate the glow
  47093. * @return true if ready otherwise, false
  47094. */
  47095. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47096. /**
  47097. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47098. */
  47099. render(): void;
  47100. /**
  47101. * Determine if a given mesh will be used in the current effect.
  47102. * @param mesh mesh to test
  47103. * @returns true if the mesh will be used
  47104. */
  47105. hasMesh(mesh: AbstractMesh): boolean;
  47106. /**
  47107. * Returns true if the layer contains information to display, otherwise false.
  47108. * @returns true if the glow layer should be rendered
  47109. */
  47110. shouldRender(): boolean;
  47111. /**
  47112. * Returns true if the mesh should render, otherwise false.
  47113. * @param mesh The mesh to render
  47114. * @returns true if it should render otherwise false
  47115. */
  47116. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47117. /**
  47118. * Returns true if the mesh can be rendered, otherwise false.
  47119. * @param mesh The mesh to render
  47120. * @param material The material used on the mesh
  47121. * @returns true if it can be rendered otherwise false
  47122. */
  47123. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47124. /**
  47125. * Returns true if the mesh should render, otherwise false.
  47126. * @param mesh The mesh to render
  47127. * @returns true if it should render otherwise false
  47128. */
  47129. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47130. /**
  47131. * Renders the submesh passed in parameter to the generation map.
  47132. */
  47133. protected _renderSubMesh(subMesh: SubMesh): void;
  47134. /**
  47135. * Rebuild the required buffers.
  47136. * @hidden Internal use only.
  47137. */
  47138. _rebuild(): void;
  47139. /**
  47140. * Dispose only the render target textures and post process.
  47141. */
  47142. private _disposeTextureAndPostProcesses;
  47143. /**
  47144. * Dispose the highlight layer and free resources.
  47145. */
  47146. dispose(): void;
  47147. /**
  47148. * Gets the class name of the effect layer
  47149. * @returns the string with the class name of the effect layer
  47150. */
  47151. getClassName(): string;
  47152. /**
  47153. * Creates an effect layer from parsed effect layer data
  47154. * @param parsedEffectLayer defines effect layer data
  47155. * @param scene defines the current scene
  47156. * @param rootUrl defines the root URL containing the effect layer information
  47157. * @returns a parsed effect Layer
  47158. */
  47159. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47160. }
  47161. }
  47162. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47163. import { Scene } from "babylonjs/scene";
  47164. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47165. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47166. import { AbstractScene } from "babylonjs/abstractScene";
  47167. module "babylonjs/abstractScene" {
  47168. interface AbstractScene {
  47169. /**
  47170. * The list of effect layers (highlights/glow) added to the scene
  47171. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47172. * @see http://doc.babylonjs.com/how_to/glow_layer
  47173. */
  47174. effectLayers: Array<EffectLayer>;
  47175. /**
  47176. * Removes the given effect layer from this scene.
  47177. * @param toRemove defines the effect layer to remove
  47178. * @returns the index of the removed effect layer
  47179. */
  47180. removeEffectLayer(toRemove: EffectLayer): number;
  47181. /**
  47182. * Adds the given effect layer to this scene
  47183. * @param newEffectLayer defines the effect layer to add
  47184. */
  47185. addEffectLayer(newEffectLayer: EffectLayer): void;
  47186. }
  47187. }
  47188. /**
  47189. * Defines the layer scene component responsible to manage any effect layers
  47190. * in a given scene.
  47191. */
  47192. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47193. /**
  47194. * The component name helpfull to identify the component in the list of scene components.
  47195. */
  47196. readonly name: string;
  47197. /**
  47198. * The scene the component belongs to.
  47199. */
  47200. scene: Scene;
  47201. private _engine;
  47202. private _renderEffects;
  47203. private _needStencil;
  47204. private _previousStencilState;
  47205. /**
  47206. * Creates a new instance of the component for the given scene
  47207. * @param scene Defines the scene to register the component in
  47208. */
  47209. constructor(scene: Scene);
  47210. /**
  47211. * Registers the component in a given scene
  47212. */
  47213. register(): void;
  47214. /**
  47215. * Rebuilds the elements related to this component in case of
  47216. * context lost for instance.
  47217. */
  47218. rebuild(): void;
  47219. /**
  47220. * Serializes the component data to the specified json object
  47221. * @param serializationObject The object to serialize to
  47222. */
  47223. serialize(serializationObject: any): void;
  47224. /**
  47225. * Adds all the element from the container to the scene
  47226. * @param container the container holding the elements
  47227. */
  47228. addFromContainer(container: AbstractScene): void;
  47229. /**
  47230. * Removes all the elements in the container from the scene
  47231. * @param container contains the elements to remove
  47232. */
  47233. removeFromContainer(container: AbstractScene): void;
  47234. /**
  47235. * Disposes the component and the associated ressources.
  47236. */
  47237. dispose(): void;
  47238. private _isReadyForMesh;
  47239. private _renderMainTexture;
  47240. private _setStencil;
  47241. private _setStencilBack;
  47242. private _draw;
  47243. private _drawCamera;
  47244. private _drawRenderingGroup;
  47245. }
  47246. }
  47247. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47248. /** @hidden */
  47249. export var glowMapMergePixelShader: {
  47250. name: string;
  47251. shader: string;
  47252. };
  47253. }
  47254. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47255. /** @hidden */
  47256. export var glowMapMergeVertexShader: {
  47257. name: string;
  47258. shader: string;
  47259. };
  47260. }
  47261. declare module "babylonjs/Layers/glowLayer" {
  47262. import { Nullable } from "babylonjs/types";
  47263. import { Camera } from "babylonjs/Cameras/camera";
  47264. import { Scene } from "babylonjs/scene";
  47265. import { Color4 } from "babylonjs/Maths/math";
  47266. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47268. import { Mesh } from "babylonjs/Meshes/mesh";
  47269. import { Texture } from "babylonjs/Materials/Textures/texture";
  47270. import { Effect } from "babylonjs/Materials/effect";
  47271. import { Material } from "babylonjs/Materials/material";
  47272. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47273. import "babylonjs/Shaders/glowMapMerge.fragment";
  47274. import "babylonjs/Shaders/glowMapMerge.vertex";
  47275. import "babylonjs/Layers/effectLayerSceneComponent";
  47276. module "babylonjs/abstractScene" {
  47277. interface AbstractScene {
  47278. /**
  47279. * Return a the first highlight layer of the scene with a given name.
  47280. * @param name The name of the highlight layer to look for.
  47281. * @return The highlight layer if found otherwise null.
  47282. */
  47283. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47284. }
  47285. }
  47286. /**
  47287. * Glow layer options. This helps customizing the behaviour
  47288. * of the glow layer.
  47289. */
  47290. export interface IGlowLayerOptions {
  47291. /**
  47292. * Multiplication factor apply to the canvas size to compute the render target size
  47293. * used to generated the glowing objects (the smaller the faster).
  47294. */
  47295. mainTextureRatio: number;
  47296. /**
  47297. * Enforces a fixed size texture to ensure resize independant blur.
  47298. */
  47299. mainTextureFixedSize?: number;
  47300. /**
  47301. * How big is the kernel of the blur texture.
  47302. */
  47303. blurKernelSize: number;
  47304. /**
  47305. * The camera attached to the layer.
  47306. */
  47307. camera: Nullable<Camera>;
  47308. /**
  47309. * Enable MSAA by chosing the number of samples.
  47310. */
  47311. mainTextureSamples?: number;
  47312. /**
  47313. * The rendering group to draw the layer in.
  47314. */
  47315. renderingGroupId: number;
  47316. }
  47317. /**
  47318. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47319. *
  47320. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47321. * glowy meshes to your scene.
  47322. *
  47323. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47324. */
  47325. export class GlowLayer extends EffectLayer {
  47326. /**
  47327. * Effect Name of the layer.
  47328. */
  47329. static readonly EffectName: string;
  47330. /**
  47331. * The default blur kernel size used for the glow.
  47332. */
  47333. static DefaultBlurKernelSize: number;
  47334. /**
  47335. * The default texture size ratio used for the glow.
  47336. */
  47337. static DefaultTextureRatio: number;
  47338. /**
  47339. * Sets the kernel size of the blur.
  47340. */
  47341. /**
  47342. * Gets the kernel size of the blur.
  47343. */
  47344. blurKernelSize: number;
  47345. /**
  47346. * Sets the glow intensity.
  47347. */
  47348. /**
  47349. * Gets the glow intensity.
  47350. */
  47351. intensity: number;
  47352. private _options;
  47353. private _intensity;
  47354. private _horizontalBlurPostprocess1;
  47355. private _verticalBlurPostprocess1;
  47356. private _horizontalBlurPostprocess2;
  47357. private _verticalBlurPostprocess2;
  47358. private _blurTexture1;
  47359. private _blurTexture2;
  47360. private _postProcesses1;
  47361. private _postProcesses2;
  47362. private _includedOnlyMeshes;
  47363. private _excludedMeshes;
  47364. /**
  47365. * Callback used to let the user override the color selection on a per mesh basis
  47366. */
  47367. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47368. /**
  47369. * Callback used to let the user override the texture selection on a per mesh basis
  47370. */
  47371. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47372. /**
  47373. * Instantiates a new glow Layer and references it to the scene.
  47374. * @param name The name of the layer
  47375. * @param scene The scene to use the layer in
  47376. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47377. */
  47378. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47379. /**
  47380. * Get the effect name of the layer.
  47381. * @return The effect name
  47382. */
  47383. getEffectName(): string;
  47384. /**
  47385. * Create the merge effect. This is the shader use to blit the information back
  47386. * to the main canvas at the end of the scene rendering.
  47387. */
  47388. protected _createMergeEffect(): Effect;
  47389. /**
  47390. * Creates the render target textures and post processes used in the glow layer.
  47391. */
  47392. protected _createTextureAndPostProcesses(): void;
  47393. /**
  47394. * Checks for the readiness of the element composing the layer.
  47395. * @param subMesh the mesh to check for
  47396. * @param useInstances specify wether or not to use instances to render the mesh
  47397. * @param emissiveTexture the associated emissive texture used to generate the glow
  47398. * @return true if ready otherwise, false
  47399. */
  47400. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47401. /**
  47402. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47403. */
  47404. needStencil(): boolean;
  47405. /**
  47406. * Returns true if the mesh can be rendered, otherwise false.
  47407. * @param mesh The mesh to render
  47408. * @param material The material used on the mesh
  47409. * @returns true if it can be rendered otherwise false
  47410. */
  47411. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47412. /**
  47413. * Implementation specific of rendering the generating effect on the main canvas.
  47414. * @param effect The effect used to render through
  47415. */
  47416. protected _internalRender(effect: Effect): void;
  47417. /**
  47418. * Sets the required values for both the emissive texture and and the main color.
  47419. */
  47420. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47421. /**
  47422. * Returns true if the mesh should render, otherwise false.
  47423. * @param mesh The mesh to render
  47424. * @returns true if it should render otherwise false
  47425. */
  47426. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47427. /**
  47428. * Adds specific effects defines.
  47429. * @param defines The defines to add specifics to.
  47430. */
  47431. protected _addCustomEffectDefines(defines: string[]): void;
  47432. /**
  47433. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47434. * @param mesh The mesh to exclude from the glow layer
  47435. */
  47436. addExcludedMesh(mesh: Mesh): void;
  47437. /**
  47438. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47439. * @param mesh The mesh to remove
  47440. */
  47441. removeExcludedMesh(mesh: Mesh): void;
  47442. /**
  47443. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47444. * @param mesh The mesh to include in the glow layer
  47445. */
  47446. addIncludedOnlyMesh(mesh: Mesh): void;
  47447. /**
  47448. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47449. * @param mesh The mesh to remove
  47450. */
  47451. removeIncludedOnlyMesh(mesh: Mesh): void;
  47452. /**
  47453. * Determine if a given mesh will be used in the glow layer
  47454. * @param mesh The mesh to test
  47455. * @returns true if the mesh will be highlighted by the current glow layer
  47456. */
  47457. hasMesh(mesh: AbstractMesh): boolean;
  47458. /**
  47459. * Free any resources and references associated to a mesh.
  47460. * Internal use
  47461. * @param mesh The mesh to free.
  47462. * @hidden
  47463. */
  47464. _disposeMesh(mesh: Mesh): void;
  47465. /**
  47466. * Gets the class name of the effect layer
  47467. * @returns the string with the class name of the effect layer
  47468. */
  47469. getClassName(): string;
  47470. /**
  47471. * Serializes this glow layer
  47472. * @returns a serialized glow layer object
  47473. */
  47474. serialize(): any;
  47475. /**
  47476. * Creates a Glow Layer from parsed glow layer data
  47477. * @param parsedGlowLayer defines glow layer data
  47478. * @param scene defines the current scene
  47479. * @param rootUrl defines the root URL containing the glow layer information
  47480. * @returns a parsed Glow Layer
  47481. */
  47482. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47483. }
  47484. }
  47485. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47486. /** @hidden */
  47487. export var glowBlurPostProcessPixelShader: {
  47488. name: string;
  47489. shader: string;
  47490. };
  47491. }
  47492. declare module "babylonjs/Layers/highlightLayer" {
  47493. import { Observable } from "babylonjs/Misc/observable";
  47494. import { Nullable } from "babylonjs/types";
  47495. import { Camera } from "babylonjs/Cameras/camera";
  47496. import { Scene } from "babylonjs/scene";
  47497. import { Color3, Color4 } from "babylonjs/Maths/math";
  47498. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47500. import { Mesh } from "babylonjs/Meshes/mesh";
  47501. import { Effect } from "babylonjs/Materials/effect";
  47502. import { Material } from "babylonjs/Materials/material";
  47503. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47504. import "babylonjs/Shaders/glowMapMerge.fragment";
  47505. import "babylonjs/Shaders/glowMapMerge.vertex";
  47506. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47507. module "babylonjs/abstractScene" {
  47508. interface AbstractScene {
  47509. /**
  47510. * Return a the first highlight layer of the scene with a given name.
  47511. * @param name The name of the highlight layer to look for.
  47512. * @return The highlight layer if found otherwise null.
  47513. */
  47514. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47515. }
  47516. }
  47517. /**
  47518. * Highlight layer options. This helps customizing the behaviour
  47519. * of the highlight layer.
  47520. */
  47521. export interface IHighlightLayerOptions {
  47522. /**
  47523. * Multiplication factor apply to the canvas size to compute the render target size
  47524. * used to generated the glowing objects (the smaller the faster).
  47525. */
  47526. mainTextureRatio: number;
  47527. /**
  47528. * Enforces a fixed size texture to ensure resize independant blur.
  47529. */
  47530. mainTextureFixedSize?: number;
  47531. /**
  47532. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47533. * of the picture to blur (the smaller the faster).
  47534. */
  47535. blurTextureSizeRatio: number;
  47536. /**
  47537. * How big in texel of the blur texture is the vertical blur.
  47538. */
  47539. blurVerticalSize: number;
  47540. /**
  47541. * How big in texel of the blur texture is the horizontal blur.
  47542. */
  47543. blurHorizontalSize: number;
  47544. /**
  47545. * Alpha blending mode used to apply the blur. Default is combine.
  47546. */
  47547. alphaBlendingMode: number;
  47548. /**
  47549. * The camera attached to the layer.
  47550. */
  47551. camera: Nullable<Camera>;
  47552. /**
  47553. * Should we display highlight as a solid stroke?
  47554. */
  47555. isStroke?: boolean;
  47556. /**
  47557. * The rendering group to draw the layer in.
  47558. */
  47559. renderingGroupId: number;
  47560. }
  47561. /**
  47562. * The highlight layer Helps adding a glow effect around a mesh.
  47563. *
  47564. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47565. * glowy meshes to your scene.
  47566. *
  47567. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47568. */
  47569. export class HighlightLayer extends EffectLayer {
  47570. name: string;
  47571. /**
  47572. * Effect Name of the highlight layer.
  47573. */
  47574. static readonly EffectName: string;
  47575. /**
  47576. * The neutral color used during the preparation of the glow effect.
  47577. * This is black by default as the blend operation is a blend operation.
  47578. */
  47579. static NeutralColor: Color4;
  47580. /**
  47581. * Stencil value used for glowing meshes.
  47582. */
  47583. static GlowingMeshStencilReference: number;
  47584. /**
  47585. * Stencil value used for the other meshes in the scene.
  47586. */
  47587. static NormalMeshStencilReference: number;
  47588. /**
  47589. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47590. */
  47591. innerGlow: boolean;
  47592. /**
  47593. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47594. */
  47595. outerGlow: boolean;
  47596. /**
  47597. * Specifies the horizontal size of the blur.
  47598. */
  47599. /**
  47600. * Gets the horizontal size of the blur.
  47601. */
  47602. blurHorizontalSize: number;
  47603. /**
  47604. * Specifies the vertical size of the blur.
  47605. */
  47606. /**
  47607. * Gets the vertical size of the blur.
  47608. */
  47609. blurVerticalSize: number;
  47610. /**
  47611. * An event triggered when the highlight layer is being blurred.
  47612. */
  47613. onBeforeBlurObservable: Observable<HighlightLayer>;
  47614. /**
  47615. * An event triggered when the highlight layer has been blurred.
  47616. */
  47617. onAfterBlurObservable: Observable<HighlightLayer>;
  47618. private _instanceGlowingMeshStencilReference;
  47619. private _options;
  47620. private _downSamplePostprocess;
  47621. private _horizontalBlurPostprocess;
  47622. private _verticalBlurPostprocess;
  47623. private _blurTexture;
  47624. private _meshes;
  47625. private _excludedMeshes;
  47626. /**
  47627. * Instantiates a new highlight Layer and references it to the scene..
  47628. * @param name The name of the layer
  47629. * @param scene The scene to use the layer in
  47630. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47631. */
  47632. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47633. /**
  47634. * Get the effect name of the layer.
  47635. * @return The effect name
  47636. */
  47637. getEffectName(): string;
  47638. /**
  47639. * Create the merge effect. This is the shader use to blit the information back
  47640. * to the main canvas at the end of the scene rendering.
  47641. */
  47642. protected _createMergeEffect(): Effect;
  47643. /**
  47644. * Creates the render target textures and post processes used in the highlight layer.
  47645. */
  47646. protected _createTextureAndPostProcesses(): void;
  47647. /**
  47648. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47649. */
  47650. needStencil(): boolean;
  47651. /**
  47652. * Checks for the readiness of the element composing the layer.
  47653. * @param subMesh the mesh to check for
  47654. * @param useInstances specify wether or not to use instances to render the mesh
  47655. * @param emissiveTexture the associated emissive texture used to generate the glow
  47656. * @return true if ready otherwise, false
  47657. */
  47658. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47659. /**
  47660. * Implementation specific of rendering the generating effect on the main canvas.
  47661. * @param effect The effect used to render through
  47662. */
  47663. protected _internalRender(effect: Effect): void;
  47664. /**
  47665. * Returns true if the layer contains information to display, otherwise false.
  47666. */
  47667. shouldRender(): boolean;
  47668. /**
  47669. * Returns true if the mesh should render, otherwise false.
  47670. * @param mesh The mesh to render
  47671. * @returns true if it should render otherwise false
  47672. */
  47673. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47674. /**
  47675. * Sets the required values for both the emissive texture and and the main color.
  47676. */
  47677. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47678. /**
  47679. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47680. * @param mesh The mesh to exclude from the highlight layer
  47681. */
  47682. addExcludedMesh(mesh: Mesh): void;
  47683. /**
  47684. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47685. * @param mesh The mesh to highlight
  47686. */
  47687. removeExcludedMesh(mesh: Mesh): void;
  47688. /**
  47689. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47690. * @param mesh mesh to test
  47691. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47692. */
  47693. hasMesh(mesh: AbstractMesh): boolean;
  47694. /**
  47695. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47696. * @param mesh The mesh to highlight
  47697. * @param color The color of the highlight
  47698. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47699. */
  47700. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47701. /**
  47702. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47703. * @param mesh The mesh to highlight
  47704. */
  47705. removeMesh(mesh: Mesh): void;
  47706. /**
  47707. * Force the stencil to the normal expected value for none glowing parts
  47708. */
  47709. private _defaultStencilReference;
  47710. /**
  47711. * Free any resources and references associated to a mesh.
  47712. * Internal use
  47713. * @param mesh The mesh to free.
  47714. * @hidden
  47715. */
  47716. _disposeMesh(mesh: Mesh): void;
  47717. /**
  47718. * Dispose the highlight layer and free resources.
  47719. */
  47720. dispose(): void;
  47721. /**
  47722. * Gets the class name of the effect layer
  47723. * @returns the string with the class name of the effect layer
  47724. */
  47725. getClassName(): string;
  47726. /**
  47727. * Serializes this Highlight layer
  47728. * @returns a serialized Highlight layer object
  47729. */
  47730. serialize(): any;
  47731. /**
  47732. * Creates a Highlight layer from parsed Highlight layer data
  47733. * @param parsedHightlightLayer defines the Highlight layer data
  47734. * @param scene defines the current scene
  47735. * @param rootUrl defines the root URL containing the Highlight layer information
  47736. * @returns a parsed Highlight layer
  47737. */
  47738. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47739. }
  47740. }
  47741. declare module "babylonjs/Layers/index" {
  47742. export * from "babylonjs/Layers/effectLayer";
  47743. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47744. export * from "babylonjs/Layers/glowLayer";
  47745. export * from "babylonjs/Layers/highlightLayer";
  47746. export * from "babylonjs/Layers/layer";
  47747. export * from "babylonjs/Layers/layerSceneComponent";
  47748. }
  47749. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47750. /** @hidden */
  47751. export var lensFlarePixelShader: {
  47752. name: string;
  47753. shader: string;
  47754. };
  47755. }
  47756. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47757. /** @hidden */
  47758. export var lensFlareVertexShader: {
  47759. name: string;
  47760. shader: string;
  47761. };
  47762. }
  47763. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47764. import { Scene } from "babylonjs/scene";
  47765. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47767. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47768. import "babylonjs/Shaders/lensFlare.fragment";
  47769. import "babylonjs/Shaders/lensFlare.vertex";
  47770. /**
  47771. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47772. * It is usually composed of several `lensFlare`.
  47773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47774. */
  47775. export class LensFlareSystem {
  47776. /**
  47777. * Define the name of the lens flare system
  47778. */
  47779. name: string;
  47780. /**
  47781. * List of lens flares used in this system.
  47782. */
  47783. lensFlares: LensFlare[];
  47784. /**
  47785. * Define a limit from the border the lens flare can be visible.
  47786. */
  47787. borderLimit: number;
  47788. /**
  47789. * Define a viewport border we do not want to see the lens flare in.
  47790. */
  47791. viewportBorder: number;
  47792. /**
  47793. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47794. */
  47795. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47796. /**
  47797. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47798. */
  47799. layerMask: number;
  47800. /**
  47801. * Define the id of the lens flare system in the scene.
  47802. * (equal to name by default)
  47803. */
  47804. id: string;
  47805. private _scene;
  47806. private _emitter;
  47807. private _vertexBuffers;
  47808. private _indexBuffer;
  47809. private _effect;
  47810. private _positionX;
  47811. private _positionY;
  47812. private _isEnabled;
  47813. /** @hidden */
  47814. static _SceneComponentInitialization: (scene: Scene) => void;
  47815. /**
  47816. * Instantiates a lens flare system.
  47817. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47818. * It is usually composed of several `lensFlare`.
  47819. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47820. * @param name Define the name of the lens flare system in the scene
  47821. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47822. * @param scene Define the scene the lens flare system belongs to
  47823. */
  47824. constructor(
  47825. /**
  47826. * Define the name of the lens flare system
  47827. */
  47828. name: string, emitter: any, scene: Scene);
  47829. /**
  47830. * Define if the lens flare system is enabled.
  47831. */
  47832. isEnabled: boolean;
  47833. /**
  47834. * Get the scene the effects belongs to.
  47835. * @returns the scene holding the lens flare system
  47836. */
  47837. getScene(): Scene;
  47838. /**
  47839. * Get the emitter of the lens flare system.
  47840. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47841. * @returns the emitter of the lens flare system
  47842. */
  47843. getEmitter(): any;
  47844. /**
  47845. * Set the emitter of the lens flare system.
  47846. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47847. * @param newEmitter Define the new emitter of the system
  47848. */
  47849. setEmitter(newEmitter: any): void;
  47850. /**
  47851. * Get the lens flare system emitter position.
  47852. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47853. * @returns the position
  47854. */
  47855. getEmitterPosition(): Vector3;
  47856. /**
  47857. * @hidden
  47858. */
  47859. computeEffectivePosition(globalViewport: Viewport): boolean;
  47860. /** @hidden */
  47861. _isVisible(): boolean;
  47862. /**
  47863. * @hidden
  47864. */
  47865. render(): boolean;
  47866. /**
  47867. * Dispose and release the lens flare with its associated resources.
  47868. */
  47869. dispose(): void;
  47870. /**
  47871. * Parse a lens flare system from a JSON repressentation
  47872. * @param parsedLensFlareSystem Define the JSON to parse
  47873. * @param scene Define the scene the parsed system should be instantiated in
  47874. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47875. * @returns the parsed system
  47876. */
  47877. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47878. /**
  47879. * Serialize the current Lens Flare System into a JSON representation.
  47880. * @returns the serialized JSON
  47881. */
  47882. serialize(): any;
  47883. }
  47884. }
  47885. declare module "babylonjs/LensFlares/lensFlare" {
  47886. import { Nullable } from "babylonjs/types";
  47887. import { Color3 } from "babylonjs/Maths/math";
  47888. import { Texture } from "babylonjs/Materials/Textures/texture";
  47889. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47890. /**
  47891. * This represents one of the lens effect in a `lensFlareSystem`.
  47892. * It controls one of the indiviual texture used in the effect.
  47893. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47894. */
  47895. export class LensFlare {
  47896. /**
  47897. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47898. */
  47899. size: number;
  47900. /**
  47901. * 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.
  47902. */
  47903. position: number;
  47904. /**
  47905. * Define the lens color.
  47906. */
  47907. color: Color3;
  47908. /**
  47909. * Define the lens texture.
  47910. */
  47911. texture: Nullable<Texture>;
  47912. /**
  47913. * Define the alpha mode to render this particular lens.
  47914. */
  47915. alphaMode: number;
  47916. private _system;
  47917. /**
  47918. * Creates a new Lens Flare.
  47919. * This represents one of the lens effect in a `lensFlareSystem`.
  47920. * It controls one of the indiviual texture used in the effect.
  47921. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47922. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47923. * @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.
  47924. * @param color Define the lens color
  47925. * @param imgUrl Define the lens texture url
  47926. * @param system Define the `lensFlareSystem` this flare is part of
  47927. * @returns The newly created Lens Flare
  47928. */
  47929. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47930. /**
  47931. * Instantiates a new Lens Flare.
  47932. * This represents one of the lens effect in a `lensFlareSystem`.
  47933. * It controls one of the indiviual texture used in the effect.
  47934. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47935. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47936. * @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.
  47937. * @param color Define the lens color
  47938. * @param imgUrl Define the lens texture url
  47939. * @param system Define the `lensFlareSystem` this flare is part of
  47940. */
  47941. constructor(
  47942. /**
  47943. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47944. */
  47945. size: number,
  47946. /**
  47947. * 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.
  47948. */
  47949. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47950. /**
  47951. * Dispose and release the lens flare with its associated resources.
  47952. */
  47953. dispose(): void;
  47954. }
  47955. }
  47956. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47957. import { Nullable } from "babylonjs/types";
  47958. import { Scene } from "babylonjs/scene";
  47959. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47960. import { AbstractScene } from "babylonjs/abstractScene";
  47961. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47962. module "babylonjs/abstractScene" {
  47963. interface AbstractScene {
  47964. /**
  47965. * The list of lens flare system added to the scene
  47966. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47967. */
  47968. lensFlareSystems: Array<LensFlareSystem>;
  47969. /**
  47970. * Removes the given lens flare system from this scene.
  47971. * @param toRemove The lens flare system to remove
  47972. * @returns The index of the removed lens flare system
  47973. */
  47974. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47975. /**
  47976. * Adds the given lens flare system to this scene
  47977. * @param newLensFlareSystem The lens flare system to add
  47978. */
  47979. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47980. /**
  47981. * Gets a lens flare system using its name
  47982. * @param name defines the name to look for
  47983. * @returns the lens flare system or null if not found
  47984. */
  47985. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47986. /**
  47987. * Gets a lens flare system using its id
  47988. * @param id defines the id to look for
  47989. * @returns the lens flare system or null if not found
  47990. */
  47991. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47992. }
  47993. }
  47994. /**
  47995. * Defines the lens flare scene component responsible to manage any lens flares
  47996. * in a given scene.
  47997. */
  47998. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47999. /**
  48000. * The component name helpfull to identify the component in the list of scene components.
  48001. */
  48002. readonly name: string;
  48003. /**
  48004. * The scene the component belongs to.
  48005. */
  48006. scene: Scene;
  48007. /**
  48008. * Creates a new instance of the component for the given scene
  48009. * @param scene Defines the scene to register the component in
  48010. */
  48011. constructor(scene: Scene);
  48012. /**
  48013. * Registers the component in a given scene
  48014. */
  48015. register(): void;
  48016. /**
  48017. * Rebuilds the elements related to this component in case of
  48018. * context lost for instance.
  48019. */
  48020. rebuild(): void;
  48021. /**
  48022. * Adds all the element from the container to the scene
  48023. * @param container the container holding the elements
  48024. */
  48025. addFromContainer(container: AbstractScene): void;
  48026. /**
  48027. * Removes all the elements in the container from the scene
  48028. * @param container contains the elements to remove
  48029. */
  48030. removeFromContainer(container: AbstractScene): void;
  48031. /**
  48032. * Serializes the component data to the specified json object
  48033. * @param serializationObject The object to serialize to
  48034. */
  48035. serialize(serializationObject: any): void;
  48036. /**
  48037. * Disposes the component and the associated ressources.
  48038. */
  48039. dispose(): void;
  48040. private _draw;
  48041. }
  48042. }
  48043. declare module "babylonjs/LensFlares/index" {
  48044. export * from "babylonjs/LensFlares/lensFlare";
  48045. export * from "babylonjs/LensFlares/lensFlareSystem";
  48046. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48047. }
  48048. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48049. import { Scene } from "babylonjs/scene";
  48050. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48051. import { AbstractScene } from "babylonjs/abstractScene";
  48052. /**
  48053. * Defines the shadow generator component responsible to manage any shadow generators
  48054. * in a given scene.
  48055. */
  48056. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48057. /**
  48058. * The component name helpfull to identify the component in the list of scene components.
  48059. */
  48060. readonly name: string;
  48061. /**
  48062. * The scene the component belongs to.
  48063. */
  48064. scene: Scene;
  48065. /**
  48066. * Creates a new instance of the component for the given scene
  48067. * @param scene Defines the scene to register the component in
  48068. */
  48069. constructor(scene: Scene);
  48070. /**
  48071. * Registers the component in a given scene
  48072. */
  48073. register(): void;
  48074. /**
  48075. * Rebuilds the elements related to this component in case of
  48076. * context lost for instance.
  48077. */
  48078. rebuild(): void;
  48079. /**
  48080. * Serializes the component data to the specified json object
  48081. * @param serializationObject The object to serialize to
  48082. */
  48083. serialize(serializationObject: any): void;
  48084. /**
  48085. * Adds all the element from the container to the scene
  48086. * @param container the container holding the elements
  48087. */
  48088. addFromContainer(container: AbstractScene): void;
  48089. /**
  48090. * Removes all the elements in the container from the scene
  48091. * @param container contains the elements to remove
  48092. */
  48093. removeFromContainer(container: AbstractScene): void;
  48094. /**
  48095. * Rebuilds the elements related to this component in case of
  48096. * context lost for instance.
  48097. */
  48098. dispose(): void;
  48099. private _gatherRenderTargets;
  48100. }
  48101. }
  48102. declare module "babylonjs/Lights/Shadows/index" {
  48103. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48104. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48105. }
  48106. declare module "babylonjs/Lights/directionalLight" {
  48107. import { Camera } from "babylonjs/Cameras/camera";
  48108. import { Scene } from "babylonjs/scene";
  48109. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48111. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48112. import { Effect } from "babylonjs/Materials/effect";
  48113. /**
  48114. * A directional light is defined by a direction (what a surprise!).
  48115. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48116. * 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.
  48117. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48118. */
  48119. export class DirectionalLight extends ShadowLight {
  48120. private _shadowFrustumSize;
  48121. /**
  48122. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48123. */
  48124. /**
  48125. * Specifies a fix frustum size for the shadow generation.
  48126. */
  48127. shadowFrustumSize: number;
  48128. private _shadowOrthoScale;
  48129. /**
  48130. * Gets the shadow projection scale against the optimal computed one.
  48131. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48132. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48133. */
  48134. /**
  48135. * Sets the shadow projection scale against the optimal computed one.
  48136. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48137. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48138. */
  48139. shadowOrthoScale: number;
  48140. /**
  48141. * Automatically compute the projection matrix to best fit (including all the casters)
  48142. * on each frame.
  48143. */
  48144. autoUpdateExtends: boolean;
  48145. private _orthoLeft;
  48146. private _orthoRight;
  48147. private _orthoTop;
  48148. private _orthoBottom;
  48149. /**
  48150. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48151. * The directional light is emitted from everywhere in the given direction.
  48152. * It can cast shadows.
  48153. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48154. * @param name The friendly name of the light
  48155. * @param direction The direction of the light
  48156. * @param scene The scene the light belongs to
  48157. */
  48158. constructor(name: string, direction: Vector3, scene: Scene);
  48159. /**
  48160. * Returns the string "DirectionalLight".
  48161. * @return The class name
  48162. */
  48163. getClassName(): string;
  48164. /**
  48165. * Returns the integer 1.
  48166. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48167. */
  48168. getTypeID(): number;
  48169. /**
  48170. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48171. * Returns the DirectionalLight Shadow projection matrix.
  48172. */
  48173. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48174. /**
  48175. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48176. * Returns the DirectionalLight Shadow projection matrix.
  48177. */
  48178. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48179. /**
  48180. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48181. * Returns the DirectionalLight Shadow projection matrix.
  48182. */
  48183. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48184. protected _buildUniformLayout(): void;
  48185. /**
  48186. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48187. * @param effect The effect to update
  48188. * @param lightIndex The index of the light in the effect to update
  48189. * @returns The directional light
  48190. */
  48191. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48192. /**
  48193. * Gets the minZ used for shadow according to both the scene and the light.
  48194. *
  48195. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48196. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48197. * @param activeCamera The camera we are returning the min for
  48198. * @returns the depth min z
  48199. */
  48200. getDepthMinZ(activeCamera: Camera): number;
  48201. /**
  48202. * Gets the maxZ used for shadow according to both the scene and the light.
  48203. *
  48204. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48205. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48206. * @param activeCamera The camera we are returning the max for
  48207. * @returns the depth max z
  48208. */
  48209. getDepthMaxZ(activeCamera: Camera): number;
  48210. /**
  48211. * Prepares the list of defines specific to the light type.
  48212. * @param defines the list of defines
  48213. * @param lightIndex defines the index of the light for the effect
  48214. */
  48215. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48216. }
  48217. }
  48218. declare module "babylonjs/Lights/pointLight" {
  48219. import { Scene } from "babylonjs/scene";
  48220. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48222. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48223. import { Effect } from "babylonjs/Materials/effect";
  48224. /**
  48225. * A point light is a light defined by an unique point in world space.
  48226. * The light is emitted in every direction from this point.
  48227. * A good example of a point light is a standard light bulb.
  48228. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48229. */
  48230. export class PointLight extends ShadowLight {
  48231. private _shadowAngle;
  48232. /**
  48233. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48234. * This specifies what angle the shadow will use to be created.
  48235. *
  48236. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48237. */
  48238. /**
  48239. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48240. * This specifies what angle the shadow will use to be created.
  48241. *
  48242. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48243. */
  48244. shadowAngle: number;
  48245. /**
  48246. * Gets the direction if it has been set.
  48247. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48248. */
  48249. /**
  48250. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48251. */
  48252. direction: Vector3;
  48253. /**
  48254. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48255. * A PointLight emits the light in every direction.
  48256. * It can cast shadows.
  48257. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48258. * ```javascript
  48259. * var pointLight = new PointLight("pl", camera.position, scene);
  48260. * ```
  48261. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48262. * @param name The light friendly name
  48263. * @param position The position of the point light in the scene
  48264. * @param scene The scene the lights belongs to
  48265. */
  48266. constructor(name: string, position: Vector3, scene: Scene);
  48267. /**
  48268. * Returns the string "PointLight"
  48269. * @returns the class name
  48270. */
  48271. getClassName(): string;
  48272. /**
  48273. * Returns the integer 0.
  48274. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48275. */
  48276. getTypeID(): number;
  48277. /**
  48278. * Specifies wether or not the shadowmap should be a cube texture.
  48279. * @returns true if the shadowmap needs to be a cube texture.
  48280. */
  48281. needCube(): boolean;
  48282. /**
  48283. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48284. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48285. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48286. */
  48287. getShadowDirection(faceIndex?: number): Vector3;
  48288. /**
  48289. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48290. * - fov = PI / 2
  48291. * - aspect ratio : 1.0
  48292. * - z-near and far equal to the active camera minZ and maxZ.
  48293. * Returns the PointLight.
  48294. */
  48295. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48296. protected _buildUniformLayout(): void;
  48297. /**
  48298. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48299. * @param effect The effect to update
  48300. * @param lightIndex The index of the light in the effect to update
  48301. * @returns The point light
  48302. */
  48303. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48304. /**
  48305. * Prepares the list of defines specific to the light type.
  48306. * @param defines the list of defines
  48307. * @param lightIndex defines the index of the light for the effect
  48308. */
  48309. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48310. }
  48311. }
  48312. declare module "babylonjs/Lights/spotLight" {
  48313. import { Nullable } from "babylonjs/types";
  48314. import { Scene } from "babylonjs/scene";
  48315. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48317. import { Effect } from "babylonjs/Materials/effect";
  48318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48319. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48320. /**
  48321. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48322. * These values define a cone of light starting from the position, emitting toward the direction.
  48323. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48324. * and the exponent defines the speed of the decay of the light with distance (reach).
  48325. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48326. */
  48327. export class SpotLight extends ShadowLight {
  48328. private _angle;
  48329. private _innerAngle;
  48330. private _cosHalfAngle;
  48331. private _lightAngleScale;
  48332. private _lightAngleOffset;
  48333. /**
  48334. * Gets the cone angle of the spot light in Radians.
  48335. */
  48336. /**
  48337. * Sets the cone angle of the spot light in Radians.
  48338. */
  48339. angle: number;
  48340. /**
  48341. * Only used in gltf falloff mode, this defines the angle where
  48342. * the directional falloff will start before cutting at angle which could be seen
  48343. * as outer angle.
  48344. */
  48345. /**
  48346. * Only used in gltf falloff mode, this defines the angle where
  48347. * the directional falloff will start before cutting at angle which could be seen
  48348. * as outer angle.
  48349. */
  48350. innerAngle: number;
  48351. private _shadowAngleScale;
  48352. /**
  48353. * Allows scaling the angle of the light for shadow generation only.
  48354. */
  48355. /**
  48356. * Allows scaling the angle of the light for shadow generation only.
  48357. */
  48358. shadowAngleScale: number;
  48359. /**
  48360. * The light decay speed with the distance from the emission spot.
  48361. */
  48362. exponent: number;
  48363. private _projectionTextureMatrix;
  48364. /**
  48365. * Allows reading the projecton texture
  48366. */
  48367. readonly projectionTextureMatrix: Matrix;
  48368. protected _projectionTextureLightNear: number;
  48369. /**
  48370. * Gets the near clip of the Spotlight for texture projection.
  48371. */
  48372. /**
  48373. * Sets the near clip of the Spotlight for texture projection.
  48374. */
  48375. projectionTextureLightNear: number;
  48376. protected _projectionTextureLightFar: number;
  48377. /**
  48378. * Gets the far clip of the Spotlight for texture projection.
  48379. */
  48380. /**
  48381. * Sets the far clip of the Spotlight for texture projection.
  48382. */
  48383. projectionTextureLightFar: number;
  48384. protected _projectionTextureUpDirection: Vector3;
  48385. /**
  48386. * Gets the Up vector of the Spotlight for texture projection.
  48387. */
  48388. /**
  48389. * Sets the Up vector of the Spotlight for texture projection.
  48390. */
  48391. projectionTextureUpDirection: Vector3;
  48392. private _projectionTexture;
  48393. /**
  48394. * Gets the projection texture of the light.
  48395. */
  48396. /**
  48397. * Sets the projection texture of the light.
  48398. */
  48399. projectionTexture: Nullable<BaseTexture>;
  48400. private _projectionTextureViewLightDirty;
  48401. private _projectionTextureProjectionLightDirty;
  48402. private _projectionTextureDirty;
  48403. private _projectionTextureViewTargetVector;
  48404. private _projectionTextureViewLightMatrix;
  48405. private _projectionTextureProjectionLightMatrix;
  48406. private _projectionTextureScalingMatrix;
  48407. /**
  48408. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48409. * It can cast shadows.
  48410. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48411. * @param name The light friendly name
  48412. * @param position The position of the spot light in the scene
  48413. * @param direction The direction of the light in the scene
  48414. * @param angle The cone angle of the light in Radians
  48415. * @param exponent The light decay speed with the distance from the emission spot
  48416. * @param scene The scene the lights belongs to
  48417. */
  48418. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48419. /**
  48420. * Returns the string "SpotLight".
  48421. * @returns the class name
  48422. */
  48423. getClassName(): string;
  48424. /**
  48425. * Returns the integer 2.
  48426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48427. */
  48428. getTypeID(): number;
  48429. /**
  48430. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48431. */
  48432. protected _setDirection(value: Vector3): void;
  48433. /**
  48434. * Overrides the position setter to recompute the projection texture view light Matrix.
  48435. */
  48436. protected _setPosition(value: Vector3): void;
  48437. /**
  48438. * 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.
  48439. * Returns the SpotLight.
  48440. */
  48441. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48442. protected _computeProjectionTextureViewLightMatrix(): void;
  48443. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48444. /**
  48445. * Main function for light texture projection matrix computing.
  48446. */
  48447. protected _computeProjectionTextureMatrix(): void;
  48448. protected _buildUniformLayout(): void;
  48449. private _computeAngleValues;
  48450. /**
  48451. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48452. * @param effect The effect to update
  48453. * @param lightIndex The index of the light in the effect to update
  48454. * @returns The spot light
  48455. */
  48456. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48457. /**
  48458. * Disposes the light and the associated resources.
  48459. */
  48460. dispose(): void;
  48461. /**
  48462. * Prepares the list of defines specific to the light type.
  48463. * @param defines the list of defines
  48464. * @param lightIndex defines the index of the light for the effect
  48465. */
  48466. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48467. }
  48468. }
  48469. declare module "babylonjs/Lights/index" {
  48470. export * from "babylonjs/Lights/light";
  48471. export * from "babylonjs/Lights/shadowLight";
  48472. export * from "babylonjs/Lights/Shadows/index";
  48473. export * from "babylonjs/Lights/directionalLight";
  48474. export * from "babylonjs/Lights/hemisphericLight";
  48475. export * from "babylonjs/Lights/pointLight";
  48476. export * from "babylonjs/Lights/spotLight";
  48477. }
  48478. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48479. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48480. /**
  48481. * Header information of HDR texture files.
  48482. */
  48483. export interface HDRInfo {
  48484. /**
  48485. * The height of the texture in pixels.
  48486. */
  48487. height: number;
  48488. /**
  48489. * The width of the texture in pixels.
  48490. */
  48491. width: number;
  48492. /**
  48493. * The index of the beginning of the data in the binary file.
  48494. */
  48495. dataPosition: number;
  48496. }
  48497. /**
  48498. * This groups tools to convert HDR texture to native colors array.
  48499. */
  48500. export class HDRTools {
  48501. private static Ldexp;
  48502. private static Rgbe2float;
  48503. private static readStringLine;
  48504. /**
  48505. * Reads header information from an RGBE texture stored in a native array.
  48506. * More information on this format are available here:
  48507. * https://en.wikipedia.org/wiki/RGBE_image_format
  48508. *
  48509. * @param uint8array The binary file stored in native array.
  48510. * @return The header information.
  48511. */
  48512. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48513. /**
  48514. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48515. * This RGBE texture needs to store the information as a panorama.
  48516. *
  48517. * More information on this format are available here:
  48518. * https://en.wikipedia.org/wiki/RGBE_image_format
  48519. *
  48520. * @param buffer The binary file stored in an array buffer.
  48521. * @param size The expected size of the extracted cubemap.
  48522. * @return The Cube Map information.
  48523. */
  48524. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48525. /**
  48526. * Returns the pixels data extracted from an RGBE texture.
  48527. * This pixels will be stored left to right up to down in the R G B order in one array.
  48528. *
  48529. * More information on this format are available here:
  48530. * https://en.wikipedia.org/wiki/RGBE_image_format
  48531. *
  48532. * @param uint8array The binary file stored in an array buffer.
  48533. * @param hdrInfo The header information of the file.
  48534. * @return The pixels data in RGB right to left up to down order.
  48535. */
  48536. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48537. private static RGBE_ReadPixels_RLE;
  48538. }
  48539. }
  48540. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48541. import { Nullable } from "babylonjs/types";
  48542. import { Scene } from "babylonjs/scene";
  48543. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48544. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48545. /**
  48546. * This represents a texture coming from an HDR input.
  48547. *
  48548. * The only supported format is currently panorama picture stored in RGBE format.
  48549. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48550. */
  48551. export class HDRCubeTexture extends BaseTexture {
  48552. private static _facesMapping;
  48553. private _generateHarmonics;
  48554. private _noMipmap;
  48555. private _textureMatrix;
  48556. private _size;
  48557. private _onLoad;
  48558. private _onError;
  48559. /**
  48560. * The texture URL.
  48561. */
  48562. url: string;
  48563. /**
  48564. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48565. */
  48566. coordinatesMode: number;
  48567. protected _isBlocking: boolean;
  48568. /**
  48569. * Sets wether or not the texture is blocking during loading.
  48570. */
  48571. /**
  48572. * Gets wether or not the texture is blocking during loading.
  48573. */
  48574. isBlocking: boolean;
  48575. protected _rotationY: number;
  48576. /**
  48577. * Sets texture matrix rotation angle around Y axis in radians.
  48578. */
  48579. /**
  48580. * Gets texture matrix rotation angle around Y axis radians.
  48581. */
  48582. rotationY: number;
  48583. /**
  48584. * Gets or sets the center of the bounding box associated with the cube texture
  48585. * It must define where the camera used to render the texture was set
  48586. */
  48587. boundingBoxPosition: Vector3;
  48588. private _boundingBoxSize;
  48589. /**
  48590. * Gets or sets the size of the bounding box associated with the cube texture
  48591. * When defined, the cubemap will switch to local mode
  48592. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48593. * @example https://www.babylonjs-playground.com/#RNASML
  48594. */
  48595. boundingBoxSize: Vector3;
  48596. /**
  48597. * Instantiates an HDRTexture from the following parameters.
  48598. *
  48599. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48600. * @param scene The scene the texture will be used in
  48601. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48602. * @param noMipmap Forces to not generate the mipmap if true
  48603. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48604. * @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)
  48605. * @param reserved Reserved flag for internal use.
  48606. */
  48607. 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>);
  48608. /**
  48609. * Get the current class name of the texture useful for serialization or dynamic coding.
  48610. * @returns "HDRCubeTexture"
  48611. */
  48612. getClassName(): string;
  48613. /**
  48614. * Occurs when the file is raw .hdr file.
  48615. */
  48616. private loadTexture;
  48617. clone(): HDRCubeTexture;
  48618. delayLoad(): void;
  48619. /**
  48620. * Get the texture reflection matrix used to rotate/transform the reflection.
  48621. * @returns the reflection matrix
  48622. */
  48623. getReflectionTextureMatrix(): Matrix;
  48624. /**
  48625. * Set the texture reflection matrix used to rotate/transform the reflection.
  48626. * @param value Define the reflection matrix to set
  48627. */
  48628. setReflectionTextureMatrix(value: Matrix): void;
  48629. /**
  48630. * Parses a JSON representation of an HDR Texture in order to create the texture
  48631. * @param parsedTexture Define the JSON representation
  48632. * @param scene Define the scene the texture should be created in
  48633. * @param rootUrl Define the root url in case we need to load relative dependencies
  48634. * @returns the newly created texture after parsing
  48635. */
  48636. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48637. serialize(): any;
  48638. }
  48639. }
  48640. declare module "babylonjs/Physics/physicsEngine" {
  48641. import { Nullable } from "babylonjs/types";
  48642. import { Vector3 } from "babylonjs/Maths/math";
  48643. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48644. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48645. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48646. /**
  48647. * Class used to control physics engine
  48648. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48649. */
  48650. export class PhysicsEngine implements IPhysicsEngine {
  48651. private _physicsPlugin;
  48652. /**
  48653. * Global value used to control the smallest number supported by the simulation
  48654. */
  48655. static Epsilon: number;
  48656. private _impostors;
  48657. private _joints;
  48658. /**
  48659. * Gets the gravity vector used by the simulation
  48660. */
  48661. gravity: Vector3;
  48662. /**
  48663. * Factory used to create the default physics plugin.
  48664. * @returns The default physics plugin
  48665. */
  48666. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48667. /**
  48668. * Creates a new Physics Engine
  48669. * @param gravity defines the gravity vector used by the simulation
  48670. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48671. */
  48672. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48673. /**
  48674. * Sets the gravity vector used by the simulation
  48675. * @param gravity defines the gravity vector to use
  48676. */
  48677. setGravity(gravity: Vector3): void;
  48678. /**
  48679. * Set the time step of the physics engine.
  48680. * Default is 1/60.
  48681. * To slow it down, enter 1/600 for example.
  48682. * To speed it up, 1/30
  48683. * @param newTimeStep defines the new timestep to apply to this world.
  48684. */
  48685. setTimeStep(newTimeStep?: number): void;
  48686. /**
  48687. * Get the time step of the physics engine.
  48688. * @returns the current time step
  48689. */
  48690. getTimeStep(): number;
  48691. /**
  48692. * Release all resources
  48693. */
  48694. dispose(): void;
  48695. /**
  48696. * Gets the name of the current physics plugin
  48697. * @returns the name of the plugin
  48698. */
  48699. getPhysicsPluginName(): string;
  48700. /**
  48701. * Adding a new impostor for the impostor tracking.
  48702. * This will be done by the impostor itself.
  48703. * @param impostor the impostor to add
  48704. */
  48705. addImpostor(impostor: PhysicsImpostor): void;
  48706. /**
  48707. * Remove an impostor from the engine.
  48708. * This impostor and its mesh will not longer be updated by the physics engine.
  48709. * @param impostor the impostor to remove
  48710. */
  48711. removeImpostor(impostor: PhysicsImpostor): void;
  48712. /**
  48713. * Add a joint to the physics engine
  48714. * @param mainImpostor defines the main impostor to which the joint is added.
  48715. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48716. * @param joint defines the joint that will connect both impostors.
  48717. */
  48718. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48719. /**
  48720. * Removes a joint from the simulation
  48721. * @param mainImpostor defines the impostor used with the joint
  48722. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48723. * @param joint defines the joint to remove
  48724. */
  48725. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48726. /**
  48727. * Called by the scene. No need to call it.
  48728. * @param delta defines the timespam between frames
  48729. */
  48730. _step(delta: number): void;
  48731. /**
  48732. * Gets the current plugin used to run the simulation
  48733. * @returns current plugin
  48734. */
  48735. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48736. /**
  48737. * Gets the list of physic impostors
  48738. * @returns an array of PhysicsImpostor
  48739. */
  48740. getImpostors(): Array<PhysicsImpostor>;
  48741. /**
  48742. * Gets the impostor for a physics enabled object
  48743. * @param object defines the object impersonated by the impostor
  48744. * @returns the PhysicsImpostor or null if not found
  48745. */
  48746. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48747. /**
  48748. * Gets the impostor for a physics body object
  48749. * @param body defines physics body used by the impostor
  48750. * @returns the PhysicsImpostor or null if not found
  48751. */
  48752. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48753. }
  48754. }
  48755. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48756. import { Nullable } from "babylonjs/types";
  48757. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48759. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48760. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48761. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48762. /** @hidden */
  48763. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48764. private _useDeltaForWorldStep;
  48765. world: any;
  48766. name: string;
  48767. private _physicsMaterials;
  48768. private _fixedTimeStep;
  48769. BJSCANNON: any;
  48770. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48771. setGravity(gravity: Vector3): void;
  48772. setTimeStep(timeStep: number): void;
  48773. getTimeStep(): number;
  48774. executeStep(delta: number): void;
  48775. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48776. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48777. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48778. private _processChildMeshes;
  48779. removePhysicsBody(impostor: PhysicsImpostor): void;
  48780. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48781. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48782. private _addMaterial;
  48783. private _checkWithEpsilon;
  48784. private _createShape;
  48785. private _createHeightmap;
  48786. private _minus90X;
  48787. private _plus90X;
  48788. private _tmpPosition;
  48789. private _tmpDeltaPosition;
  48790. private _tmpUnityRotation;
  48791. private _updatePhysicsBodyTransformation;
  48792. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48793. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48794. isSupported(): boolean;
  48795. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48796. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48797. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48798. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48799. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48800. getBodyMass(impostor: PhysicsImpostor): number;
  48801. getBodyFriction(impostor: PhysicsImpostor): number;
  48802. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48803. getBodyRestitution(impostor: PhysicsImpostor): number;
  48804. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48805. sleepBody(impostor: PhysicsImpostor): void;
  48806. wakeUpBody(impostor: PhysicsImpostor): void;
  48807. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48808. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48809. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48810. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48811. getRadius(impostor: PhysicsImpostor): number;
  48812. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48813. dispose(): void;
  48814. private _extendNamespace;
  48815. }
  48816. }
  48817. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48818. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48819. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48820. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48822. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48823. import { Nullable } from "babylonjs/types";
  48824. /** @hidden */
  48825. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48826. world: any;
  48827. name: string;
  48828. BJSOIMO: any;
  48829. constructor(iterations?: number, oimoInjection?: any);
  48830. setGravity(gravity: Vector3): void;
  48831. setTimeStep(timeStep: number): void;
  48832. getTimeStep(): number;
  48833. private _tmpImpostorsArray;
  48834. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48835. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48836. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48837. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48838. private _tmpPositionVector;
  48839. removePhysicsBody(impostor: PhysicsImpostor): void;
  48840. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48841. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48842. isSupported(): boolean;
  48843. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48844. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48845. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48846. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48847. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48848. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48849. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48850. getBodyMass(impostor: PhysicsImpostor): number;
  48851. getBodyFriction(impostor: PhysicsImpostor): number;
  48852. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48853. getBodyRestitution(impostor: PhysicsImpostor): number;
  48854. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48855. sleepBody(impostor: PhysicsImpostor): void;
  48856. wakeUpBody(impostor: PhysicsImpostor): void;
  48857. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48858. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48859. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48860. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48861. getRadius(impostor: PhysicsImpostor): number;
  48862. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48863. dispose(): void;
  48864. }
  48865. }
  48866. declare module "babylonjs/Probes/reflectionProbe" {
  48867. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48868. import { Vector3 } from "babylonjs/Maths/math";
  48869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48870. import { Nullable } from "babylonjs/types";
  48871. import { Scene } from "babylonjs/scene";
  48872. module "babylonjs/abstractScene" {
  48873. interface AbstractScene {
  48874. /**
  48875. * The list of reflection probes added to the scene
  48876. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48877. */
  48878. reflectionProbes: Array<ReflectionProbe>;
  48879. /**
  48880. * Removes the given reflection probe from this scene.
  48881. * @param toRemove The reflection probe to remove
  48882. * @returns The index of the removed reflection probe
  48883. */
  48884. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48885. /**
  48886. * Adds the given reflection probe to this scene.
  48887. * @param newReflectionProbe The reflection probe to add
  48888. */
  48889. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48890. }
  48891. }
  48892. /**
  48893. * Class used to generate realtime reflection / refraction cube textures
  48894. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48895. */
  48896. export class ReflectionProbe {
  48897. /** defines the name of the probe */
  48898. name: string;
  48899. private _scene;
  48900. private _renderTargetTexture;
  48901. private _projectionMatrix;
  48902. private _viewMatrix;
  48903. private _target;
  48904. private _add;
  48905. private _attachedMesh;
  48906. private _invertYAxis;
  48907. /** Gets or sets probe position (center of the cube map) */
  48908. position: Vector3;
  48909. /**
  48910. * Creates a new reflection probe
  48911. * @param name defines the name of the probe
  48912. * @param size defines the texture resolution (for each face)
  48913. * @param scene defines the hosting scene
  48914. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48915. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48916. */
  48917. constructor(
  48918. /** defines the name of the probe */
  48919. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48920. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48921. samples: number;
  48922. /** Gets or sets the refresh rate to use (on every frame by default) */
  48923. refreshRate: number;
  48924. /**
  48925. * Gets the hosting scene
  48926. * @returns a Scene
  48927. */
  48928. getScene(): Scene;
  48929. /** Gets the internal CubeTexture used to render to */
  48930. readonly cubeTexture: RenderTargetTexture;
  48931. /** Gets the list of meshes to render */
  48932. readonly renderList: Nullable<AbstractMesh[]>;
  48933. /**
  48934. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48935. * @param mesh defines the mesh to attach to
  48936. */
  48937. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48938. /**
  48939. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48940. * @param renderingGroupId The rendering group id corresponding to its index
  48941. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48942. */
  48943. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48944. /**
  48945. * Clean all associated resources
  48946. */
  48947. dispose(): void;
  48948. /**
  48949. * Converts the reflection probe information to a readable string for debug purpose.
  48950. * @param fullDetails Supports for multiple levels of logging within scene loading
  48951. * @returns the human readable reflection probe info
  48952. */
  48953. toString(fullDetails?: boolean): string;
  48954. /**
  48955. * Get the class name of the relfection probe.
  48956. * @returns "ReflectionProbe"
  48957. */
  48958. getClassName(): string;
  48959. /**
  48960. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48961. * @returns The JSON representation of the texture
  48962. */
  48963. serialize(): any;
  48964. /**
  48965. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48966. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48967. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48968. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48969. * @returns The parsed reflection probe if successful
  48970. */
  48971. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48972. }
  48973. }
  48974. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48975. /** @hidden */
  48976. export var _BabylonLoaderRegistered: boolean;
  48977. }
  48978. declare module "babylonjs/Loading/Plugins/index" {
  48979. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48980. }
  48981. declare module "babylonjs/Loading/index" {
  48982. export * from "babylonjs/Loading/loadingScreen";
  48983. export * from "babylonjs/Loading/Plugins/index";
  48984. export * from "babylonjs/Loading/sceneLoader";
  48985. export * from "babylonjs/Loading/sceneLoaderFlags";
  48986. }
  48987. declare module "babylonjs/Materials/Background/index" {
  48988. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48989. }
  48990. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48991. import { Scene } from "babylonjs/scene";
  48992. import { Color3 } from "babylonjs/Maths/math";
  48993. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48995. /**
  48996. * The Physically based simple base material of BJS.
  48997. *
  48998. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48999. * It is used as the base class for both the specGloss and metalRough conventions.
  49000. */
  49001. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49002. /**
  49003. * Number of Simultaneous lights allowed on the material.
  49004. */
  49005. maxSimultaneousLights: number;
  49006. /**
  49007. * If sets to true, disables all the lights affecting the material.
  49008. */
  49009. disableLighting: boolean;
  49010. /**
  49011. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49012. */
  49013. environmentTexture: BaseTexture;
  49014. /**
  49015. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49016. */
  49017. invertNormalMapX: boolean;
  49018. /**
  49019. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49020. */
  49021. invertNormalMapY: boolean;
  49022. /**
  49023. * Normal map used in the model.
  49024. */
  49025. normalTexture: BaseTexture;
  49026. /**
  49027. * Emissivie color used to self-illuminate the model.
  49028. */
  49029. emissiveColor: Color3;
  49030. /**
  49031. * Emissivie texture used to self-illuminate the model.
  49032. */
  49033. emissiveTexture: BaseTexture;
  49034. /**
  49035. * Occlusion Channel Strenght.
  49036. */
  49037. occlusionStrength: number;
  49038. /**
  49039. * Occlusion Texture of the material (adding extra occlusion effects).
  49040. */
  49041. occlusionTexture: BaseTexture;
  49042. /**
  49043. * Defines the alpha limits in alpha test mode.
  49044. */
  49045. alphaCutOff: number;
  49046. /**
  49047. * Gets the current double sided mode.
  49048. */
  49049. /**
  49050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49051. */
  49052. doubleSided: boolean;
  49053. /**
  49054. * Stores the pre-calculated light information of a mesh in a texture.
  49055. */
  49056. lightmapTexture: BaseTexture;
  49057. /**
  49058. * If true, the light map contains occlusion information instead of lighting info.
  49059. */
  49060. useLightmapAsShadowmap: boolean;
  49061. /**
  49062. * Instantiates a new PBRMaterial instance.
  49063. *
  49064. * @param name The material name
  49065. * @param scene The scene the material will be use in.
  49066. */
  49067. constructor(name: string, scene: Scene);
  49068. getClassName(): string;
  49069. }
  49070. }
  49071. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49072. import { Scene } from "babylonjs/scene";
  49073. import { Color3 } from "babylonjs/Maths/math";
  49074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49075. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49076. /**
  49077. * The PBR material of BJS following the metal roughness convention.
  49078. *
  49079. * This fits to the PBR convention in the GLTF definition:
  49080. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49081. */
  49082. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49083. /**
  49084. * The base color has two different interpretations depending on the value of metalness.
  49085. * When the material is a metal, the base color is the specific measured reflectance value
  49086. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49087. * of the material.
  49088. */
  49089. baseColor: Color3;
  49090. /**
  49091. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49092. * well as opacity information in the alpha channel.
  49093. */
  49094. baseTexture: BaseTexture;
  49095. /**
  49096. * Specifies the metallic scalar value of the material.
  49097. * Can also be used to scale the metalness values of the metallic texture.
  49098. */
  49099. metallic: number;
  49100. /**
  49101. * Specifies the roughness scalar value of the material.
  49102. * Can also be used to scale the roughness values of the metallic texture.
  49103. */
  49104. roughness: number;
  49105. /**
  49106. * Texture containing both the metallic value in the B channel and the
  49107. * roughness value in the G channel to keep better precision.
  49108. */
  49109. metallicRoughnessTexture: BaseTexture;
  49110. /**
  49111. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49112. *
  49113. * @param name The material name
  49114. * @param scene The scene the material will be use in.
  49115. */
  49116. constructor(name: string, scene: Scene);
  49117. /**
  49118. * Return the currrent class name of the material.
  49119. */
  49120. getClassName(): string;
  49121. /**
  49122. * Makes a duplicate of the current material.
  49123. * @param name - name to use for the new material.
  49124. */
  49125. clone(name: string): PBRMetallicRoughnessMaterial;
  49126. /**
  49127. * Serialize the material to a parsable JSON object.
  49128. */
  49129. serialize(): any;
  49130. /**
  49131. * Parses a JSON object correponding to the serialize function.
  49132. */
  49133. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49134. }
  49135. }
  49136. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49137. import { Scene } from "babylonjs/scene";
  49138. import { Color3 } from "babylonjs/Maths/math";
  49139. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49140. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49141. /**
  49142. * The PBR material of BJS following the specular glossiness convention.
  49143. *
  49144. * This fits to the PBR convention in the GLTF definition:
  49145. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49146. */
  49147. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49148. /**
  49149. * Specifies the diffuse color of the material.
  49150. */
  49151. diffuseColor: Color3;
  49152. /**
  49153. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49154. * channel.
  49155. */
  49156. diffuseTexture: BaseTexture;
  49157. /**
  49158. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49159. */
  49160. specularColor: Color3;
  49161. /**
  49162. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49163. */
  49164. glossiness: number;
  49165. /**
  49166. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49167. */
  49168. specularGlossinessTexture: BaseTexture;
  49169. /**
  49170. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49171. *
  49172. * @param name The material name
  49173. * @param scene The scene the material will be use in.
  49174. */
  49175. constructor(name: string, scene: Scene);
  49176. /**
  49177. * Return the currrent class name of the material.
  49178. */
  49179. getClassName(): string;
  49180. /**
  49181. * Makes a duplicate of the current material.
  49182. * @param name - name to use for the new material.
  49183. */
  49184. clone(name: string): PBRSpecularGlossinessMaterial;
  49185. /**
  49186. * Serialize the material to a parsable JSON object.
  49187. */
  49188. serialize(): any;
  49189. /**
  49190. * Parses a JSON object correponding to the serialize function.
  49191. */
  49192. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49193. }
  49194. }
  49195. declare module "babylonjs/Materials/PBR/index" {
  49196. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49197. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49198. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49199. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49200. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49201. }
  49202. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49203. import { Nullable } from "babylonjs/types";
  49204. import { Scene } from "babylonjs/scene";
  49205. import { Matrix } from "babylonjs/Maths/math";
  49206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49207. /**
  49208. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49209. * It can help converting any input color in a desired output one. This can then be used to create effects
  49210. * from sepia, black and white to sixties or futuristic rendering...
  49211. *
  49212. * The only supported format is currently 3dl.
  49213. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49214. */
  49215. export class ColorGradingTexture extends BaseTexture {
  49216. /**
  49217. * The current texture matrix. (will always be identity in color grading texture)
  49218. */
  49219. private _textureMatrix;
  49220. /**
  49221. * The texture URL.
  49222. */
  49223. url: string;
  49224. /**
  49225. * Empty line regex stored for GC.
  49226. */
  49227. private static _noneEmptyLineRegex;
  49228. private _engine;
  49229. /**
  49230. * Instantiates a ColorGradingTexture from the following parameters.
  49231. *
  49232. * @param url The location of the color gradind data (currently only supporting 3dl)
  49233. * @param scene The scene the texture will be used in
  49234. */
  49235. constructor(url: string, scene: Scene);
  49236. /**
  49237. * Returns the texture matrix used in most of the material.
  49238. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49239. */
  49240. getTextureMatrix(): Matrix;
  49241. /**
  49242. * Occurs when the file being loaded is a .3dl LUT file.
  49243. */
  49244. private load3dlTexture;
  49245. /**
  49246. * Starts the loading process of the texture.
  49247. */
  49248. private loadTexture;
  49249. /**
  49250. * Clones the color gradind texture.
  49251. */
  49252. clone(): ColorGradingTexture;
  49253. /**
  49254. * Called during delayed load for textures.
  49255. */
  49256. delayLoad(): void;
  49257. /**
  49258. * Parses a color grading texture serialized by Babylon.
  49259. * @param parsedTexture The texture information being parsedTexture
  49260. * @param scene The scene to load the texture in
  49261. * @param rootUrl The root url of the data assets to load
  49262. * @return A color gradind texture
  49263. */
  49264. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49265. /**
  49266. * Serializes the LUT texture to json format.
  49267. */
  49268. serialize(): any;
  49269. }
  49270. }
  49271. declare module "babylonjs/Misc/tga" {
  49272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49273. /**
  49274. * Based on jsTGALoader - Javascript loader for TGA file
  49275. * By Vincent Thibault
  49276. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49277. */
  49278. export class TGATools {
  49279. private static _TYPE_INDEXED;
  49280. private static _TYPE_RGB;
  49281. private static _TYPE_GREY;
  49282. private static _TYPE_RLE_INDEXED;
  49283. private static _TYPE_RLE_RGB;
  49284. private static _TYPE_RLE_GREY;
  49285. private static _ORIGIN_MASK;
  49286. private static _ORIGIN_SHIFT;
  49287. private static _ORIGIN_BL;
  49288. private static _ORIGIN_BR;
  49289. private static _ORIGIN_UL;
  49290. private static _ORIGIN_UR;
  49291. /**
  49292. * Gets the header of a TGA file
  49293. * @param data defines the TGA data
  49294. * @returns the header
  49295. */
  49296. static GetTGAHeader(data: Uint8Array): any;
  49297. /**
  49298. * Uploads TGA content to a Babylon Texture
  49299. * @hidden
  49300. */
  49301. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49302. /** @hidden */
  49303. 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;
  49304. /** @hidden */
  49305. 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;
  49306. /** @hidden */
  49307. 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;
  49308. /** @hidden */
  49309. 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;
  49310. /** @hidden */
  49311. 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;
  49312. /** @hidden */
  49313. 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;
  49314. }
  49315. }
  49316. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49317. import { Nullable } from "babylonjs/types";
  49318. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49319. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49320. /**
  49321. * Implementation of the TGA Texture Loader.
  49322. * @hidden
  49323. */
  49324. export class _TGATextureLoader implements IInternalTextureLoader {
  49325. /**
  49326. * Defines wether the loader supports cascade loading the different faces.
  49327. */
  49328. readonly supportCascades: boolean;
  49329. /**
  49330. * This returns if the loader support the current file information.
  49331. * @param extension defines the file extension of the file being loaded
  49332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49333. * @param fallback defines the fallback internal texture if any
  49334. * @param isBase64 defines whether the texture is encoded as a base64
  49335. * @param isBuffer defines whether the texture data are stored as a buffer
  49336. * @returns true if the loader can load the specified file
  49337. */
  49338. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49339. /**
  49340. * Transform the url before loading if required.
  49341. * @param rootUrl the url of the texture
  49342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49343. * @returns the transformed texture
  49344. */
  49345. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49346. /**
  49347. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49348. * @param rootUrl the url of the texture
  49349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49350. * @returns the fallback texture
  49351. */
  49352. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49353. /**
  49354. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49355. * @param data contains the texture data
  49356. * @param texture defines the BabylonJS internal texture
  49357. * @param createPolynomials will be true if polynomials have been requested
  49358. * @param onLoad defines the callback to trigger once the texture is ready
  49359. * @param onError defines the callback to trigger in case of error
  49360. */
  49361. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49362. /**
  49363. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49364. * @param data contains the texture data
  49365. * @param texture defines the BabylonJS internal texture
  49366. * @param callback defines the method to call once ready to upload
  49367. */
  49368. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49369. }
  49370. }
  49371. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49372. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49373. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49374. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49375. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49376. }
  49377. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49378. import { Scene } from "babylonjs/scene";
  49379. import { Texture } from "babylonjs/Materials/Textures/texture";
  49380. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49381. /**
  49382. * 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.
  49383. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49384. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49385. */
  49386. export class CustomProceduralTexture extends ProceduralTexture {
  49387. private _animate;
  49388. private _time;
  49389. private _config;
  49390. private _texturePath;
  49391. /**
  49392. * Instantiates a new Custom Procedural Texture.
  49393. * 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.
  49394. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49395. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49396. * @param name Define the name of the texture
  49397. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49398. * @param size Define the size of the texture to create
  49399. * @param scene Define the scene the texture belongs to
  49400. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49401. * @param generateMipMaps Define if the texture should creates mip maps or not
  49402. */
  49403. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49404. private _loadJson;
  49405. /**
  49406. * Is the texture ready to be used ? (rendered at least once)
  49407. * @returns true if ready, otherwise, false.
  49408. */
  49409. isReady(): boolean;
  49410. /**
  49411. * Render the texture to its associated render target.
  49412. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49413. */
  49414. render(useCameraPostProcess?: boolean): void;
  49415. /**
  49416. * Update the list of dependant textures samplers in the shader.
  49417. */
  49418. updateTextures(): void;
  49419. /**
  49420. * Update the uniform values of the procedural texture in the shader.
  49421. */
  49422. updateShaderUniforms(): void;
  49423. /**
  49424. * Define if the texture animates or not.
  49425. */
  49426. animate: boolean;
  49427. }
  49428. }
  49429. declare module "babylonjs/Shaders/noise.fragment" {
  49430. /** @hidden */
  49431. export var noisePixelShader: {
  49432. name: string;
  49433. shader: string;
  49434. };
  49435. }
  49436. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49437. import { Nullable } from "babylonjs/types";
  49438. import { Scene } from "babylonjs/scene";
  49439. import { Texture } from "babylonjs/Materials/Textures/texture";
  49440. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49441. import "babylonjs/Shaders/noise.fragment";
  49442. /**
  49443. * Class used to generate noise procedural textures
  49444. */
  49445. export class NoiseProceduralTexture extends ProceduralTexture {
  49446. private _time;
  49447. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49448. brightness: number;
  49449. /** Defines the number of octaves to process */
  49450. octaves: number;
  49451. /** Defines the level of persistence (0.8 by default) */
  49452. persistence: number;
  49453. /** Gets or sets animation speed factor (default is 1) */
  49454. animationSpeedFactor: number;
  49455. /**
  49456. * Creates a new NoiseProceduralTexture
  49457. * @param name defines the name fo the texture
  49458. * @param size defines the size of the texture (default is 256)
  49459. * @param scene defines the hosting scene
  49460. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49461. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49462. */
  49463. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49464. private _updateShaderUniforms;
  49465. protected _getDefines(): string;
  49466. /** Generate the current state of the procedural texture */
  49467. render(useCameraPostProcess?: boolean): void;
  49468. /**
  49469. * Serializes this noise procedural texture
  49470. * @returns a serialized noise procedural texture object
  49471. */
  49472. serialize(): any;
  49473. /**
  49474. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49475. * @param parsedTexture defines parsed texture data
  49476. * @param scene defines the current scene
  49477. * @param rootUrl defines the root URL containing noise procedural texture information
  49478. * @returns a parsed NoiseProceduralTexture
  49479. */
  49480. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49481. }
  49482. }
  49483. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49484. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49485. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49486. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49487. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49488. }
  49489. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49490. import { Nullable } from "babylonjs/types";
  49491. import { Scene } from "babylonjs/scene";
  49492. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49493. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49494. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49495. /**
  49496. * Raw cube texture where the raw buffers are passed in
  49497. */
  49498. export class RawCubeTexture extends CubeTexture {
  49499. /**
  49500. * Creates a cube texture where the raw buffers are passed in.
  49501. * @param scene defines the scene the texture is attached to
  49502. * @param data defines the array of data to use to create each face
  49503. * @param size defines the size of the textures
  49504. * @param format defines the format of the data
  49505. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49506. * @param generateMipMaps defines if the engine should generate the mip levels
  49507. * @param invertY defines if data must be stored with Y axis inverted
  49508. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49509. * @param compression defines the compression used (null by default)
  49510. */
  49511. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49512. /**
  49513. * Updates the raw cube texture.
  49514. * @param data defines the data to store
  49515. * @param format defines the data format
  49516. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49517. * @param invertY defines if data must be stored with Y axis inverted
  49518. * @param compression defines the compression used (null by default)
  49519. * @param level defines which level of the texture to update
  49520. */
  49521. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49522. /**
  49523. * Updates a raw cube texture with RGBD encoded data.
  49524. * @param data defines the array of data [mipmap][face] to use to create each face
  49525. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49526. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49527. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49528. * @returns a promsie that resolves when the operation is complete
  49529. */
  49530. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49531. /**
  49532. * Clones the raw cube texture.
  49533. * @return a new cube texture
  49534. */
  49535. clone(): CubeTexture;
  49536. /** @hidden */
  49537. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49538. }
  49539. }
  49540. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49541. import { Scene } from "babylonjs/scene";
  49542. import { Texture } from "babylonjs/Materials/Textures/texture";
  49543. /**
  49544. * Class used to store 3D textures containing user data
  49545. */
  49546. export class RawTexture3D extends Texture {
  49547. /** Gets or sets the texture format to use */
  49548. format: number;
  49549. private _engine;
  49550. /**
  49551. * Create a new RawTexture3D
  49552. * @param data defines the data of the texture
  49553. * @param width defines the width of the texture
  49554. * @param height defines the height of the texture
  49555. * @param depth defines the depth of the texture
  49556. * @param format defines the texture format to use
  49557. * @param scene defines the hosting scene
  49558. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49559. * @param invertY defines if texture must be stored with Y axis inverted
  49560. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49562. */
  49563. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49564. /** Gets or sets the texture format to use */
  49565. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49566. /**
  49567. * Update the texture with new data
  49568. * @param data defines the data to store in the texture
  49569. */
  49570. update(data: ArrayBufferView): void;
  49571. }
  49572. }
  49573. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49574. import { Scene } from "babylonjs/scene";
  49575. import { Plane } from "babylonjs/Maths/math";
  49576. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49577. /**
  49578. * Creates a refraction texture used by refraction channel of the standard material.
  49579. * It is like a mirror but to see through a material.
  49580. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49581. */
  49582. export class RefractionTexture extends RenderTargetTexture {
  49583. /**
  49584. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49585. * 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.
  49586. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49587. */
  49588. refractionPlane: Plane;
  49589. /**
  49590. * Define how deep under the surface we should see.
  49591. */
  49592. depth: number;
  49593. /**
  49594. * Creates a refraction texture used by refraction channel of the standard material.
  49595. * It is like a mirror but to see through a material.
  49596. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49597. * @param name Define the texture name
  49598. * @param size Define the size of the underlying texture
  49599. * @param scene Define the scene the refraction belongs to
  49600. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49601. */
  49602. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49603. /**
  49604. * Clone the refraction texture.
  49605. * @returns the cloned texture
  49606. */
  49607. clone(): RefractionTexture;
  49608. /**
  49609. * Serialize the texture to a JSON representation you could use in Parse later on
  49610. * @returns the serialized JSON representation
  49611. */
  49612. serialize(): any;
  49613. }
  49614. }
  49615. declare module "babylonjs/Materials/Textures/index" {
  49616. export * from "babylonjs/Materials/Textures/baseTexture";
  49617. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49618. export * from "babylonjs/Materials/Textures/cubeTexture";
  49619. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49620. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49621. export * from "babylonjs/Materials/Textures/internalTexture";
  49622. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49623. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49624. export * from "babylonjs/Materials/Textures/Loaders/index";
  49625. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49626. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49627. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49628. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49629. export * from "babylonjs/Materials/Textures/rawTexture";
  49630. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49631. export * from "babylonjs/Materials/Textures/refractionTexture";
  49632. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49633. export * from "babylonjs/Materials/Textures/texture";
  49634. export * from "babylonjs/Materials/Textures/videoTexture";
  49635. }
  49636. declare module "babylonjs/Materials/index" {
  49637. export * from "babylonjs/Materials/Background/index";
  49638. export * from "babylonjs/Materials/colorCurves";
  49639. export * from "babylonjs/Materials/effect";
  49640. export * from "babylonjs/Materials/fresnelParameters";
  49641. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49642. export * from "babylonjs/Materials/material";
  49643. export * from "babylonjs/Materials/materialDefines";
  49644. export * from "babylonjs/Materials/materialHelper";
  49645. export * from "babylonjs/Materials/multiMaterial";
  49646. export * from "babylonjs/Materials/PBR/index";
  49647. export * from "babylonjs/Materials/pushMaterial";
  49648. export * from "babylonjs/Materials/shaderMaterial";
  49649. export * from "babylonjs/Materials/standardMaterial";
  49650. export * from "babylonjs/Materials/Textures/index";
  49651. export * from "babylonjs/Materials/uniformBuffer";
  49652. export * from "babylonjs/Materials/materialFlags";
  49653. }
  49654. declare module "babylonjs/Maths/index" {
  49655. export * from "babylonjs/Maths/math.scalar";
  49656. export * from "babylonjs/Maths/math";
  49657. export * from "babylonjs/Maths/sphericalPolynomial";
  49658. }
  49659. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49660. import { IDisposable } from "babylonjs/scene";
  49661. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49662. /**
  49663. * Configuration for Draco compression
  49664. */
  49665. export interface IDracoCompressionConfiguration {
  49666. /**
  49667. * Configuration for the decoder.
  49668. */
  49669. decoder?: {
  49670. /**
  49671. * The url to the WebAssembly module.
  49672. */
  49673. wasmUrl?: string;
  49674. /**
  49675. * The url to the WebAssembly binary.
  49676. */
  49677. wasmBinaryUrl?: string;
  49678. /**
  49679. * The url to the fallback JavaScript module.
  49680. */
  49681. fallbackUrl?: string;
  49682. };
  49683. }
  49684. /**
  49685. * Draco compression (https://google.github.io/draco/)
  49686. *
  49687. * This class wraps the Draco module.
  49688. *
  49689. * **Encoder**
  49690. *
  49691. * The encoder is not currently implemented.
  49692. *
  49693. * **Decoder**
  49694. *
  49695. * 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.
  49696. *
  49697. * To update the configuration, use the following code:
  49698. * ```javascript
  49699. * DracoCompression.Configuration = {
  49700. * decoder: {
  49701. * wasmUrl: "<url to the WebAssembly library>",
  49702. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49703. * fallbackUrl: "<url to the fallback JavaScript library>",
  49704. * }
  49705. * };
  49706. * ```
  49707. *
  49708. * 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.
  49709. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49710. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49711. *
  49712. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49713. * ```javascript
  49714. * var dracoCompression = new DracoCompression();
  49715. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49716. * [VertexBuffer.PositionKind]: 0
  49717. * });
  49718. * ```
  49719. *
  49720. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49721. */
  49722. export class DracoCompression implements IDisposable {
  49723. private static _DecoderModulePromise;
  49724. /**
  49725. * The configuration. Defaults to the following urls:
  49726. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49727. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49728. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49729. */
  49730. static Configuration: IDracoCompressionConfiguration;
  49731. /**
  49732. * Returns true if the decoder is available.
  49733. */
  49734. static readonly DecoderAvailable: boolean;
  49735. /**
  49736. * Constructor
  49737. */
  49738. constructor();
  49739. /**
  49740. * Stop all async operations and release resources.
  49741. */
  49742. dispose(): void;
  49743. /**
  49744. * Decode Draco compressed mesh data to vertex data.
  49745. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49746. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49747. * @returns A promise that resolves with the decoded vertex data
  49748. */
  49749. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49750. [kind: string]: number;
  49751. }): Promise<VertexData>;
  49752. private static _GetDecoderModule;
  49753. private static _LoadScriptAsync;
  49754. private static _LoadFileAsync;
  49755. }
  49756. }
  49757. declare module "babylonjs/Meshes/Compression/index" {
  49758. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49759. }
  49760. declare module "babylonjs/Meshes/csg" {
  49761. import { Nullable } from "babylonjs/types";
  49762. import { Scene } from "babylonjs/scene";
  49763. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49764. import { Mesh } from "babylonjs/Meshes/mesh";
  49765. import { Material } from "babylonjs/Materials/material";
  49766. /**
  49767. * Class for building Constructive Solid Geometry
  49768. */
  49769. export class CSG {
  49770. private polygons;
  49771. /**
  49772. * The world matrix
  49773. */
  49774. matrix: Matrix;
  49775. /**
  49776. * Stores the position
  49777. */
  49778. position: Vector3;
  49779. /**
  49780. * Stores the rotation
  49781. */
  49782. rotation: Vector3;
  49783. /**
  49784. * Stores the rotation quaternion
  49785. */
  49786. rotationQuaternion: Nullable<Quaternion>;
  49787. /**
  49788. * Stores the scaling vector
  49789. */
  49790. scaling: Vector3;
  49791. /**
  49792. * Convert the Mesh to CSG
  49793. * @param mesh The Mesh to convert to CSG
  49794. * @returns A new CSG from the Mesh
  49795. */
  49796. static FromMesh(mesh: Mesh): CSG;
  49797. /**
  49798. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49799. * @param polygons Polygons used to construct a CSG solid
  49800. */
  49801. private static FromPolygons;
  49802. /**
  49803. * Clones, or makes a deep copy, of the CSG
  49804. * @returns A new CSG
  49805. */
  49806. clone(): CSG;
  49807. /**
  49808. * Unions this CSG with another CSG
  49809. * @param csg The CSG to union against this CSG
  49810. * @returns The unioned CSG
  49811. */
  49812. union(csg: CSG): CSG;
  49813. /**
  49814. * Unions this CSG with another CSG in place
  49815. * @param csg The CSG to union against this CSG
  49816. */
  49817. unionInPlace(csg: CSG): void;
  49818. /**
  49819. * Subtracts this CSG with another CSG
  49820. * @param csg The CSG to subtract against this CSG
  49821. * @returns A new CSG
  49822. */
  49823. subtract(csg: CSG): CSG;
  49824. /**
  49825. * Subtracts this CSG with another CSG in place
  49826. * @param csg The CSG to subtact against this CSG
  49827. */
  49828. subtractInPlace(csg: CSG): void;
  49829. /**
  49830. * Intersect this CSG with another CSG
  49831. * @param csg The CSG to intersect against this CSG
  49832. * @returns A new CSG
  49833. */
  49834. intersect(csg: CSG): CSG;
  49835. /**
  49836. * Intersects this CSG with another CSG in place
  49837. * @param csg The CSG to intersect against this CSG
  49838. */
  49839. intersectInPlace(csg: CSG): void;
  49840. /**
  49841. * Return a new CSG solid with solid and empty space switched. This solid is
  49842. * not modified.
  49843. * @returns A new CSG solid with solid and empty space switched
  49844. */
  49845. inverse(): CSG;
  49846. /**
  49847. * Inverses the CSG in place
  49848. */
  49849. inverseInPlace(): void;
  49850. /**
  49851. * This is used to keep meshes transformations so they can be restored
  49852. * when we build back a Babylon Mesh
  49853. * NB : All CSG operations are performed in world coordinates
  49854. * @param csg The CSG to copy the transform attributes from
  49855. * @returns This CSG
  49856. */
  49857. copyTransformAttributes(csg: CSG): CSG;
  49858. /**
  49859. * Build Raw mesh from CSG
  49860. * Coordinates here are in world space
  49861. * @param name The name of the mesh geometry
  49862. * @param scene The Scene
  49863. * @param keepSubMeshes Specifies if the submeshes should be kept
  49864. * @returns A new Mesh
  49865. */
  49866. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49867. /**
  49868. * Build Mesh from CSG taking material and transforms into account
  49869. * @param name The name of the Mesh
  49870. * @param material The material of the Mesh
  49871. * @param scene The Scene
  49872. * @param keepSubMeshes Specifies if submeshes should be kept
  49873. * @returns The new Mesh
  49874. */
  49875. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49876. }
  49877. }
  49878. declare module "babylonjs/Meshes/trailMesh" {
  49879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49880. import { Mesh } from "babylonjs/Meshes/mesh";
  49881. import { Scene } from "babylonjs/scene";
  49882. /**
  49883. * Class used to create a trail following a mesh
  49884. */
  49885. export class TrailMesh extends Mesh {
  49886. private _generator;
  49887. private _autoStart;
  49888. private _running;
  49889. private _diameter;
  49890. private _length;
  49891. private _sectionPolygonPointsCount;
  49892. private _sectionVectors;
  49893. private _sectionNormalVectors;
  49894. private _beforeRenderObserver;
  49895. /**
  49896. * @constructor
  49897. * @param name The value used by scene.getMeshByName() to do a lookup.
  49898. * @param generator The mesh to generate a trail.
  49899. * @param scene The scene to add this mesh to.
  49900. * @param diameter Diameter of trailing mesh. Default is 1.
  49901. * @param length Length of trailing mesh. Default is 60.
  49902. * @param autoStart Automatically start trailing mesh. Default true.
  49903. */
  49904. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49905. /**
  49906. * "TrailMesh"
  49907. * @returns "TrailMesh"
  49908. */
  49909. getClassName(): string;
  49910. private _createMesh;
  49911. /**
  49912. * Start trailing mesh.
  49913. */
  49914. start(): void;
  49915. /**
  49916. * Stop trailing mesh.
  49917. */
  49918. stop(): void;
  49919. /**
  49920. * Update trailing mesh geometry.
  49921. */
  49922. update(): void;
  49923. /**
  49924. * Returns a new TrailMesh object.
  49925. * @param name is a string, the name given to the new mesh
  49926. * @param newGenerator use new generator object for cloned trail mesh
  49927. * @returns a new mesh
  49928. */
  49929. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49930. /**
  49931. * Serializes this trail mesh
  49932. * @param serializationObject object to write serialization to
  49933. */
  49934. serialize(serializationObject: any): void;
  49935. /**
  49936. * Parses a serialized trail mesh
  49937. * @param parsedMesh the serialized mesh
  49938. * @param scene the scene to create the trail mesh in
  49939. * @returns the created trail mesh
  49940. */
  49941. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49942. }
  49943. }
  49944. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49945. import { Nullable } from "babylonjs/types";
  49946. import { Scene } from "babylonjs/scene";
  49947. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49948. import { Mesh } from "babylonjs/Meshes/mesh";
  49949. /**
  49950. * Class containing static functions to help procedurally build meshes
  49951. */
  49952. export class RibbonBuilder {
  49953. /**
  49954. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49955. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49956. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49957. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49958. * * 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
  49959. * * 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
  49960. * * 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
  49961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49963. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49964. * * 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
  49965. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49966. * * 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
  49967. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49969. * @param name defines the name of the mesh
  49970. * @param options defines the options used to create the mesh
  49971. * @param scene defines the hosting scene
  49972. * @returns the ribbon mesh
  49973. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49975. */
  49976. static CreateRibbon(name: string, options: {
  49977. pathArray: Vector3[][];
  49978. closeArray?: boolean;
  49979. closePath?: boolean;
  49980. offset?: number;
  49981. updatable?: boolean;
  49982. sideOrientation?: number;
  49983. frontUVs?: Vector4;
  49984. backUVs?: Vector4;
  49985. instance?: Mesh;
  49986. invertUV?: boolean;
  49987. uvs?: Vector2[];
  49988. colors?: Color4[];
  49989. }, scene?: Nullable<Scene>): Mesh;
  49990. }
  49991. }
  49992. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49993. import { Vector4 } from "babylonjs/Maths/math";
  49994. import { Mesh } from "babylonjs/Meshes/mesh";
  49995. /**
  49996. * Class containing static functions to help procedurally build meshes
  49997. */
  49998. export class TorusKnotBuilder {
  49999. /**
  50000. * Creates a torus knot mesh
  50001. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50002. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50003. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50004. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50008. * @param name defines the name of the mesh
  50009. * @param options defines the options used to create the mesh
  50010. * @param scene defines the hosting scene
  50011. * @returns the torus knot mesh
  50012. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50013. */
  50014. static CreateTorusKnot(name: string, options: {
  50015. radius?: number;
  50016. tube?: number;
  50017. radialSegments?: number;
  50018. tubularSegments?: number;
  50019. p?: number;
  50020. q?: number;
  50021. updatable?: boolean;
  50022. sideOrientation?: number;
  50023. frontUVs?: Vector4;
  50024. backUVs?: Vector4;
  50025. }, scene: any): Mesh;
  50026. }
  50027. }
  50028. declare module "babylonjs/Meshes/polygonMesh" {
  50029. import { Scene } from "babylonjs/scene";
  50030. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50031. import { Mesh } from "babylonjs/Meshes/mesh";
  50032. /**
  50033. * Polygon
  50034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50035. */
  50036. export class Polygon {
  50037. /**
  50038. * Creates a rectangle
  50039. * @param xmin bottom X coord
  50040. * @param ymin bottom Y coord
  50041. * @param xmax top X coord
  50042. * @param ymax top Y coord
  50043. * @returns points that make the resulting rectation
  50044. */
  50045. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50046. /**
  50047. * Creates a circle
  50048. * @param radius radius of circle
  50049. * @param cx scale in x
  50050. * @param cy scale in y
  50051. * @param numberOfSides number of sides that make up the circle
  50052. * @returns points that make the resulting circle
  50053. */
  50054. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50055. /**
  50056. * Creates a polygon from input string
  50057. * @param input Input polygon data
  50058. * @returns the parsed points
  50059. */
  50060. static Parse(input: string): Vector2[];
  50061. /**
  50062. * Starts building a polygon from x and y coordinates
  50063. * @param x x coordinate
  50064. * @param y y coordinate
  50065. * @returns the started path2
  50066. */
  50067. static StartingAt(x: number, y: number): Path2;
  50068. }
  50069. /**
  50070. * Builds a polygon
  50071. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50072. */
  50073. export class PolygonMeshBuilder {
  50074. private _points;
  50075. private _outlinepoints;
  50076. private _holes;
  50077. private _name;
  50078. private _scene;
  50079. private _epoints;
  50080. private _eholes;
  50081. private _addToepoint;
  50082. /**
  50083. * Babylon reference to the earcut plugin.
  50084. */
  50085. bjsEarcut: any;
  50086. /**
  50087. * Creates a PolygonMeshBuilder
  50088. * @param name name of the builder
  50089. * @param contours Path of the polygon
  50090. * @param scene scene to add to
  50091. * @param earcutInjection can be used to inject your own earcut reference
  50092. */
  50093. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  50094. /**
  50095. * Adds a whole within the polygon
  50096. * @param hole Array of points defining the hole
  50097. * @returns this
  50098. */
  50099. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50100. /**
  50101. * Creates the polygon
  50102. * @param updatable If the mesh should be updatable
  50103. * @param depth The depth of the mesh created
  50104. * @returns the created mesh
  50105. */
  50106. build(updatable?: boolean, depth?: number): Mesh;
  50107. /**
  50108. * Adds a side to the polygon
  50109. * @param positions points that make the polygon
  50110. * @param normals normals of the polygon
  50111. * @param uvs uvs of the polygon
  50112. * @param indices indices of the polygon
  50113. * @param bounds bounds of the polygon
  50114. * @param points points of the polygon
  50115. * @param depth depth of the polygon
  50116. * @param flip flip of the polygon
  50117. */
  50118. private addSide;
  50119. }
  50120. }
  50121. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50122. import { Scene } from "babylonjs/scene";
  50123. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50124. import { Mesh } from "babylonjs/Meshes/mesh";
  50125. /**
  50126. * Class containing static functions to help procedurally build meshes
  50127. */
  50128. export class PolygonBuilder {
  50129. /**
  50130. * Creates a polygon mesh
  50131. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50132. * * 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
  50133. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50136. * * Remember you can only change the shape positions, not their number when updating a polygon
  50137. * @param name defines the name of the mesh
  50138. * @param options defines the options used to create the mesh
  50139. * @param scene defines the hosting scene
  50140. * @param earcutInjection can be used to inject your own earcut reference
  50141. * @returns the polygon mesh
  50142. */
  50143. static CreatePolygon(name: string, options: {
  50144. shape: Vector3[];
  50145. holes?: Vector3[][];
  50146. depth?: number;
  50147. faceUV?: Vector4[];
  50148. faceColors?: Color4[];
  50149. updatable?: boolean;
  50150. sideOrientation?: number;
  50151. frontUVs?: Vector4;
  50152. backUVs?: Vector4;
  50153. }, scene: Scene, earcutInjection?: any): Mesh;
  50154. /**
  50155. * Creates an extruded polygon mesh, with depth in the Y direction.
  50156. * * 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)
  50157. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50158. * @param name defines the name of the mesh
  50159. * @param options defines the options used to create the mesh
  50160. * @param scene defines the hosting scene
  50161. * @param earcutInjection can be used to inject your own earcut reference
  50162. * @returns the polygon mesh
  50163. */
  50164. static ExtrudePolygon(name: string, options: {
  50165. shape: Vector3[];
  50166. holes?: Vector3[][];
  50167. depth?: number;
  50168. faceUV?: Vector4[];
  50169. faceColors?: Color4[];
  50170. updatable?: boolean;
  50171. sideOrientation?: number;
  50172. frontUVs?: Vector4;
  50173. backUVs?: Vector4;
  50174. }, scene: Scene, earcutInjection?: any): Mesh;
  50175. }
  50176. }
  50177. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50178. import { Nullable } from "babylonjs/types";
  50179. import { Scene } from "babylonjs/scene";
  50180. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50181. import { Mesh } from "babylonjs/Meshes/mesh";
  50182. /**
  50183. * Class containing static functions to help procedurally build meshes
  50184. */
  50185. export class ShapeBuilder {
  50186. /**
  50187. * 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.
  50188. * * 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.
  50189. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50190. * * 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.
  50191. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50192. * * 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
  50193. * * 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
  50194. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50199. * @param name defines the name of the mesh
  50200. * @param options defines the options used to create the mesh
  50201. * @param scene defines the hosting scene
  50202. * @returns the extruded shape mesh
  50203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50205. */
  50206. static ExtrudeShape(name: string, options: {
  50207. shape: Vector3[];
  50208. path: Vector3[];
  50209. scale?: number;
  50210. rotation?: number;
  50211. cap?: number;
  50212. updatable?: boolean;
  50213. sideOrientation?: number;
  50214. frontUVs?: Vector4;
  50215. backUVs?: Vector4;
  50216. instance?: Mesh;
  50217. invertUV?: boolean;
  50218. }, scene?: Nullable<Scene>): Mesh;
  50219. /**
  50220. * Creates an custom extruded shape mesh.
  50221. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50222. * * 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.
  50223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50224. * * 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
  50225. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50226. * * 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
  50227. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50228. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50229. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50230. * * 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
  50231. * * 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
  50232. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50237. * @param name defines the name of the mesh
  50238. * @param options defines the options used to create the mesh
  50239. * @param scene defines the hosting scene
  50240. * @returns the custom extruded shape mesh
  50241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50244. */
  50245. static ExtrudeShapeCustom(name: string, options: {
  50246. shape: Vector3[];
  50247. path: Vector3[];
  50248. scaleFunction?: any;
  50249. rotationFunction?: any;
  50250. ribbonCloseArray?: boolean;
  50251. ribbonClosePath?: boolean;
  50252. cap?: number;
  50253. updatable?: boolean;
  50254. sideOrientation?: number;
  50255. frontUVs?: Vector4;
  50256. backUVs?: Vector4;
  50257. instance?: Mesh;
  50258. invertUV?: boolean;
  50259. }, scene: Scene): Mesh;
  50260. private static _ExtrudeShapeGeneric;
  50261. }
  50262. }
  50263. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50264. import { Scene } from "babylonjs/scene";
  50265. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50266. import { Mesh } from "babylonjs/Meshes/mesh";
  50267. /**
  50268. * Class containing static functions to help procedurally build meshes
  50269. */
  50270. export class LatheBuilder {
  50271. /**
  50272. * Creates lathe mesh.
  50273. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50274. * * 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
  50275. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50276. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50277. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50278. * * 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
  50279. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50280. * * 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
  50281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50283. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50285. * @param name defines the name of the mesh
  50286. * @param options defines the options used to create the mesh
  50287. * @param scene defines the hosting scene
  50288. * @returns the lathe mesh
  50289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50290. */
  50291. static CreateLathe(name: string, options: {
  50292. shape: Vector3[];
  50293. radius?: number;
  50294. tessellation?: number;
  50295. clip?: number;
  50296. arc?: number;
  50297. closed?: boolean;
  50298. updatable?: boolean;
  50299. sideOrientation?: number;
  50300. frontUVs?: Vector4;
  50301. backUVs?: Vector4;
  50302. cap?: number;
  50303. invertUV?: boolean;
  50304. }, scene: Scene): Mesh;
  50305. }
  50306. }
  50307. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50308. import { Scene } from "babylonjs/scene";
  50309. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50310. import { Mesh } from "babylonjs/Meshes/mesh";
  50311. /**
  50312. * Class containing static functions to help procedurally build meshes
  50313. */
  50314. export class TubeBuilder {
  50315. /**
  50316. * Creates a tube mesh.
  50317. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50318. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50319. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50320. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50321. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50322. * * 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)
  50323. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50324. * * 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
  50325. * * 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
  50326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50328. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50330. * @param name defines the name of the mesh
  50331. * @param options defines the options used to create the mesh
  50332. * @param scene defines the hosting scene
  50333. * @returns the tube mesh
  50334. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50335. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50336. */
  50337. static CreateTube(name: string, options: {
  50338. path: Vector3[];
  50339. radius?: number;
  50340. tessellation?: number;
  50341. radiusFunction?: {
  50342. (i: number, distance: number): number;
  50343. };
  50344. cap?: number;
  50345. arc?: number;
  50346. updatable?: boolean;
  50347. sideOrientation?: number;
  50348. frontUVs?: Vector4;
  50349. backUVs?: Vector4;
  50350. instance?: Mesh;
  50351. invertUV?: boolean;
  50352. }, scene: Scene): Mesh;
  50353. }
  50354. }
  50355. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50356. import { Scene } from "babylonjs/scene";
  50357. import { Vector4 } from "babylonjs/Maths/math";
  50358. import { Mesh } from "babylonjs/Meshes/mesh";
  50359. /**
  50360. * Class containing static functions to help procedurally build meshes
  50361. */
  50362. export class IcoSphereBuilder {
  50363. /**
  50364. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50365. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50366. * * 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`)
  50367. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50368. * * 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
  50369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50372. * @param name defines the name of the mesh
  50373. * @param options defines the options used to create the mesh
  50374. * @param scene defines the hosting scene
  50375. * @returns the icosahedron mesh
  50376. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50377. */
  50378. static CreateIcoSphere(name: string, options: {
  50379. radius?: number;
  50380. radiusX?: number;
  50381. radiusY?: number;
  50382. radiusZ?: number;
  50383. flat?: boolean;
  50384. subdivisions?: number;
  50385. sideOrientation?: number;
  50386. frontUVs?: Vector4;
  50387. backUVs?: Vector4;
  50388. updatable?: boolean;
  50389. }, scene: Scene): Mesh;
  50390. }
  50391. }
  50392. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50393. import { Vector3 } from "babylonjs/Maths/math";
  50394. import { Mesh } from "babylonjs/Meshes/mesh";
  50395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50396. /**
  50397. * Class containing static functions to help procedurally build meshes
  50398. */
  50399. export class DecalBuilder {
  50400. /**
  50401. * Creates a decal mesh.
  50402. * 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
  50403. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50404. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50405. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50406. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50407. * @param name defines the name of the mesh
  50408. * @param sourceMesh defines the mesh where the decal must be applied
  50409. * @param options defines the options used to create the mesh
  50410. * @param scene defines the hosting scene
  50411. * @returns the decal mesh
  50412. * @see https://doc.babylonjs.com/how_to/decals
  50413. */
  50414. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50415. position?: Vector3;
  50416. normal?: Vector3;
  50417. size?: Vector3;
  50418. angle?: number;
  50419. }): Mesh;
  50420. }
  50421. }
  50422. declare module "babylonjs/Meshes/meshBuilder" {
  50423. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50424. import { Nullable } from "babylonjs/types";
  50425. import { Scene } from "babylonjs/scene";
  50426. import { Mesh } from "babylonjs/Meshes/mesh";
  50427. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50428. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50430. /**
  50431. * Class containing static functions to help procedurally build meshes
  50432. */
  50433. export class MeshBuilder {
  50434. /**
  50435. * Creates a box mesh
  50436. * * The parameter `size` sets the size (float) of each box side (default 1)
  50437. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50438. * * 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)
  50439. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50443. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50444. * @param name defines the name of the mesh
  50445. * @param options defines the options used to create the mesh
  50446. * @param scene defines the hosting scene
  50447. * @returns the box mesh
  50448. */
  50449. static CreateBox(name: string, options: {
  50450. size?: number;
  50451. width?: number;
  50452. height?: number;
  50453. depth?: number;
  50454. faceUV?: Vector4[];
  50455. faceColors?: Color4[];
  50456. sideOrientation?: number;
  50457. frontUVs?: Vector4;
  50458. backUVs?: Vector4;
  50459. updatable?: boolean;
  50460. }, scene?: Nullable<Scene>): Mesh;
  50461. /**
  50462. * Creates a sphere mesh
  50463. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50464. * * 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`)
  50465. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50466. * * 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
  50467. * * 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)
  50468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50471. * @param name defines the name of the mesh
  50472. * @param options defines the options used to create the mesh
  50473. * @param scene defines the hosting scene
  50474. * @returns the sphere mesh
  50475. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50476. */
  50477. static CreateSphere(name: string, options: {
  50478. segments?: number;
  50479. diameter?: number;
  50480. diameterX?: number;
  50481. diameterY?: number;
  50482. diameterZ?: number;
  50483. arc?: number;
  50484. slice?: number;
  50485. sideOrientation?: number;
  50486. frontUVs?: Vector4;
  50487. backUVs?: Vector4;
  50488. updatable?: boolean;
  50489. }, scene: any): Mesh;
  50490. /**
  50491. * Creates a plane polygonal mesh. By default, this is a disc
  50492. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50493. * * 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
  50494. * * 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
  50495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50498. * @param name defines the name of the mesh
  50499. * @param options defines the options used to create the mesh
  50500. * @param scene defines the hosting scene
  50501. * @returns the plane polygonal mesh
  50502. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50503. */
  50504. static CreateDisc(name: string, options: {
  50505. radius?: number;
  50506. tessellation?: number;
  50507. arc?: number;
  50508. updatable?: boolean;
  50509. sideOrientation?: number;
  50510. frontUVs?: Vector4;
  50511. backUVs?: Vector4;
  50512. }, scene?: Nullable<Scene>): Mesh;
  50513. /**
  50514. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50515. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50516. * * 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`)
  50517. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50518. * * 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
  50519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50522. * @param name defines the name of the mesh
  50523. * @param options defines the options used to create the mesh
  50524. * @param scene defines the hosting scene
  50525. * @returns the icosahedron mesh
  50526. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50527. */
  50528. static CreateIcoSphere(name: string, options: {
  50529. radius?: number;
  50530. radiusX?: number;
  50531. radiusY?: number;
  50532. radiusZ?: number;
  50533. flat?: boolean;
  50534. subdivisions?: number;
  50535. sideOrientation?: number;
  50536. frontUVs?: Vector4;
  50537. backUVs?: Vector4;
  50538. updatable?: boolean;
  50539. }, scene: Scene): Mesh;
  50540. /**
  50541. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50542. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50543. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50544. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50545. * * 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
  50546. * * 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
  50547. * * 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
  50548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50551. * * 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
  50552. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50553. * * 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
  50554. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50556. * @param name defines the name of the mesh
  50557. * @param options defines the options used to create the mesh
  50558. * @param scene defines the hosting scene
  50559. * @returns the ribbon mesh
  50560. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50562. */
  50563. static CreateRibbon(name: string, options: {
  50564. pathArray: Vector3[][];
  50565. closeArray?: boolean;
  50566. closePath?: boolean;
  50567. offset?: number;
  50568. updatable?: boolean;
  50569. sideOrientation?: number;
  50570. frontUVs?: Vector4;
  50571. backUVs?: Vector4;
  50572. instance?: Mesh;
  50573. invertUV?: boolean;
  50574. uvs?: Vector2[];
  50575. colors?: Color4[];
  50576. }, scene?: Nullable<Scene>): Mesh;
  50577. /**
  50578. * Creates a cylinder or a cone mesh
  50579. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50580. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50581. * * 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.
  50582. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50583. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50584. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50585. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50586. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50587. * * 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).
  50588. * * 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
  50589. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50590. * * 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
  50591. * * 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.
  50592. * * If `enclose` is false, a ring surface is one element.
  50593. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50594. * * 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
  50595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50598. * @param name defines the name of the mesh
  50599. * @param options defines the options used to create the mesh
  50600. * @param scene defines the hosting scene
  50601. * @returns the cylinder mesh
  50602. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50603. */
  50604. static CreateCylinder(name: string, options: {
  50605. height?: number;
  50606. diameterTop?: number;
  50607. diameterBottom?: number;
  50608. diameter?: number;
  50609. tessellation?: number;
  50610. subdivisions?: number;
  50611. arc?: number;
  50612. faceColors?: Color4[];
  50613. faceUV?: Vector4[];
  50614. updatable?: boolean;
  50615. hasRings?: boolean;
  50616. enclose?: boolean;
  50617. sideOrientation?: number;
  50618. frontUVs?: Vector4;
  50619. backUVs?: Vector4;
  50620. }, scene: any): Mesh;
  50621. /**
  50622. * Creates a torus mesh
  50623. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50624. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50625. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50629. * @param name defines the name of the mesh
  50630. * @param options defines the options used to create the mesh
  50631. * @param scene defines the hosting scene
  50632. * @returns the torus mesh
  50633. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50634. */
  50635. static CreateTorus(name: string, options: {
  50636. diameter?: number;
  50637. thickness?: number;
  50638. tessellation?: number;
  50639. updatable?: boolean;
  50640. sideOrientation?: number;
  50641. frontUVs?: Vector4;
  50642. backUVs?: Vector4;
  50643. }, scene: any): Mesh;
  50644. /**
  50645. * Creates a torus knot mesh
  50646. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50647. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50648. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50649. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50653. * @param name defines the name of the mesh
  50654. * @param options defines the options used to create the mesh
  50655. * @param scene defines the hosting scene
  50656. * @returns the torus knot mesh
  50657. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50658. */
  50659. static CreateTorusKnot(name: string, options: {
  50660. radius?: number;
  50661. tube?: number;
  50662. radialSegments?: number;
  50663. tubularSegments?: number;
  50664. p?: number;
  50665. q?: number;
  50666. updatable?: boolean;
  50667. sideOrientation?: number;
  50668. frontUVs?: Vector4;
  50669. backUVs?: Vector4;
  50670. }, scene: any): Mesh;
  50671. /**
  50672. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50673. * * 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
  50674. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50675. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50676. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50677. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50678. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50679. * * 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
  50680. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50683. * @param name defines the name of the new line system
  50684. * @param options defines the options used to create the line system
  50685. * @param scene defines the hosting scene
  50686. * @returns a new line system mesh
  50687. */
  50688. static CreateLineSystem(name: string, options: {
  50689. lines: Vector3[][];
  50690. updatable?: boolean;
  50691. instance?: Nullable<LinesMesh>;
  50692. colors?: Nullable<Color4[][]>;
  50693. useVertexAlpha?: boolean;
  50694. }, scene: Nullable<Scene>): LinesMesh;
  50695. /**
  50696. * Creates a line mesh
  50697. * 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
  50698. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50699. * * The parameter `points` is an array successive Vector3
  50700. * * 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
  50701. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50702. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50703. * * When updating an instance, remember that only point positions can change, not the number of points
  50704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50706. * @param name defines the name of the new line system
  50707. * @param options defines the options used to create the line system
  50708. * @param scene defines the hosting scene
  50709. * @returns a new line mesh
  50710. */
  50711. static CreateLines(name: string, options: {
  50712. points: Vector3[];
  50713. updatable?: boolean;
  50714. instance?: Nullable<LinesMesh>;
  50715. colors?: Color4[];
  50716. useVertexAlpha?: boolean;
  50717. }, scene?: Nullable<Scene>): LinesMesh;
  50718. /**
  50719. * Creates a dashed line mesh
  50720. * * 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
  50721. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50722. * * The parameter `points` is an array successive Vector3
  50723. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50724. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50725. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50726. * * 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
  50727. * * When updating an instance, remember that only point positions can change, not the number of points
  50728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50729. * @param name defines the name of the mesh
  50730. * @param options defines the options used to create the mesh
  50731. * @param scene defines the hosting scene
  50732. * @returns the dashed line mesh
  50733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50734. */
  50735. static CreateDashedLines(name: string, options: {
  50736. points: Vector3[];
  50737. dashSize?: number;
  50738. gapSize?: number;
  50739. dashNb?: number;
  50740. updatable?: boolean;
  50741. instance?: LinesMesh;
  50742. }, scene?: Nullable<Scene>): LinesMesh;
  50743. /**
  50744. * 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.
  50745. * * 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.
  50746. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50747. * * 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.
  50748. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50749. * * 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
  50750. * * 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
  50751. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50756. * @param name defines the name of the mesh
  50757. * @param options defines the options used to create the mesh
  50758. * @param scene defines the hosting scene
  50759. * @returns the extruded shape mesh
  50760. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50762. */
  50763. static ExtrudeShape(name: string, options: {
  50764. shape: Vector3[];
  50765. path: Vector3[];
  50766. scale?: number;
  50767. rotation?: number;
  50768. cap?: number;
  50769. updatable?: boolean;
  50770. sideOrientation?: number;
  50771. frontUVs?: Vector4;
  50772. backUVs?: Vector4;
  50773. instance?: Mesh;
  50774. invertUV?: boolean;
  50775. }, scene?: Nullable<Scene>): Mesh;
  50776. /**
  50777. * Creates an custom extruded shape mesh.
  50778. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50779. * * 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.
  50780. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50781. * * 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
  50782. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50783. * * 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
  50784. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50785. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50786. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50787. * * 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
  50788. * * 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
  50789. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50794. * @param name defines the name of the mesh
  50795. * @param options defines the options used to create the mesh
  50796. * @param scene defines the hosting scene
  50797. * @returns the custom extruded shape mesh
  50798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50801. */
  50802. static ExtrudeShapeCustom(name: string, options: {
  50803. shape: Vector3[];
  50804. path: Vector3[];
  50805. scaleFunction?: any;
  50806. rotationFunction?: any;
  50807. ribbonCloseArray?: boolean;
  50808. ribbonClosePath?: boolean;
  50809. cap?: number;
  50810. updatable?: boolean;
  50811. sideOrientation?: number;
  50812. frontUVs?: Vector4;
  50813. backUVs?: Vector4;
  50814. instance?: Mesh;
  50815. invertUV?: boolean;
  50816. }, scene: Scene): Mesh;
  50817. /**
  50818. * Creates lathe mesh.
  50819. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50820. * * 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
  50821. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50822. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50823. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50824. * * 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
  50825. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50826. * * 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
  50827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50829. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50831. * @param name defines the name of the mesh
  50832. * @param options defines the options used to create the mesh
  50833. * @param scene defines the hosting scene
  50834. * @returns the lathe mesh
  50835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50836. */
  50837. static CreateLathe(name: string, options: {
  50838. shape: Vector3[];
  50839. radius?: number;
  50840. tessellation?: number;
  50841. clip?: number;
  50842. arc?: number;
  50843. closed?: boolean;
  50844. updatable?: boolean;
  50845. sideOrientation?: number;
  50846. frontUVs?: Vector4;
  50847. backUVs?: Vector4;
  50848. cap?: number;
  50849. invertUV?: boolean;
  50850. }, scene: Scene): Mesh;
  50851. /**
  50852. * Creates a plane mesh
  50853. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50854. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50855. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50859. * @param name defines the name of the mesh
  50860. * @param options defines the options used to create the mesh
  50861. * @param scene defines the hosting scene
  50862. * @returns the plane mesh
  50863. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50864. */
  50865. static CreatePlane(name: string, options: {
  50866. size?: number;
  50867. width?: number;
  50868. height?: number;
  50869. sideOrientation?: number;
  50870. frontUVs?: Vector4;
  50871. backUVs?: Vector4;
  50872. updatable?: boolean;
  50873. sourcePlane?: Plane;
  50874. }, scene: Scene): Mesh;
  50875. /**
  50876. * Creates a ground mesh
  50877. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50878. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50880. * @param name defines the name of the mesh
  50881. * @param options defines the options used to create the mesh
  50882. * @param scene defines the hosting scene
  50883. * @returns the ground mesh
  50884. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50885. */
  50886. static CreateGround(name: string, options: {
  50887. width?: number;
  50888. height?: number;
  50889. subdivisions?: number;
  50890. subdivisionsX?: number;
  50891. subdivisionsY?: number;
  50892. updatable?: boolean;
  50893. }, scene: any): Mesh;
  50894. /**
  50895. * Creates a tiled ground mesh
  50896. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50897. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50898. * * 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
  50899. * * 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
  50900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50901. * @param name defines the name of the mesh
  50902. * @param options defines the options used to create the mesh
  50903. * @param scene defines the hosting scene
  50904. * @returns the tiled ground mesh
  50905. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50906. */
  50907. static CreateTiledGround(name: string, options: {
  50908. xmin: number;
  50909. zmin: number;
  50910. xmax: number;
  50911. zmax: number;
  50912. subdivisions?: {
  50913. w: number;
  50914. h: number;
  50915. };
  50916. precision?: {
  50917. w: number;
  50918. h: number;
  50919. };
  50920. updatable?: boolean;
  50921. }, scene: Scene): Mesh;
  50922. /**
  50923. * Creates a ground mesh from a height map
  50924. * * The parameter `url` sets the URL of the height map image resource.
  50925. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50926. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50927. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50928. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50929. * * 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.
  50930. * * 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).
  50931. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50933. * @param name defines the name of the mesh
  50934. * @param url defines the url to the height map
  50935. * @param options defines the options used to create the mesh
  50936. * @param scene defines the hosting scene
  50937. * @returns the ground mesh
  50938. * @see https://doc.babylonjs.com/babylon101/height_map
  50939. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50940. */
  50941. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50942. width?: number;
  50943. height?: number;
  50944. subdivisions?: number;
  50945. minHeight?: number;
  50946. maxHeight?: number;
  50947. colorFilter?: Color3;
  50948. alphaFilter?: number;
  50949. updatable?: boolean;
  50950. onReady?: (mesh: GroundMesh) => void;
  50951. }, scene: Scene): GroundMesh;
  50952. /**
  50953. * Creates a polygon mesh
  50954. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50955. * * 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
  50956. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50959. * * Remember you can only change the shape positions, not their number when updating a polygon
  50960. * @param name defines the name of the mesh
  50961. * @param options defines the options used to create the mesh
  50962. * @param scene defines the hosting scene
  50963. * @param earcutInjection can be used to inject your own earcut reference
  50964. * @returns the polygon mesh
  50965. */
  50966. static CreatePolygon(name: string, options: {
  50967. shape: Vector3[];
  50968. holes?: Vector3[][];
  50969. depth?: number;
  50970. faceUV?: Vector4[];
  50971. faceColors?: Color4[];
  50972. updatable?: boolean;
  50973. sideOrientation?: number;
  50974. frontUVs?: Vector4;
  50975. backUVs?: Vector4;
  50976. }, scene: Scene, earcutInjection?: any): Mesh;
  50977. /**
  50978. * Creates an extruded polygon mesh, with depth in the Y direction.
  50979. * * 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)
  50980. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50981. * @param name defines the name of the mesh
  50982. * @param options defines the options used to create the mesh
  50983. * @param scene defines the hosting scene
  50984. * @param earcutInjection can be used to inject your own earcut reference
  50985. * @returns the polygon mesh
  50986. */
  50987. static ExtrudePolygon(name: string, options: {
  50988. shape: Vector3[];
  50989. holes?: Vector3[][];
  50990. depth?: number;
  50991. faceUV?: Vector4[];
  50992. faceColors?: Color4[];
  50993. updatable?: boolean;
  50994. sideOrientation?: number;
  50995. frontUVs?: Vector4;
  50996. backUVs?: Vector4;
  50997. }, scene: Scene, earcutInjection?: any): Mesh;
  50998. /**
  50999. * Creates a tube mesh.
  51000. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51001. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51002. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51003. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51004. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51005. * * 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)
  51006. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51007. * * 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
  51008. * * 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
  51009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51013. * @param name defines the name of the mesh
  51014. * @param options defines the options used to create the mesh
  51015. * @param scene defines the hosting scene
  51016. * @returns the tube mesh
  51017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51018. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51019. */
  51020. static CreateTube(name: string, options: {
  51021. path: Vector3[];
  51022. radius?: number;
  51023. tessellation?: number;
  51024. radiusFunction?: {
  51025. (i: number, distance: number): number;
  51026. };
  51027. cap?: number;
  51028. arc?: number;
  51029. updatable?: boolean;
  51030. sideOrientation?: number;
  51031. frontUVs?: Vector4;
  51032. backUVs?: Vector4;
  51033. instance?: Mesh;
  51034. invertUV?: boolean;
  51035. }, scene: Scene): Mesh;
  51036. /**
  51037. * Creates a polyhedron mesh
  51038. * * 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
  51039. * * The parameter `size` (positive float, default 1) sets the polygon size
  51040. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51041. * * 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`
  51042. * * 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
  51043. * * 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)`)
  51044. * * 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
  51045. * * 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
  51046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51049. * @param name defines the name of the mesh
  51050. * @param options defines the options used to create the mesh
  51051. * @param scene defines the hosting scene
  51052. * @returns the polyhedron mesh
  51053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51054. */
  51055. static CreatePolyhedron(name: string, options: {
  51056. type?: number;
  51057. size?: number;
  51058. sizeX?: number;
  51059. sizeY?: number;
  51060. sizeZ?: number;
  51061. custom?: any;
  51062. faceUV?: Vector4[];
  51063. faceColors?: Color4[];
  51064. flat?: boolean;
  51065. updatable?: boolean;
  51066. sideOrientation?: number;
  51067. frontUVs?: Vector4;
  51068. backUVs?: Vector4;
  51069. }, scene: Scene): Mesh;
  51070. /**
  51071. * Creates a decal mesh.
  51072. * 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
  51073. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51074. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51075. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51076. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51077. * @param name defines the name of the mesh
  51078. * @param sourceMesh defines the mesh where the decal must be applied
  51079. * @param options defines the options used to create the mesh
  51080. * @param scene defines the hosting scene
  51081. * @returns the decal mesh
  51082. * @see https://doc.babylonjs.com/how_to/decals
  51083. */
  51084. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51085. position?: Vector3;
  51086. normal?: Vector3;
  51087. size?: Vector3;
  51088. angle?: number;
  51089. }): Mesh;
  51090. }
  51091. }
  51092. declare module "babylonjs/Meshes/meshSimplification" {
  51093. import { Mesh } from "babylonjs/Meshes/mesh";
  51094. /**
  51095. * A simplifier interface for future simplification implementations
  51096. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51097. */
  51098. export interface ISimplifier {
  51099. /**
  51100. * Simplification of a given mesh according to the given settings.
  51101. * Since this requires computation, it is assumed that the function runs async.
  51102. * @param settings The settings of the simplification, including quality and distance
  51103. * @param successCallback A callback that will be called after the mesh was simplified.
  51104. * @param errorCallback in case of an error, this callback will be called. optional.
  51105. */
  51106. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51107. }
  51108. /**
  51109. * Expected simplification settings.
  51110. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51111. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51112. */
  51113. export interface ISimplificationSettings {
  51114. /**
  51115. * Gets or sets the expected quality
  51116. */
  51117. quality: number;
  51118. /**
  51119. * Gets or sets the distance when this optimized version should be used
  51120. */
  51121. distance: number;
  51122. /**
  51123. * Gets an already optimized mesh
  51124. */
  51125. optimizeMesh?: boolean;
  51126. }
  51127. /**
  51128. * Class used to specify simplification options
  51129. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51130. */
  51131. export class SimplificationSettings implements ISimplificationSettings {
  51132. /** expected quality */
  51133. quality: number;
  51134. /** distance when this optimized version should be used */
  51135. distance: number;
  51136. /** already optimized mesh */
  51137. optimizeMesh?: boolean | undefined;
  51138. /**
  51139. * Creates a SimplificationSettings
  51140. * @param quality expected quality
  51141. * @param distance distance when this optimized version should be used
  51142. * @param optimizeMesh already optimized mesh
  51143. */
  51144. constructor(
  51145. /** expected quality */
  51146. quality: number,
  51147. /** distance when this optimized version should be used */
  51148. distance: number,
  51149. /** already optimized mesh */
  51150. optimizeMesh?: boolean | undefined);
  51151. }
  51152. /**
  51153. * Interface used to define a simplification task
  51154. */
  51155. export interface ISimplificationTask {
  51156. /**
  51157. * Array of settings
  51158. */
  51159. settings: Array<ISimplificationSettings>;
  51160. /**
  51161. * Simplification type
  51162. */
  51163. simplificationType: SimplificationType;
  51164. /**
  51165. * Mesh to simplify
  51166. */
  51167. mesh: Mesh;
  51168. /**
  51169. * Callback called on success
  51170. */
  51171. successCallback?: () => void;
  51172. /**
  51173. * Defines if parallel processing can be used
  51174. */
  51175. parallelProcessing: boolean;
  51176. }
  51177. /**
  51178. * Queue used to order the simplification tasks
  51179. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51180. */
  51181. export class SimplificationQueue {
  51182. private _simplificationArray;
  51183. /**
  51184. * Gets a boolean indicating that the process is still running
  51185. */
  51186. running: boolean;
  51187. /**
  51188. * Creates a new queue
  51189. */
  51190. constructor();
  51191. /**
  51192. * Adds a new simplification task
  51193. * @param task defines a task to add
  51194. */
  51195. addTask(task: ISimplificationTask): void;
  51196. /**
  51197. * Execute next task
  51198. */
  51199. executeNext(): void;
  51200. /**
  51201. * Execute a simplification task
  51202. * @param task defines the task to run
  51203. */
  51204. runSimplification(task: ISimplificationTask): void;
  51205. private getSimplifier;
  51206. }
  51207. /**
  51208. * The implemented types of simplification
  51209. * At the moment only Quadratic Error Decimation is implemented
  51210. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51211. */
  51212. export enum SimplificationType {
  51213. /** Quadratic error decimation */
  51214. QUADRATIC = 0
  51215. }
  51216. }
  51217. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51218. import { Scene } from "babylonjs/scene";
  51219. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51220. import { ISceneComponent } from "babylonjs/sceneComponent";
  51221. module "babylonjs/scene" {
  51222. interface Scene {
  51223. /** @hidden (Backing field) */
  51224. _simplificationQueue: SimplificationQueue;
  51225. /**
  51226. * Gets or sets the simplification queue attached to the scene
  51227. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51228. */
  51229. simplificationQueue: SimplificationQueue;
  51230. }
  51231. }
  51232. module "babylonjs/Meshes/mesh" {
  51233. interface Mesh {
  51234. /**
  51235. * Simplify the mesh according to the given array of settings.
  51236. * Function will return immediately and will simplify async
  51237. * @param settings a collection of simplification settings
  51238. * @param parallelProcessing should all levels calculate parallel or one after the other
  51239. * @param simplificationType the type of simplification to run
  51240. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51241. * @returns the current mesh
  51242. */
  51243. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51244. }
  51245. }
  51246. /**
  51247. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51248. * created in a scene
  51249. */
  51250. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51251. /**
  51252. * The component name helpfull to identify the component in the list of scene components.
  51253. */
  51254. readonly name: string;
  51255. /**
  51256. * The scene the component belongs to.
  51257. */
  51258. scene: Scene;
  51259. /**
  51260. * Creates a new instance of the component for the given scene
  51261. * @param scene Defines the scene to register the component in
  51262. */
  51263. constructor(scene: Scene);
  51264. /**
  51265. * Registers the component in a given scene
  51266. */
  51267. register(): void;
  51268. /**
  51269. * Rebuilds the elements related to this component in case of
  51270. * context lost for instance.
  51271. */
  51272. rebuild(): void;
  51273. /**
  51274. * Disposes the component and the associated ressources
  51275. */
  51276. dispose(): void;
  51277. private _beforeCameraUpdate;
  51278. }
  51279. }
  51280. declare module "babylonjs/Meshes/Builders/index" {
  51281. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51282. export * from "babylonjs/Meshes/Builders/discBuilder";
  51283. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51284. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51285. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51286. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51287. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51288. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51289. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51290. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51291. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51292. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51293. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51294. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51295. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51296. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51297. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51298. }
  51299. declare module "babylonjs/Meshes/index" {
  51300. export * from "babylonjs/Meshes/abstractMesh";
  51301. export * from "babylonjs/Meshes/buffer";
  51302. export * from "babylonjs/Meshes/Compression/index";
  51303. export * from "babylonjs/Meshes/csg";
  51304. export * from "babylonjs/Meshes/geometry";
  51305. export * from "babylonjs/Meshes/groundMesh";
  51306. export * from "babylonjs/Meshes/trailMesh";
  51307. export * from "babylonjs/Meshes/instancedMesh";
  51308. export * from "babylonjs/Meshes/linesMesh";
  51309. export * from "babylonjs/Meshes/mesh";
  51310. export * from "babylonjs/Meshes/mesh.vertexData";
  51311. export * from "babylonjs/Meshes/meshBuilder";
  51312. export * from "babylonjs/Meshes/meshSimplification";
  51313. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51314. export * from "babylonjs/Meshes/polygonMesh";
  51315. export * from "babylonjs/Meshes/subMesh";
  51316. export * from "babylonjs/Meshes/transformNode";
  51317. export * from "babylonjs/Meshes/Builders/index";
  51318. }
  51319. declare module "babylonjs/Morph/index" {
  51320. export * from "babylonjs/Morph/morphTarget";
  51321. export * from "babylonjs/Morph/morphTargetManager";
  51322. }
  51323. declare module "babylonjs/Offline/database" {
  51324. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51325. /**
  51326. * Class used to enable access to IndexedDB
  51327. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51328. */
  51329. export class Database implements IOfflineProvider {
  51330. private _callbackManifestChecked;
  51331. private _currentSceneUrl;
  51332. private _db;
  51333. private _enableSceneOffline;
  51334. private _enableTexturesOffline;
  51335. private _manifestVersionFound;
  51336. private _mustUpdateRessources;
  51337. private _hasReachedQuota;
  51338. private _isSupported;
  51339. private _idbFactory;
  51340. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51341. private static IsUASupportingBlobStorage;
  51342. /**
  51343. * Gets a boolean indicating if Database storate is enabled (off by default)
  51344. */
  51345. static IDBStorageEnabled: boolean;
  51346. /**
  51347. * Gets a boolean indicating if scene must be saved in the database
  51348. */
  51349. readonly enableSceneOffline: boolean;
  51350. /**
  51351. * Gets a boolean indicating if textures must be saved in the database
  51352. */
  51353. readonly enableTexturesOffline: boolean;
  51354. /**
  51355. * Creates a new Database
  51356. * @param urlToScene defines the url to load the scene
  51357. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51358. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51359. */
  51360. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51361. private static _ParseURL;
  51362. private static _ReturnFullUrlLocation;
  51363. private _checkManifestFile;
  51364. /**
  51365. * Open the database and make it available
  51366. * @param successCallback defines the callback to call on success
  51367. * @param errorCallback defines the callback to call on error
  51368. */
  51369. open(successCallback: () => void, errorCallback: () => void): void;
  51370. /**
  51371. * Loads an image from the database
  51372. * @param url defines the url to load from
  51373. * @param image defines the target DOM image
  51374. */
  51375. loadImage(url: string, image: HTMLImageElement): void;
  51376. private _loadImageFromDBAsync;
  51377. private _saveImageIntoDBAsync;
  51378. private _checkVersionFromDB;
  51379. private _loadVersionFromDBAsync;
  51380. private _saveVersionIntoDBAsync;
  51381. /**
  51382. * Loads a file from database
  51383. * @param url defines the URL to load from
  51384. * @param sceneLoaded defines a callback to call on success
  51385. * @param progressCallBack defines a callback to call when progress changed
  51386. * @param errorCallback defines a callback to call on error
  51387. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51388. */
  51389. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51390. private _loadFileAsync;
  51391. private _saveFileAsync;
  51392. /**
  51393. * Validates if xhr data is correct
  51394. * @param xhr defines the request to validate
  51395. * @param dataType defines the expected data type
  51396. * @returns true if data is correct
  51397. */
  51398. private static _ValidateXHRData;
  51399. }
  51400. }
  51401. declare module "babylonjs/Offline/index" {
  51402. export * from "babylonjs/Offline/database";
  51403. export * from "babylonjs/Offline/IOfflineProvider";
  51404. }
  51405. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51406. /** @hidden */
  51407. export var gpuUpdateParticlesPixelShader: {
  51408. name: string;
  51409. shader: string;
  51410. };
  51411. }
  51412. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51413. /** @hidden */
  51414. export var gpuUpdateParticlesVertexShader: {
  51415. name: string;
  51416. shader: string;
  51417. };
  51418. }
  51419. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51420. /** @hidden */
  51421. export var clipPlaneFragmentDeclaration2: {
  51422. name: string;
  51423. shader: string;
  51424. };
  51425. }
  51426. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51427. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51428. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51429. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51430. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51431. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51432. /** @hidden */
  51433. export var gpuRenderParticlesPixelShader: {
  51434. name: string;
  51435. shader: string;
  51436. };
  51437. }
  51438. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51439. /** @hidden */
  51440. export var clipPlaneVertexDeclaration2: {
  51441. name: string;
  51442. shader: string;
  51443. };
  51444. }
  51445. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51446. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51447. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51448. /** @hidden */
  51449. export var gpuRenderParticlesVertexShader: {
  51450. name: string;
  51451. shader: string;
  51452. };
  51453. }
  51454. declare module "babylonjs/Particles/gpuParticleSystem" {
  51455. import { Nullable } from "babylonjs/types";
  51456. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51457. import { Observable } from "babylonjs/Misc/observable";
  51458. import { Color4, Color3 } from "babylonjs/Maths/math";
  51459. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51460. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51461. import { Scene, IDisposable } from "babylonjs/scene";
  51462. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51463. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51464. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51465. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51466. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51467. /**
  51468. * This represents a GPU particle system in Babylon
  51469. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51470. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51471. */
  51472. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51473. /**
  51474. * The layer mask we are rendering the particles through.
  51475. */
  51476. layerMask: number;
  51477. private _capacity;
  51478. private _activeCount;
  51479. private _currentActiveCount;
  51480. private _accumulatedCount;
  51481. private _renderEffect;
  51482. private _updateEffect;
  51483. private _buffer0;
  51484. private _buffer1;
  51485. private _spriteBuffer;
  51486. private _updateVAO;
  51487. private _renderVAO;
  51488. private _targetIndex;
  51489. private _sourceBuffer;
  51490. private _targetBuffer;
  51491. private _engine;
  51492. private _currentRenderId;
  51493. private _started;
  51494. private _stopped;
  51495. private _timeDelta;
  51496. private _randomTexture;
  51497. private _randomTexture2;
  51498. private _attributesStrideSize;
  51499. private _updateEffectOptions;
  51500. private _randomTextureSize;
  51501. private _actualFrame;
  51502. private readonly _rawTextureWidth;
  51503. /**
  51504. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51505. */
  51506. static readonly IsSupported: boolean;
  51507. /**
  51508. * An event triggered when the system is disposed.
  51509. */
  51510. onDisposeObservable: Observable<GPUParticleSystem>;
  51511. /**
  51512. * Gets the maximum number of particles active at the same time.
  51513. * @returns The max number of active particles.
  51514. */
  51515. getCapacity(): number;
  51516. /**
  51517. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51518. * to override the particles.
  51519. */
  51520. forceDepthWrite: boolean;
  51521. /**
  51522. * Gets or set the number of active particles
  51523. */
  51524. activeParticleCount: number;
  51525. private _preWarmDone;
  51526. /**
  51527. * Is this system ready to be used/rendered
  51528. * @return true if the system is ready
  51529. */
  51530. isReady(): boolean;
  51531. /**
  51532. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51533. * @returns True if it has been started, otherwise false.
  51534. */
  51535. isStarted(): boolean;
  51536. /**
  51537. * Starts the particle system and begins to emit
  51538. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51539. */
  51540. start(delay?: number): void;
  51541. /**
  51542. * Stops the particle system.
  51543. */
  51544. stop(): void;
  51545. /**
  51546. * Remove all active particles
  51547. */
  51548. reset(): void;
  51549. /**
  51550. * Returns the string "GPUParticleSystem"
  51551. * @returns a string containing the class name
  51552. */
  51553. getClassName(): string;
  51554. private _colorGradientsTexture;
  51555. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51556. /**
  51557. * Adds a new color gradient
  51558. * @param gradient defines the gradient to use (between 0 and 1)
  51559. * @param color1 defines the color to affect to the specified gradient
  51560. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51561. * @returns the current particle system
  51562. */
  51563. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51564. /**
  51565. * Remove a specific color gradient
  51566. * @param gradient defines the gradient to remove
  51567. * @returns the current particle system
  51568. */
  51569. removeColorGradient(gradient: number): GPUParticleSystem;
  51570. private _angularSpeedGradientsTexture;
  51571. private _sizeGradientsTexture;
  51572. private _velocityGradientsTexture;
  51573. private _limitVelocityGradientsTexture;
  51574. private _dragGradientsTexture;
  51575. private _addFactorGradient;
  51576. /**
  51577. * Adds a new size gradient
  51578. * @param gradient defines the gradient to use (between 0 and 1)
  51579. * @param factor defines the size factor to affect to the specified gradient
  51580. * @returns the current particle system
  51581. */
  51582. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51583. /**
  51584. * Remove a specific size gradient
  51585. * @param gradient defines the gradient to remove
  51586. * @returns the current particle system
  51587. */
  51588. removeSizeGradient(gradient: number): GPUParticleSystem;
  51589. /**
  51590. * Adds a new angular speed gradient
  51591. * @param gradient defines the gradient to use (between 0 and 1)
  51592. * @param factor defines the angular speed to affect to the specified gradient
  51593. * @returns the current particle system
  51594. */
  51595. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51596. /**
  51597. * Remove a specific angular speed gradient
  51598. * @param gradient defines the gradient to remove
  51599. * @returns the current particle system
  51600. */
  51601. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51602. /**
  51603. * Adds a new velocity gradient
  51604. * @param gradient defines the gradient to use (between 0 and 1)
  51605. * @param factor defines the velocity to affect to the specified gradient
  51606. * @returns the current particle system
  51607. */
  51608. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51609. /**
  51610. * Remove a specific velocity gradient
  51611. * @param gradient defines the gradient to remove
  51612. * @returns the current particle system
  51613. */
  51614. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51615. /**
  51616. * Adds a new limit velocity gradient
  51617. * @param gradient defines the gradient to use (between 0 and 1)
  51618. * @param factor defines the limit velocity value to affect to the specified gradient
  51619. * @returns the current particle system
  51620. */
  51621. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51622. /**
  51623. * Remove a specific limit velocity gradient
  51624. * @param gradient defines the gradient to remove
  51625. * @returns the current particle system
  51626. */
  51627. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51628. /**
  51629. * Adds a new drag gradient
  51630. * @param gradient defines the gradient to use (between 0 and 1)
  51631. * @param factor defines the drag value to affect to the specified gradient
  51632. * @returns the current particle system
  51633. */
  51634. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51635. /**
  51636. * Remove a specific drag gradient
  51637. * @param gradient defines the gradient to remove
  51638. * @returns the current particle system
  51639. */
  51640. removeDragGradient(gradient: number): GPUParticleSystem;
  51641. /**
  51642. * Not supported by GPUParticleSystem
  51643. * @param gradient defines the gradient to use (between 0 and 1)
  51644. * @param factor defines the emit rate value to affect to the specified gradient
  51645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51646. * @returns the current particle system
  51647. */
  51648. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51649. /**
  51650. * Not supported by GPUParticleSystem
  51651. * @param gradient defines the gradient to remove
  51652. * @returns the current particle system
  51653. */
  51654. removeEmitRateGradient(gradient: number): IParticleSystem;
  51655. /**
  51656. * Not supported by GPUParticleSystem
  51657. * @param gradient defines the gradient to use (between 0 and 1)
  51658. * @param factor defines the start size value to affect to the specified gradient
  51659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51660. * @returns the current particle system
  51661. */
  51662. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51663. /**
  51664. * Not supported by GPUParticleSystem
  51665. * @param gradient defines the gradient to remove
  51666. * @returns the current particle system
  51667. */
  51668. removeStartSizeGradient(gradient: number): IParticleSystem;
  51669. /**
  51670. * Not supported by GPUParticleSystem
  51671. * @param gradient defines the gradient to use (between 0 and 1)
  51672. * @param min defines the color remap minimal range
  51673. * @param max defines the color remap maximal range
  51674. * @returns the current particle system
  51675. */
  51676. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51677. /**
  51678. * Not supported by GPUParticleSystem
  51679. * @param gradient defines the gradient to remove
  51680. * @returns the current particle system
  51681. */
  51682. removeColorRemapGradient(): IParticleSystem;
  51683. /**
  51684. * Not supported by GPUParticleSystem
  51685. * @param gradient defines the gradient to use (between 0 and 1)
  51686. * @param min defines the alpha remap minimal range
  51687. * @param max defines the alpha remap maximal range
  51688. * @returns the current particle system
  51689. */
  51690. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51691. /**
  51692. * Not supported by GPUParticleSystem
  51693. * @param gradient defines the gradient to remove
  51694. * @returns the current particle system
  51695. */
  51696. removeAlphaRemapGradient(): IParticleSystem;
  51697. /**
  51698. * Not supported by GPUParticleSystem
  51699. * @param gradient defines the gradient to use (between 0 and 1)
  51700. * @param color defines the color to affect to the specified gradient
  51701. * @returns the current particle system
  51702. */
  51703. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51704. /**
  51705. * Not supported by GPUParticleSystem
  51706. * @param gradient defines the gradient to remove
  51707. * @returns the current particle system
  51708. */
  51709. removeRampGradient(): IParticleSystem;
  51710. /**
  51711. * Not supported by GPUParticleSystem
  51712. * @returns the list of ramp gradients
  51713. */
  51714. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51715. /**
  51716. * Not supported by GPUParticleSystem
  51717. * Gets or sets a boolean indicating that ramp gradients must be used
  51718. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51719. */
  51720. useRampGradients: boolean;
  51721. /**
  51722. * Not supported by GPUParticleSystem
  51723. * @param gradient defines the gradient to use (between 0 and 1)
  51724. * @param factor defines the life time factor to affect to the specified gradient
  51725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51726. * @returns the current particle system
  51727. */
  51728. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51729. /**
  51730. * Not supported by GPUParticleSystem
  51731. * @param gradient defines the gradient to remove
  51732. * @returns the current particle system
  51733. */
  51734. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51735. /**
  51736. * Instantiates a GPU particle system.
  51737. * 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.
  51738. * @param name The name of the particle system
  51739. * @param options The options used to create the system
  51740. * @param scene The scene the particle system belongs to
  51741. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51742. */
  51743. constructor(name: string, options: Partial<{
  51744. capacity: number;
  51745. randomTextureSize: number;
  51746. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51747. protected _reset(): void;
  51748. private _createUpdateVAO;
  51749. private _createRenderVAO;
  51750. private _initialize;
  51751. /** @hidden */
  51752. _recreateUpdateEffect(): void;
  51753. /** @hidden */
  51754. _recreateRenderEffect(): void;
  51755. /**
  51756. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51757. * @param preWarm defines if we are in the pre-warmimg phase
  51758. */
  51759. animate(preWarm?: boolean): void;
  51760. private _createFactorGradientTexture;
  51761. private _createSizeGradientTexture;
  51762. private _createAngularSpeedGradientTexture;
  51763. private _createVelocityGradientTexture;
  51764. private _createLimitVelocityGradientTexture;
  51765. private _createDragGradientTexture;
  51766. private _createColorGradientTexture;
  51767. /**
  51768. * Renders the particle system in its current state
  51769. * @param preWarm defines if the system should only update the particles but not render them
  51770. * @returns the current number of particles
  51771. */
  51772. render(preWarm?: boolean): number;
  51773. /**
  51774. * Rebuilds the particle system
  51775. */
  51776. rebuild(): void;
  51777. private _releaseBuffers;
  51778. private _releaseVAOs;
  51779. /**
  51780. * Disposes the particle system and free the associated resources
  51781. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51782. */
  51783. dispose(disposeTexture?: boolean): void;
  51784. /**
  51785. * Clones the particle system.
  51786. * @param name The name of the cloned object
  51787. * @param newEmitter The new emitter to use
  51788. * @returns the cloned particle system
  51789. */
  51790. clone(name: string, newEmitter: any): GPUParticleSystem;
  51791. /**
  51792. * Serializes the particle system to a JSON object.
  51793. * @returns the JSON object
  51794. */
  51795. serialize(): any;
  51796. /**
  51797. * Parses a JSON object to create a GPU particle system.
  51798. * @param parsedParticleSystem The JSON object to parse
  51799. * @param scene The scene to create the particle system in
  51800. * @param rootUrl The root url to use to load external dependencies like texture
  51801. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51802. * @returns the parsed GPU particle system
  51803. */
  51804. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51805. }
  51806. }
  51807. declare module "babylonjs/Particles/particleSystemSet" {
  51808. import { Nullable } from "babylonjs/types";
  51809. import { Color3 } from "babylonjs/Maths/math";
  51810. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51812. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51813. import { Scene, IDisposable } from "babylonjs/scene";
  51814. /**
  51815. * Represents a set of particle systems working together to create a specific effect
  51816. */
  51817. export class ParticleSystemSet implements IDisposable {
  51818. private _emitterCreationOptions;
  51819. private _emitterNode;
  51820. /**
  51821. * Gets the particle system list
  51822. */
  51823. systems: IParticleSystem[];
  51824. /**
  51825. * Gets the emitter node used with this set
  51826. */
  51827. readonly emitterNode: Nullable<TransformNode>;
  51828. /**
  51829. * Creates a new emitter mesh as a sphere
  51830. * @param options defines the options used to create the sphere
  51831. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51832. * @param scene defines the hosting scene
  51833. */
  51834. setEmitterAsSphere(options: {
  51835. diameter: number;
  51836. segments: number;
  51837. color: Color3;
  51838. }, renderingGroupId: number, scene: Scene): void;
  51839. /**
  51840. * Starts all particle systems of the set
  51841. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51842. */
  51843. start(emitter?: AbstractMesh): void;
  51844. /**
  51845. * Release all associated resources
  51846. */
  51847. dispose(): void;
  51848. /**
  51849. * Serialize the set into a JSON compatible object
  51850. * @returns a JSON compatible representation of the set
  51851. */
  51852. serialize(): any;
  51853. /**
  51854. * Parse a new ParticleSystemSet from a serialized source
  51855. * @param data defines a JSON compatible representation of the set
  51856. * @param scene defines the hosting scene
  51857. * @param gpu defines if we want GPU particles or CPU particles
  51858. * @returns a new ParticleSystemSet
  51859. */
  51860. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51861. }
  51862. }
  51863. declare module "babylonjs/Particles/particleHelper" {
  51864. import { Nullable } from "babylonjs/types";
  51865. import { Scene } from "babylonjs/scene";
  51866. import { Vector3 } from "babylonjs/Maths/math";
  51867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51868. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51869. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51870. /**
  51871. * This class is made for on one-liner static method to help creating particle system set.
  51872. */
  51873. export class ParticleHelper {
  51874. /**
  51875. * Gets or sets base Assets URL
  51876. */
  51877. static BaseAssetsUrl: string;
  51878. /**
  51879. * Create a default particle system that you can tweak
  51880. * @param emitter defines the emitter to use
  51881. * @param capacity defines the system capacity (default is 500 particles)
  51882. * @param scene defines the hosting scene
  51883. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51884. * @returns the new Particle system
  51885. */
  51886. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51887. /**
  51888. * This is the main static method (one-liner) of this helper to create different particle systems
  51889. * @param type This string represents the type to the particle system to create
  51890. * @param scene The scene where the particle system should live
  51891. * @param gpu If the system will use gpu
  51892. * @returns the ParticleSystemSet created
  51893. */
  51894. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51895. /**
  51896. * Static function used to export a particle system to a ParticleSystemSet variable.
  51897. * Please note that the emitter shape is not exported
  51898. * @param systems defines the particle systems to export
  51899. * @returns the created particle system set
  51900. */
  51901. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51902. }
  51903. }
  51904. declare module "babylonjs/Particles/particleSystemComponent" {
  51905. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51906. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51907. import "babylonjs/Shaders/particles.vertex";
  51908. module "babylonjs/Engines/engine" {
  51909. interface Engine {
  51910. /**
  51911. * Create an effect to use with particle systems.
  51912. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51913. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51914. * @param uniformsNames defines a list of attribute names
  51915. * @param samplers defines an array of string used to represent textures
  51916. * @param defines defines the string containing the defines to use to compile the shaders
  51917. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51918. * @param onCompiled defines a function to call when the effect creation is successful
  51919. * @param onError defines a function to call when the effect creation has failed
  51920. * @returns the new Effect
  51921. */
  51922. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51923. }
  51924. }
  51925. module "babylonjs/Meshes/mesh" {
  51926. interface Mesh {
  51927. /**
  51928. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51929. * @returns an array of IParticleSystem
  51930. */
  51931. getEmittedParticleSystems(): IParticleSystem[];
  51932. /**
  51933. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51934. * @returns an array of IParticleSystem
  51935. */
  51936. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51937. }
  51938. }
  51939. /**
  51940. * @hidden
  51941. */
  51942. export var _IDoNeedToBeInTheBuild: number;
  51943. }
  51944. declare module "babylonjs/Particles/index" {
  51945. export * from "babylonjs/Particles/baseParticleSystem";
  51946. export * from "babylonjs/Particles/EmitterTypes/index";
  51947. export * from "babylonjs/Particles/gpuParticleSystem";
  51948. export * from "babylonjs/Particles/IParticleSystem";
  51949. export * from "babylonjs/Particles/particle";
  51950. export * from "babylonjs/Particles/particleHelper";
  51951. export * from "babylonjs/Particles/particleSystem";
  51952. export * from "babylonjs/Particles/particleSystemComponent";
  51953. export * from "babylonjs/Particles/particleSystemSet";
  51954. export * from "babylonjs/Particles/solidParticle";
  51955. export * from "babylonjs/Particles/solidParticleSystem";
  51956. export * from "babylonjs/Particles/subEmitter";
  51957. }
  51958. declare module "babylonjs/Physics/physicsEngineComponent" {
  51959. import { Nullable } from "babylonjs/types";
  51960. import { Observable, Observer } from "babylonjs/Misc/observable";
  51961. import { Vector3 } from "babylonjs/Maths/math";
  51962. import { Mesh } from "babylonjs/Meshes/mesh";
  51963. import { ISceneComponent } from "babylonjs/sceneComponent";
  51964. import { Scene } from "babylonjs/scene";
  51965. import { Node } from "babylonjs/node";
  51966. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51967. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51968. module "babylonjs/scene" {
  51969. interface Scene {
  51970. /** @hidden (Backing field) */
  51971. _physicsEngine: Nullable<IPhysicsEngine>;
  51972. /**
  51973. * Gets the current physics engine
  51974. * @returns a IPhysicsEngine or null if none attached
  51975. */
  51976. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51977. /**
  51978. * Enables physics to the current scene
  51979. * @param gravity defines the scene's gravity for the physics engine
  51980. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51981. * @return a boolean indicating if the physics engine was initialized
  51982. */
  51983. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51984. /**
  51985. * Disables and disposes the physics engine associated with the scene
  51986. */
  51987. disablePhysicsEngine(): void;
  51988. /**
  51989. * Gets a boolean indicating if there is an active physics engine
  51990. * @returns a boolean indicating if there is an active physics engine
  51991. */
  51992. isPhysicsEnabled(): boolean;
  51993. /**
  51994. * Deletes a physics compound impostor
  51995. * @param compound defines the compound to delete
  51996. */
  51997. deleteCompoundImpostor(compound: any): void;
  51998. /**
  51999. * An event triggered when physic simulation is about to be run
  52000. */
  52001. onBeforePhysicsObservable: Observable<Scene>;
  52002. /**
  52003. * An event triggered when physic simulation has been done
  52004. */
  52005. onAfterPhysicsObservable: Observable<Scene>;
  52006. }
  52007. }
  52008. module "babylonjs/Meshes/abstractMesh" {
  52009. interface AbstractMesh {
  52010. /** @hidden */
  52011. _physicsImpostor: Nullable<PhysicsImpostor>;
  52012. /**
  52013. * Gets or sets impostor used for physic simulation
  52014. * @see http://doc.babylonjs.com/features/physics_engine
  52015. */
  52016. physicsImpostor: Nullable<PhysicsImpostor>;
  52017. /**
  52018. * Gets the current physics impostor
  52019. * @see http://doc.babylonjs.com/features/physics_engine
  52020. * @returns a physics impostor or null
  52021. */
  52022. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52023. /** Apply a physic impulse to the mesh
  52024. * @param force defines the force to apply
  52025. * @param contactPoint defines where to apply the force
  52026. * @returns the current mesh
  52027. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52028. */
  52029. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52030. /**
  52031. * Creates a physic joint between two meshes
  52032. * @param otherMesh defines the other mesh to use
  52033. * @param pivot1 defines the pivot to use on this mesh
  52034. * @param pivot2 defines the pivot to use on the other mesh
  52035. * @param options defines additional options (can be plugin dependent)
  52036. * @returns the current mesh
  52037. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52038. */
  52039. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52040. /** @hidden */
  52041. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52042. }
  52043. }
  52044. /**
  52045. * Defines the physics engine scene component responsible to manage a physics engine
  52046. */
  52047. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52048. /**
  52049. * The component name helpful to identify the component in the list of scene components.
  52050. */
  52051. readonly name: string;
  52052. /**
  52053. * The scene the component belongs to.
  52054. */
  52055. scene: Scene;
  52056. /**
  52057. * Creates a new instance of the component for the given scene
  52058. * @param scene Defines the scene to register the component in
  52059. */
  52060. constructor(scene: Scene);
  52061. /**
  52062. * Registers the component in a given scene
  52063. */
  52064. register(): void;
  52065. /**
  52066. * Rebuilds the elements related to this component in case of
  52067. * context lost for instance.
  52068. */
  52069. rebuild(): void;
  52070. /**
  52071. * Disposes the component and the associated ressources
  52072. */
  52073. dispose(): void;
  52074. }
  52075. }
  52076. declare module "babylonjs/Physics/physicsHelper" {
  52077. import { Nullable } from "babylonjs/types";
  52078. import { Vector3 } from "babylonjs/Maths/math";
  52079. import { Mesh } from "babylonjs/Meshes/mesh";
  52080. import { Ray } from "babylonjs/Culling/ray";
  52081. import { Scene } from "babylonjs/scene";
  52082. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52083. /**
  52084. * A helper for physics simulations
  52085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52086. */
  52087. export class PhysicsHelper {
  52088. private _scene;
  52089. private _physicsEngine;
  52090. /**
  52091. * Initializes the Physics helper
  52092. * @param scene Babylon.js scene
  52093. */
  52094. constructor(scene: Scene);
  52095. /**
  52096. * Applies a radial explosion impulse
  52097. * @param origin the origin of the explosion
  52098. * @param radius the explosion radius
  52099. * @param strength the explosion strength
  52100. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52101. * @returns A physics radial explosion event, or null
  52102. */
  52103. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52104. /**
  52105. * Applies a radial explosion force
  52106. * @param origin the origin of the explosion
  52107. * @param radius the explosion radius
  52108. * @param strength the explosion strength
  52109. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52110. * @returns A physics radial explosion event, or null
  52111. */
  52112. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52113. /**
  52114. * Creates a gravitational field
  52115. * @param origin the origin of the explosion
  52116. * @param radius the explosion radius
  52117. * @param strength the explosion strength
  52118. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52119. * @returns A physics gravitational field event, or null
  52120. */
  52121. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52122. /**
  52123. * Creates a physics updraft event
  52124. * @param origin the origin of the updraft
  52125. * @param radius the radius of the updraft
  52126. * @param strength the strength of the updraft
  52127. * @param height the height of the updraft
  52128. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52129. * @returns A physics updraft event, or null
  52130. */
  52131. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52132. /**
  52133. * Creates a physics vortex event
  52134. * @param origin the of the vortex
  52135. * @param radius the radius of the vortex
  52136. * @param strength the strength of the vortex
  52137. * @param height the height of the vortex
  52138. * @returns a Physics vortex event, or null
  52139. * A physics vortex event or null
  52140. */
  52141. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52142. }
  52143. /**
  52144. * Represents a physics radial explosion event
  52145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52146. */
  52147. export class PhysicsRadialExplosionEvent {
  52148. private _scene;
  52149. private _sphere;
  52150. private _sphereOptions;
  52151. private _rays;
  52152. private _dataFetched;
  52153. /**
  52154. * Initializes a radial explosioin event
  52155. * @param scene BabylonJS scene
  52156. */
  52157. constructor(scene: Scene);
  52158. /**
  52159. * Returns the data related to the radial explosion event (sphere & rays).
  52160. * @returns The radial explosion event data
  52161. */
  52162. getData(): PhysicsRadialExplosionEventData;
  52163. /**
  52164. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52165. * @param impostor A physics imposter
  52166. * @param origin the origin of the explosion
  52167. * @param radius the explosion radius
  52168. * @param strength the explosion strength
  52169. * @param falloff possible options: Constant & Linear
  52170. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52171. */
  52172. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52173. /**
  52174. * Disposes the sphere.
  52175. * @param force Specifies if the sphere should be disposed by force
  52176. */
  52177. dispose(force?: boolean): void;
  52178. /*** Helpers ***/
  52179. private _prepareSphere;
  52180. private _intersectsWithSphere;
  52181. }
  52182. /**
  52183. * Represents a gravitational field event
  52184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52185. */
  52186. export class PhysicsGravitationalFieldEvent {
  52187. private _physicsHelper;
  52188. private _scene;
  52189. private _origin;
  52190. private _radius;
  52191. private _strength;
  52192. private _falloff;
  52193. private _tickCallback;
  52194. private _sphere;
  52195. private _dataFetched;
  52196. /**
  52197. * Initializes the physics gravitational field event
  52198. * @param physicsHelper A physics helper
  52199. * @param scene BabylonJS scene
  52200. * @param origin The origin position of the gravitational field event
  52201. * @param radius The radius of the gravitational field event
  52202. * @param strength The strength of the gravitational field event
  52203. * @param falloff The falloff for the gravitational field event
  52204. */
  52205. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52206. /**
  52207. * Returns the data related to the gravitational field event (sphere).
  52208. * @returns A gravitational field event
  52209. */
  52210. getData(): PhysicsGravitationalFieldEventData;
  52211. /**
  52212. * Enables the gravitational field.
  52213. */
  52214. enable(): void;
  52215. /**
  52216. * Disables the gravitational field.
  52217. */
  52218. disable(): void;
  52219. /**
  52220. * Disposes the sphere.
  52221. * @param force The force to dispose from the gravitational field event
  52222. */
  52223. dispose(force?: boolean): void;
  52224. private _tick;
  52225. }
  52226. /**
  52227. * Represents a physics updraft event
  52228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52229. */
  52230. export class PhysicsUpdraftEvent {
  52231. private _scene;
  52232. private _origin;
  52233. private _radius;
  52234. private _strength;
  52235. private _height;
  52236. private _updraftMode;
  52237. private _physicsEngine;
  52238. private _originTop;
  52239. private _originDirection;
  52240. private _tickCallback;
  52241. private _cylinder;
  52242. private _cylinderPosition;
  52243. private _dataFetched;
  52244. /**
  52245. * Initializes the physics updraft event
  52246. * @param _scene BabylonJS scene
  52247. * @param _origin The origin position of the updraft
  52248. * @param _radius The radius of the updraft
  52249. * @param _strength The strength of the updraft
  52250. * @param _height The height of the updraft
  52251. * @param _updraftMode The mode of the updraft
  52252. */
  52253. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52254. /**
  52255. * Returns the data related to the updraft event (cylinder).
  52256. * @returns A physics updraft event
  52257. */
  52258. getData(): PhysicsUpdraftEventData;
  52259. /**
  52260. * Enables the updraft.
  52261. */
  52262. enable(): void;
  52263. /**
  52264. * Disables the cortex.
  52265. */
  52266. disable(): void;
  52267. /**
  52268. * Disposes the sphere.
  52269. * @param force Specifies if the updraft should be disposed by force
  52270. */
  52271. dispose(force?: boolean): void;
  52272. private getImpostorForceAndContactPoint;
  52273. private _tick;
  52274. /*** Helpers ***/
  52275. private _prepareCylinder;
  52276. private _intersectsWithCylinder;
  52277. }
  52278. /**
  52279. * Represents a physics vortex event
  52280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52281. */
  52282. export class PhysicsVortexEvent {
  52283. private _scene;
  52284. private _origin;
  52285. private _radius;
  52286. private _strength;
  52287. private _height;
  52288. private _physicsEngine;
  52289. private _originTop;
  52290. private _centripetalForceThreshold;
  52291. private _updraftMultiplier;
  52292. private _tickCallback;
  52293. private _cylinder;
  52294. private _cylinderPosition;
  52295. private _dataFetched;
  52296. /**
  52297. * Initializes the physics vortex event
  52298. * @param _scene The BabylonJS scene
  52299. * @param _origin The origin position of the vortex
  52300. * @param _radius The radius of the vortex
  52301. * @param _strength The strength of the vortex
  52302. * @param _height The height of the vortex
  52303. */
  52304. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52305. /**
  52306. * Returns the data related to the vortex event (cylinder).
  52307. * @returns The physics vortex event data
  52308. */
  52309. getData(): PhysicsVortexEventData;
  52310. /**
  52311. * Enables the vortex.
  52312. */
  52313. enable(): void;
  52314. /**
  52315. * Disables the cortex.
  52316. */
  52317. disable(): void;
  52318. /**
  52319. * Disposes the sphere.
  52320. * @param force
  52321. */
  52322. dispose(force?: boolean): void;
  52323. private getImpostorForceAndContactPoint;
  52324. private _tick;
  52325. /*** Helpers ***/
  52326. private _prepareCylinder;
  52327. private _intersectsWithCylinder;
  52328. }
  52329. /**
  52330. * The strenght of the force in correspondence to the distance of the affected object
  52331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52332. */
  52333. export enum PhysicsRadialImpulseFalloff {
  52334. /** Defines that impulse is constant in strength across it's whole radius */
  52335. Constant = 0,
  52336. /** DEfines that impulse gets weaker if it's further from the origin */
  52337. Linear = 1
  52338. }
  52339. /**
  52340. * The strength of the force in correspondence to the distance of the affected object
  52341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52342. */
  52343. export enum PhysicsUpdraftMode {
  52344. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52345. Center = 0,
  52346. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52347. Perpendicular = 1
  52348. }
  52349. /**
  52350. * Interface for a physics force and contact point
  52351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52352. */
  52353. export interface PhysicsForceAndContactPoint {
  52354. /**
  52355. * The force applied at the contact point
  52356. */
  52357. force: Vector3;
  52358. /**
  52359. * The contact point
  52360. */
  52361. contactPoint: Vector3;
  52362. }
  52363. /**
  52364. * Interface for radial explosion event data
  52365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52366. */
  52367. export interface PhysicsRadialExplosionEventData {
  52368. /**
  52369. * A sphere used for the radial explosion event
  52370. */
  52371. sphere: Mesh;
  52372. /**
  52373. * An array of rays for the radial explosion event
  52374. */
  52375. rays: Array<Ray>;
  52376. }
  52377. /**
  52378. * Interface for gravitational field event data
  52379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52380. */
  52381. export interface PhysicsGravitationalFieldEventData {
  52382. /**
  52383. * A sphere mesh used for the gravitational field event
  52384. */
  52385. sphere: Mesh;
  52386. }
  52387. /**
  52388. * Interface for updraft event data
  52389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52390. */
  52391. export interface PhysicsUpdraftEventData {
  52392. /**
  52393. * A cylinder used for the updraft event
  52394. */
  52395. cylinder: Mesh;
  52396. }
  52397. /**
  52398. * Interface for vortex event data
  52399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52400. */
  52401. export interface PhysicsVortexEventData {
  52402. /**
  52403. * A cylinder used for the vortex event
  52404. */
  52405. cylinder: Mesh;
  52406. }
  52407. }
  52408. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52409. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52410. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52411. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52412. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52413. import { Nullable } from "babylonjs/types";
  52414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52415. /**
  52416. * AmmoJS Physics plugin
  52417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52418. * @see https://github.com/kripken/ammo.js/
  52419. */
  52420. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52421. private _useDeltaForWorldStep;
  52422. /**
  52423. * Reference to the Ammo library
  52424. */
  52425. bjsAMMO: any;
  52426. /**
  52427. * Created ammoJS world which physics bodies are added to
  52428. */
  52429. world: any;
  52430. /**
  52431. * Name of the plugin
  52432. */
  52433. name: string;
  52434. private _timeStep;
  52435. private _fixedTimeStep;
  52436. private _maxSteps;
  52437. private _tmpQuaternion;
  52438. private _tmpAmmoTransform;
  52439. private _tmpAmmoQuaternion;
  52440. private _tmpAmmoConcreteContactResultCallback;
  52441. private _collisionConfiguration;
  52442. private _dispatcher;
  52443. private _overlappingPairCache;
  52444. private _solver;
  52445. private _tmpAmmoVectorA;
  52446. private _tmpAmmoVectorB;
  52447. private _tmpAmmoVectorC;
  52448. private _tmpContactCallbackResult;
  52449. private static readonly DISABLE_COLLISION_FLAG;
  52450. private static readonly KINEMATIC_FLAG;
  52451. private static readonly DISABLE_DEACTIVATION_FLAG;
  52452. /**
  52453. * Initializes the ammoJS plugin
  52454. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52455. * @param ammoInjection can be used to inject your own ammo reference
  52456. */
  52457. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52458. /**
  52459. * Sets the gravity of the physics world (m/(s^2))
  52460. * @param gravity Gravity to set
  52461. */
  52462. setGravity(gravity: Vector3): void;
  52463. /**
  52464. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52465. * @param timeStep timestep to use in seconds
  52466. */
  52467. setTimeStep(timeStep: number): void;
  52468. /**
  52469. * 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)
  52470. * @param fixedTimeStep fixedTimeStep to use in seconds
  52471. */
  52472. setFixedTimeStep(fixedTimeStep: number): void;
  52473. /**
  52474. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52475. * @param maxSteps the maximum number of steps by the physics engine per frame
  52476. */
  52477. setMaxSteps(maxSteps: number): void;
  52478. /**
  52479. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52480. * @returns the current timestep in seconds
  52481. */
  52482. getTimeStep(): number;
  52483. private _isImpostorInContact;
  52484. private _isImpostorPairInContact;
  52485. private _stepSimulation;
  52486. /**
  52487. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52488. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52489. * After the step the babylon meshes are set to the position of the physics imposters
  52490. * @param delta amount of time to step forward
  52491. * @param impostors array of imposters to update before/after the step
  52492. */
  52493. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52494. private _tmpVector;
  52495. private _tmpMatrix;
  52496. /**
  52497. * Applies an implulse on the imposter
  52498. * @param impostor imposter to apply impulse
  52499. * @param force amount of force to be applied to the imposter
  52500. * @param contactPoint the location to apply the impulse on the imposter
  52501. */
  52502. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52503. /**
  52504. * Applies a force on the imposter
  52505. * @param impostor imposter to apply force
  52506. * @param force amount of force to be applied to the imposter
  52507. * @param contactPoint the location to apply the force on the imposter
  52508. */
  52509. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52510. /**
  52511. * Creates a physics body using the plugin
  52512. * @param impostor the imposter to create the physics body on
  52513. */
  52514. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52515. /**
  52516. * Removes the physics body from the imposter and disposes of the body's memory
  52517. * @param impostor imposter to remove the physics body from
  52518. */
  52519. removePhysicsBody(impostor: PhysicsImpostor): void;
  52520. /**
  52521. * Generates a joint
  52522. * @param impostorJoint the imposter joint to create the joint with
  52523. */
  52524. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52525. /**
  52526. * Removes a joint
  52527. * @param impostorJoint the imposter joint to remove the joint from
  52528. */
  52529. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52530. private _addMeshVerts;
  52531. private _createShape;
  52532. /**
  52533. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52534. * @param impostor imposter containing the physics body and babylon object
  52535. */
  52536. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52537. /**
  52538. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52539. * @param impostor imposter containing the physics body and babylon object
  52540. * @param newPosition new position
  52541. * @param newRotation new rotation
  52542. */
  52543. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52544. /**
  52545. * If this plugin is supported
  52546. * @returns true if its supported
  52547. */
  52548. isSupported(): boolean;
  52549. /**
  52550. * Sets the linear velocity of the physics body
  52551. * @param impostor imposter to set the velocity on
  52552. * @param velocity velocity to set
  52553. */
  52554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52555. /**
  52556. * Sets the angular velocity of the physics body
  52557. * @param impostor imposter to set the velocity on
  52558. * @param velocity velocity to set
  52559. */
  52560. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52561. /**
  52562. * gets the linear velocity
  52563. * @param impostor imposter to get linear velocity from
  52564. * @returns linear velocity
  52565. */
  52566. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52567. /**
  52568. * gets the angular velocity
  52569. * @param impostor imposter to get angular velocity from
  52570. * @returns angular velocity
  52571. */
  52572. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52573. /**
  52574. * Sets the mass of physics body
  52575. * @param impostor imposter to set the mass on
  52576. * @param mass mass to set
  52577. */
  52578. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52579. /**
  52580. * Gets the mass of the physics body
  52581. * @param impostor imposter to get the mass from
  52582. * @returns mass
  52583. */
  52584. getBodyMass(impostor: PhysicsImpostor): number;
  52585. /**
  52586. * Gets friction of the impostor
  52587. * @param impostor impostor to get friction from
  52588. * @returns friction value
  52589. */
  52590. getBodyFriction(impostor: PhysicsImpostor): number;
  52591. /**
  52592. * Sets friction of the impostor
  52593. * @param impostor impostor to set friction on
  52594. * @param friction friction value
  52595. */
  52596. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52597. /**
  52598. * Gets restitution of the impostor
  52599. * @param impostor impostor to get restitution from
  52600. * @returns restitution value
  52601. */
  52602. getBodyRestitution(impostor: PhysicsImpostor): number;
  52603. /**
  52604. * Sets resitution of the impostor
  52605. * @param impostor impostor to set resitution on
  52606. * @param restitution resitution value
  52607. */
  52608. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52609. /**
  52610. * Sleeps the physics body and stops it from being active
  52611. * @param impostor impostor to sleep
  52612. */
  52613. sleepBody(impostor: PhysicsImpostor): void;
  52614. /**
  52615. * Activates the physics body
  52616. * @param impostor impostor to activate
  52617. */
  52618. wakeUpBody(impostor: PhysicsImpostor): void;
  52619. /**
  52620. * Updates the distance parameters of the joint
  52621. * @param joint joint to update
  52622. * @param maxDistance maximum distance of the joint
  52623. * @param minDistance minimum distance of the joint
  52624. */
  52625. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52626. /**
  52627. * Sets a motor on the joint
  52628. * @param joint joint to set motor on
  52629. * @param speed speed of the motor
  52630. * @param maxForce maximum force of the motor
  52631. * @param motorIndex index of the motor
  52632. */
  52633. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52634. /**
  52635. * Sets the motors limit
  52636. * @param joint joint to set limit on
  52637. * @param upperLimit upper limit
  52638. * @param lowerLimit lower limit
  52639. */
  52640. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52641. /**
  52642. * Syncs the position and rotation of a mesh with the impostor
  52643. * @param mesh mesh to sync
  52644. * @param impostor impostor to update the mesh with
  52645. */
  52646. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52647. /**
  52648. * Gets the radius of the impostor
  52649. * @param impostor impostor to get radius from
  52650. * @returns the radius
  52651. */
  52652. getRadius(impostor: PhysicsImpostor): number;
  52653. /**
  52654. * Gets the box size of the impostor
  52655. * @param impostor impostor to get box size from
  52656. * @param result the resulting box size
  52657. */
  52658. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52659. /**
  52660. * Disposes of the impostor
  52661. */
  52662. dispose(): void;
  52663. }
  52664. }
  52665. declare module "babylonjs/Physics/Plugins/index" {
  52666. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52667. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52668. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52669. }
  52670. declare module "babylonjs/Physics/index" {
  52671. export * from "babylonjs/Physics/IPhysicsEngine";
  52672. export * from "babylonjs/Physics/physicsEngine";
  52673. export * from "babylonjs/Physics/physicsEngineComponent";
  52674. export * from "babylonjs/Physics/physicsHelper";
  52675. export * from "babylonjs/Physics/physicsImpostor";
  52676. export * from "babylonjs/Physics/physicsJoint";
  52677. export * from "babylonjs/Physics/Plugins/index";
  52678. }
  52679. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52680. /** @hidden */
  52681. export var blackAndWhitePixelShader: {
  52682. name: string;
  52683. shader: string;
  52684. };
  52685. }
  52686. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52688. import { Camera } from "babylonjs/Cameras/camera";
  52689. import { Engine } from "babylonjs/Engines/engine";
  52690. import "babylonjs/Shaders/blackAndWhite.fragment";
  52691. /**
  52692. * Post process used to render in black and white
  52693. */
  52694. export class BlackAndWhitePostProcess extends PostProcess {
  52695. /**
  52696. * Linear about to convert he result to black and white (default: 1)
  52697. */
  52698. degree: number;
  52699. /**
  52700. * Creates a black and white post process
  52701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52702. * @param name The name of the effect.
  52703. * @param options The required width/height ratio to downsize to before computing the render pass.
  52704. * @param camera The camera to apply the render pass to.
  52705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52706. * @param engine The engine which the post process will be applied. (default: current engine)
  52707. * @param reusable If the post process can be reused on the same frame. (default: false)
  52708. */
  52709. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52710. }
  52711. }
  52712. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52713. import { Nullable } from "babylonjs/types";
  52714. import { Camera } from "babylonjs/Cameras/camera";
  52715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52716. import { Engine } from "babylonjs/Engines/engine";
  52717. /**
  52718. * This represents a set of one or more post processes in Babylon.
  52719. * A post process can be used to apply a shader to a texture after it is rendered.
  52720. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52721. */
  52722. export class PostProcessRenderEffect {
  52723. private _postProcesses;
  52724. private _getPostProcesses;
  52725. private _singleInstance;
  52726. private _cameras;
  52727. private _indicesForCamera;
  52728. /**
  52729. * Name of the effect
  52730. * @hidden
  52731. */
  52732. _name: string;
  52733. /**
  52734. * Instantiates a post process render effect.
  52735. * A post process can be used to apply a shader to a texture after it is rendered.
  52736. * @param engine The engine the effect is tied to
  52737. * @param name The name of the effect
  52738. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52739. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52740. */
  52741. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52742. /**
  52743. * Checks if all the post processes in the effect are supported.
  52744. */
  52745. readonly isSupported: boolean;
  52746. /**
  52747. * Updates the current state of the effect
  52748. * @hidden
  52749. */
  52750. _update(): void;
  52751. /**
  52752. * Attaches the effect on cameras
  52753. * @param cameras The camera to attach to.
  52754. * @hidden
  52755. */
  52756. _attachCameras(cameras: Camera): void;
  52757. /**
  52758. * Attaches the effect on cameras
  52759. * @param cameras The camera to attach to.
  52760. * @hidden
  52761. */
  52762. _attachCameras(cameras: Camera[]): void;
  52763. /**
  52764. * Detatches the effect on cameras
  52765. * @param cameras The camera to detatch from.
  52766. * @hidden
  52767. */
  52768. _detachCameras(cameras: Camera): void;
  52769. /**
  52770. * Detatches the effect on cameras
  52771. * @param cameras The camera to detatch from.
  52772. * @hidden
  52773. */
  52774. _detachCameras(cameras: Camera[]): void;
  52775. /**
  52776. * Enables the effect on given cameras
  52777. * @param cameras The camera to enable.
  52778. * @hidden
  52779. */
  52780. _enable(cameras: Camera): void;
  52781. /**
  52782. * Enables the effect on given cameras
  52783. * @param cameras The camera to enable.
  52784. * @hidden
  52785. */
  52786. _enable(cameras: Nullable<Camera[]>): void;
  52787. /**
  52788. * Disables the effect on the given cameras
  52789. * @param cameras The camera to disable.
  52790. * @hidden
  52791. */
  52792. _disable(cameras: Camera): void;
  52793. /**
  52794. * Disables the effect on the given cameras
  52795. * @param cameras The camera to disable.
  52796. * @hidden
  52797. */
  52798. _disable(cameras: Nullable<Camera[]>): void;
  52799. /**
  52800. * Gets a list of the post processes contained in the effect.
  52801. * @param camera The camera to get the post processes on.
  52802. * @returns The list of the post processes in the effect.
  52803. */
  52804. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52805. }
  52806. }
  52807. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52808. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52809. /** @hidden */
  52810. export var extractHighlightsPixelShader: {
  52811. name: string;
  52812. shader: string;
  52813. };
  52814. }
  52815. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52816. import { Nullable } from "babylonjs/types";
  52817. import { Camera } from "babylonjs/Cameras/camera";
  52818. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52819. import { Engine } from "babylonjs/Engines/engine";
  52820. import "babylonjs/Shaders/extractHighlights.fragment";
  52821. /**
  52822. * 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.
  52823. */
  52824. export class ExtractHighlightsPostProcess extends PostProcess {
  52825. /**
  52826. * The luminance threshold, pixels below this value will be set to black.
  52827. */
  52828. threshold: number;
  52829. /** @hidden */
  52830. _exposure: number;
  52831. /**
  52832. * Post process which has the input texture to be used when performing highlight extraction
  52833. * @hidden
  52834. */
  52835. _inputPostProcess: Nullable<PostProcess>;
  52836. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52837. }
  52838. }
  52839. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52840. /** @hidden */
  52841. export var bloomMergePixelShader: {
  52842. name: string;
  52843. shader: string;
  52844. };
  52845. }
  52846. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52847. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52848. import { Nullable } from "babylonjs/types";
  52849. import { Engine } from "babylonjs/Engines/engine";
  52850. import { Camera } from "babylonjs/Cameras/camera";
  52851. import "babylonjs/Shaders/bloomMerge.fragment";
  52852. /**
  52853. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52854. */
  52855. export class BloomMergePostProcess extends PostProcess {
  52856. /** Weight of the bloom to be added to the original input. */
  52857. weight: number;
  52858. /**
  52859. * Creates a new instance of @see BloomMergePostProcess
  52860. * @param name The name of the effect.
  52861. * @param originalFromInput Post process which's input will be used for the merge.
  52862. * @param blurred Blurred highlights post process which's output will be used.
  52863. * @param weight Weight of the bloom to be added to the original input.
  52864. * @param options The required width/height ratio to downsize to before computing the render pass.
  52865. * @param camera The camera to apply the render pass to.
  52866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52867. * @param engine The engine which the post process will be applied. (default: current engine)
  52868. * @param reusable If the post process can be reused on the same frame. (default: false)
  52869. * @param textureType Type of textures used when performing the post process. (default: 0)
  52870. * @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)
  52871. */
  52872. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52873. /** Weight of the bloom to be added to the original input. */
  52874. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52875. }
  52876. }
  52877. declare module "babylonjs/PostProcesses/bloomEffect" {
  52878. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52880. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52881. import { Camera } from "babylonjs/Cameras/camera";
  52882. import { Scene } from "babylonjs/scene";
  52883. /**
  52884. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52885. */
  52886. export class BloomEffect extends PostProcessRenderEffect {
  52887. private bloomScale;
  52888. /**
  52889. * @hidden Internal
  52890. */
  52891. _effects: Array<PostProcess>;
  52892. /**
  52893. * @hidden Internal
  52894. */
  52895. _downscale: ExtractHighlightsPostProcess;
  52896. private _blurX;
  52897. private _blurY;
  52898. private _merge;
  52899. /**
  52900. * The luminance threshold to find bright areas of the image to bloom.
  52901. */
  52902. threshold: number;
  52903. /**
  52904. * The strength of the bloom.
  52905. */
  52906. weight: number;
  52907. /**
  52908. * Specifies the size of the bloom blur kernel, relative to the final output size
  52909. */
  52910. kernel: number;
  52911. /**
  52912. * Creates a new instance of @see BloomEffect
  52913. * @param scene The scene the effect belongs to.
  52914. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52915. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52916. * @param bloomWeight The the strength of bloom.
  52917. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52918. * @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)
  52919. */
  52920. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52921. /**
  52922. * Disposes each of the internal effects for a given camera.
  52923. * @param camera The camera to dispose the effect on.
  52924. */
  52925. disposeEffects(camera: Camera): void;
  52926. /**
  52927. * @hidden Internal
  52928. */
  52929. _updateEffects(): void;
  52930. /**
  52931. * Internal
  52932. * @returns if all the contained post processes are ready.
  52933. * @hidden
  52934. */
  52935. _isReady(): boolean;
  52936. }
  52937. }
  52938. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52939. /** @hidden */
  52940. export var chromaticAberrationPixelShader: {
  52941. name: string;
  52942. shader: string;
  52943. };
  52944. }
  52945. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52946. import { Vector2 } from "babylonjs/Maths/math";
  52947. import { Nullable } from "babylonjs/types";
  52948. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52949. import { Camera } from "babylonjs/Cameras/camera";
  52950. import { Engine } from "babylonjs/Engines/engine";
  52951. import "babylonjs/Shaders/chromaticAberration.fragment";
  52952. /**
  52953. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52954. */
  52955. export class ChromaticAberrationPostProcess extends PostProcess {
  52956. /**
  52957. * The amount of seperation of rgb channels (default: 30)
  52958. */
  52959. aberrationAmount: number;
  52960. /**
  52961. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52962. */
  52963. radialIntensity: number;
  52964. /**
  52965. * 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))
  52966. */
  52967. direction: Vector2;
  52968. /**
  52969. * 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))
  52970. */
  52971. centerPosition: Vector2;
  52972. /**
  52973. * Creates a new instance ChromaticAberrationPostProcess
  52974. * @param name The name of the effect.
  52975. * @param screenWidth The width of the screen to apply the effect on.
  52976. * @param screenHeight The height of the screen to apply the effect on.
  52977. * @param options The required width/height ratio to downsize to before computing the render pass.
  52978. * @param camera The camera to apply the render pass to.
  52979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52980. * @param engine The engine which the post process will be applied. (default: current engine)
  52981. * @param reusable If the post process can be reused on the same frame. (default: false)
  52982. * @param textureType Type of textures used when performing the post process. (default: 0)
  52983. * @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)
  52984. */
  52985. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52986. }
  52987. }
  52988. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52989. /** @hidden */
  52990. export var circleOfConfusionPixelShader: {
  52991. name: string;
  52992. shader: string;
  52993. };
  52994. }
  52995. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52996. import { Nullable } from "babylonjs/types";
  52997. import { Engine } from "babylonjs/Engines/engine";
  52998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53000. import { Camera } from "babylonjs/Cameras/camera";
  53001. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53002. /**
  53003. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53004. */
  53005. export class CircleOfConfusionPostProcess extends PostProcess {
  53006. /**
  53007. * 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.
  53008. */
  53009. lensSize: number;
  53010. /**
  53011. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53012. */
  53013. fStop: number;
  53014. /**
  53015. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53016. */
  53017. focusDistance: number;
  53018. /**
  53019. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53020. */
  53021. focalLength: number;
  53022. private _depthTexture;
  53023. /**
  53024. * Creates a new instance CircleOfConfusionPostProcess
  53025. * @param name The name of the effect.
  53026. * @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.
  53027. * @param options The required width/height ratio to downsize to before computing the render pass.
  53028. * @param camera The camera to apply the render pass to.
  53029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53030. * @param engine The engine which the post process will be applied. (default: current engine)
  53031. * @param reusable If the post process can be reused on the same frame. (default: false)
  53032. * @param textureType Type of textures used when performing the post process. (default: 0)
  53033. * @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)
  53034. */
  53035. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53036. /**
  53037. * 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.
  53038. */
  53039. depthTexture: RenderTargetTexture;
  53040. }
  53041. }
  53042. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53043. /** @hidden */
  53044. export var colorCorrectionPixelShader: {
  53045. name: string;
  53046. shader: string;
  53047. };
  53048. }
  53049. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53051. import { Engine } from "babylonjs/Engines/engine";
  53052. import { Camera } from "babylonjs/Cameras/camera";
  53053. import "babylonjs/Shaders/colorCorrection.fragment";
  53054. /**
  53055. *
  53056. * This post-process allows the modification of rendered colors by using
  53057. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53058. *
  53059. * The object needs to be provided an url to a texture containing the color
  53060. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53061. * Use an image editing software to tweak the LUT to match your needs.
  53062. *
  53063. * For an example of a color LUT, see here:
  53064. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53065. * For explanations on color grading, see here:
  53066. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53067. *
  53068. */
  53069. export class ColorCorrectionPostProcess extends PostProcess {
  53070. private _colorTableTexture;
  53071. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53072. }
  53073. }
  53074. declare module "babylonjs/Shaders/convolution.fragment" {
  53075. /** @hidden */
  53076. export var convolutionPixelShader: {
  53077. name: string;
  53078. shader: string;
  53079. };
  53080. }
  53081. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53082. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53083. import { Nullable } from "babylonjs/types";
  53084. import { Camera } from "babylonjs/Cameras/camera";
  53085. import { Engine } from "babylonjs/Engines/engine";
  53086. import "babylonjs/Shaders/convolution.fragment";
  53087. /**
  53088. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53089. * input texture to perform effects such as edge detection or sharpening
  53090. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53091. */
  53092. export class ConvolutionPostProcess extends PostProcess {
  53093. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53094. kernel: number[];
  53095. /**
  53096. * Creates a new instance ConvolutionPostProcess
  53097. * @param name The name of the effect.
  53098. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53099. * @param options The required width/height ratio to downsize to before computing the render pass.
  53100. * @param camera The camera to apply the render pass to.
  53101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53102. * @param engine The engine which the post process will be applied. (default: current engine)
  53103. * @param reusable If the post process can be reused on the same frame. (default: false)
  53104. * @param textureType Type of textures used when performing the post process. (default: 0)
  53105. */
  53106. constructor(name: string,
  53107. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53108. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53109. /**
  53110. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53111. */
  53112. static EdgeDetect0Kernel: number[];
  53113. /**
  53114. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53115. */
  53116. static EdgeDetect1Kernel: number[];
  53117. /**
  53118. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53119. */
  53120. static EdgeDetect2Kernel: number[];
  53121. /**
  53122. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53123. */
  53124. static SharpenKernel: number[];
  53125. /**
  53126. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53127. */
  53128. static EmbossKernel: number[];
  53129. /**
  53130. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53131. */
  53132. static GaussianKernel: number[];
  53133. }
  53134. }
  53135. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53136. import { Nullable } from "babylonjs/types";
  53137. import { Vector2 } from "babylonjs/Maths/math";
  53138. import { Camera } from "babylonjs/Cameras/camera";
  53139. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53140. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53141. import { Engine } from "babylonjs/Engines/engine";
  53142. import { Scene } from "babylonjs/scene";
  53143. /**
  53144. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53145. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53146. * based on samples that have a large difference in distance than the center pixel.
  53147. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53148. */
  53149. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53150. direction: Vector2;
  53151. /**
  53152. * Creates a new instance CircleOfConfusionPostProcess
  53153. * @param name The name of the effect.
  53154. * @param scene The scene the effect belongs to.
  53155. * @param direction The direction the blur should be applied.
  53156. * @param kernel The size of the kernel used to blur.
  53157. * @param options The required width/height ratio to downsize to before computing the render pass.
  53158. * @param camera The camera to apply the render pass to.
  53159. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53160. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53162. * @param engine The engine which the post process will be applied. (default: current engine)
  53163. * @param reusable If the post process can be reused on the same frame. (default: false)
  53164. * @param textureType Type of textures used when performing the post process. (default: 0)
  53165. * @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)
  53166. */
  53167. 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);
  53168. }
  53169. }
  53170. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53171. /** @hidden */
  53172. export var depthOfFieldMergePixelShader: {
  53173. name: string;
  53174. shader: string;
  53175. };
  53176. }
  53177. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53178. import { Nullable } from "babylonjs/types";
  53179. import { Camera } from "babylonjs/Cameras/camera";
  53180. import { Effect } from "babylonjs/Materials/effect";
  53181. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53182. import { Engine } from "babylonjs/Engines/engine";
  53183. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53184. /**
  53185. * Options to be set when merging outputs from the default pipeline.
  53186. */
  53187. export class DepthOfFieldMergePostProcessOptions {
  53188. /**
  53189. * The original image to merge on top of
  53190. */
  53191. originalFromInput: PostProcess;
  53192. /**
  53193. * Parameters to perform the merge of the depth of field effect
  53194. */
  53195. depthOfField?: {
  53196. circleOfConfusion: PostProcess;
  53197. blurSteps: Array<PostProcess>;
  53198. };
  53199. /**
  53200. * Parameters to perform the merge of bloom effect
  53201. */
  53202. bloom?: {
  53203. blurred: PostProcess;
  53204. weight: number;
  53205. };
  53206. }
  53207. /**
  53208. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53209. */
  53210. export class DepthOfFieldMergePostProcess extends PostProcess {
  53211. private blurSteps;
  53212. /**
  53213. * Creates a new instance of DepthOfFieldMergePostProcess
  53214. * @param name The name of the effect.
  53215. * @param originalFromInput Post process which's input will be used for the merge.
  53216. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53217. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53218. * @param options The required width/height ratio to downsize to before computing the render pass.
  53219. * @param camera The camera to apply the render pass to.
  53220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53221. * @param engine The engine which the post process will be applied. (default: current engine)
  53222. * @param reusable If the post process can be reused on the same frame. (default: false)
  53223. * @param textureType Type of textures used when performing the post process. (default: 0)
  53224. * @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)
  53225. */
  53226. 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);
  53227. /**
  53228. * Updates the effect with the current post process compile time values and recompiles the shader.
  53229. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53230. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53231. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53232. * @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
  53233. * @param onCompiled Called when the shader has been compiled.
  53234. * @param onError Called if there is an error when compiling a shader.
  53235. */
  53236. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53237. }
  53238. }
  53239. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53240. import { Nullable } from "babylonjs/types";
  53241. import { Camera } from "babylonjs/Cameras/camera";
  53242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53243. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53244. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53245. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53246. import { Scene } from "babylonjs/scene";
  53247. /**
  53248. * Specifies the level of max blur that should be applied when using the depth of field effect
  53249. */
  53250. export enum DepthOfFieldEffectBlurLevel {
  53251. /**
  53252. * Subtle blur
  53253. */
  53254. Low = 0,
  53255. /**
  53256. * Medium blur
  53257. */
  53258. Medium = 1,
  53259. /**
  53260. * Large blur
  53261. */
  53262. High = 2
  53263. }
  53264. /**
  53265. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53266. */
  53267. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53268. private _circleOfConfusion;
  53269. /**
  53270. * @hidden Internal, blurs from high to low
  53271. */
  53272. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53273. private _depthOfFieldBlurY;
  53274. private _dofMerge;
  53275. /**
  53276. * @hidden Internal post processes in depth of field effect
  53277. */
  53278. _effects: Array<PostProcess>;
  53279. /**
  53280. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53281. */
  53282. focalLength: number;
  53283. /**
  53284. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53285. */
  53286. fStop: number;
  53287. /**
  53288. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53289. */
  53290. focusDistance: number;
  53291. /**
  53292. * 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.
  53293. */
  53294. lensSize: number;
  53295. /**
  53296. * Creates a new instance DepthOfFieldEffect
  53297. * @param scene The scene the effect belongs to.
  53298. * @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.
  53299. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53300. * @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)
  53301. */
  53302. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53303. /**
  53304. * 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.
  53305. */
  53306. depthTexture: RenderTargetTexture;
  53307. /**
  53308. * Disposes each of the internal effects for a given camera.
  53309. * @param camera The camera to dispose the effect on.
  53310. */
  53311. disposeEffects(camera: Camera): void;
  53312. /**
  53313. * @hidden Internal
  53314. */
  53315. _updateEffects(): void;
  53316. /**
  53317. * Internal
  53318. * @returns if all the contained post processes are ready.
  53319. * @hidden
  53320. */
  53321. _isReady(): boolean;
  53322. }
  53323. }
  53324. declare module "babylonjs/Shaders/displayPass.fragment" {
  53325. /** @hidden */
  53326. export var displayPassPixelShader: {
  53327. name: string;
  53328. shader: string;
  53329. };
  53330. }
  53331. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53332. import { Nullable } from "babylonjs/types";
  53333. import { Camera } from "babylonjs/Cameras/camera";
  53334. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53335. import { Engine } from "babylonjs/Engines/engine";
  53336. import "babylonjs/Shaders/displayPass.fragment";
  53337. /**
  53338. * DisplayPassPostProcess which produces an output the same as it's input
  53339. */
  53340. export class DisplayPassPostProcess extends PostProcess {
  53341. /**
  53342. * Creates the DisplayPassPostProcess
  53343. * @param name The name of the effect.
  53344. * @param options The required width/height ratio to downsize to before computing the render pass.
  53345. * @param camera The camera to apply the render pass to.
  53346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53347. * @param engine The engine which the post process will be applied. (default: current engine)
  53348. * @param reusable If the post process can be reused on the same frame. (default: false)
  53349. */
  53350. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53351. }
  53352. }
  53353. declare module "babylonjs/Shaders/filter.fragment" {
  53354. /** @hidden */
  53355. export var filterPixelShader: {
  53356. name: string;
  53357. shader: string;
  53358. };
  53359. }
  53360. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53361. import { Nullable } from "babylonjs/types";
  53362. import { Matrix } from "babylonjs/Maths/math";
  53363. import { Camera } from "babylonjs/Cameras/camera";
  53364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53365. import { Engine } from "babylonjs/Engines/engine";
  53366. import "babylonjs/Shaders/filter.fragment";
  53367. /**
  53368. * Applies a kernel filter to the image
  53369. */
  53370. export class FilterPostProcess extends PostProcess {
  53371. /** The matrix to be applied to the image */
  53372. kernelMatrix: Matrix;
  53373. /**
  53374. *
  53375. * @param name The name of the effect.
  53376. * @param kernelMatrix The matrix to be applied to the image
  53377. * @param options The required width/height ratio to downsize to before computing the render pass.
  53378. * @param camera The camera to apply the render pass to.
  53379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53380. * @param engine The engine which the post process will be applied. (default: current engine)
  53381. * @param reusable If the post process can be reused on the same frame. (default: false)
  53382. */
  53383. constructor(name: string,
  53384. /** The matrix to be applied to the image */
  53385. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53386. }
  53387. }
  53388. declare module "babylonjs/Shaders/fxaa.fragment" {
  53389. /** @hidden */
  53390. export var fxaaPixelShader: {
  53391. name: string;
  53392. shader: string;
  53393. };
  53394. }
  53395. declare module "babylonjs/Shaders/fxaa.vertex" {
  53396. /** @hidden */
  53397. export var fxaaVertexShader: {
  53398. name: string;
  53399. shader: string;
  53400. };
  53401. }
  53402. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53403. import { Nullable } from "babylonjs/types";
  53404. import { Camera } from "babylonjs/Cameras/camera";
  53405. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53406. import { Engine } from "babylonjs/Engines/engine";
  53407. import "babylonjs/Shaders/fxaa.fragment";
  53408. import "babylonjs/Shaders/fxaa.vertex";
  53409. /**
  53410. * Fxaa post process
  53411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53412. */
  53413. export class FxaaPostProcess extends PostProcess {
  53414. /** @hidden */
  53415. texelWidth: number;
  53416. /** @hidden */
  53417. texelHeight: number;
  53418. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53419. private _getDefines;
  53420. }
  53421. }
  53422. declare module "babylonjs/Shaders/grain.fragment" {
  53423. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53424. /** @hidden */
  53425. export var grainPixelShader: {
  53426. name: string;
  53427. shader: string;
  53428. };
  53429. }
  53430. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53431. import { Nullable } from "babylonjs/types";
  53432. import { Camera } from "babylonjs/Cameras/camera";
  53433. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53434. import { Engine } from "babylonjs/Engines/engine";
  53435. import "babylonjs/Shaders/grain.fragment";
  53436. /**
  53437. * The GrainPostProcess adds noise to the image at mid luminance levels
  53438. */
  53439. export class GrainPostProcess extends PostProcess {
  53440. /**
  53441. * The intensity of the grain added (default: 30)
  53442. */
  53443. intensity: number;
  53444. /**
  53445. * If the grain should be randomized on every frame
  53446. */
  53447. animated: boolean;
  53448. /**
  53449. * Creates a new instance of @see GrainPostProcess
  53450. * @param name The name of the effect.
  53451. * @param options The required width/height ratio to downsize to before computing the render pass.
  53452. * @param camera The camera to apply the render pass to.
  53453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53454. * @param engine The engine which the post process will be applied. (default: current engine)
  53455. * @param reusable If the post process can be reused on the same frame. (default: false)
  53456. * @param textureType Type of textures used when performing the post process. (default: 0)
  53457. * @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)
  53458. */
  53459. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53460. }
  53461. }
  53462. declare module "babylonjs/Shaders/highlights.fragment" {
  53463. /** @hidden */
  53464. export var highlightsPixelShader: {
  53465. name: string;
  53466. shader: string;
  53467. };
  53468. }
  53469. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53470. import { Nullable } from "babylonjs/types";
  53471. import { Camera } from "babylonjs/Cameras/camera";
  53472. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53473. import { Engine } from "babylonjs/Engines/engine";
  53474. import "babylonjs/Shaders/highlights.fragment";
  53475. /**
  53476. * Extracts highlights from the image
  53477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53478. */
  53479. export class HighlightsPostProcess extends PostProcess {
  53480. /**
  53481. * Extracts highlights from the image
  53482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53483. * @param name The name of the effect.
  53484. * @param options The required width/height ratio to downsize to before computing the render pass.
  53485. * @param camera The camera to apply the render pass to.
  53486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53487. * @param engine The engine which the post process will be applied. (default: current engine)
  53488. * @param reusable If the post process can be reused on the same frame. (default: false)
  53489. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53490. */
  53491. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53492. }
  53493. }
  53494. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53495. /** @hidden */
  53496. export var mrtFragmentDeclaration: {
  53497. name: string;
  53498. shader: string;
  53499. };
  53500. }
  53501. declare module "babylonjs/Shaders/geometry.fragment" {
  53502. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53503. /** @hidden */
  53504. export var geometryPixelShader: {
  53505. name: string;
  53506. shader: string;
  53507. };
  53508. }
  53509. declare module "babylonjs/Shaders/geometry.vertex" {
  53510. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53511. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53512. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53513. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53514. /** @hidden */
  53515. export var geometryVertexShader: {
  53516. name: string;
  53517. shader: string;
  53518. };
  53519. }
  53520. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53521. import { Matrix } from "babylonjs/Maths/math";
  53522. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53523. import { Mesh } from "babylonjs/Meshes/mesh";
  53524. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53525. import { Effect } from "babylonjs/Materials/effect";
  53526. import { Scene } from "babylonjs/scene";
  53527. import "babylonjs/Shaders/geometry.fragment";
  53528. import "babylonjs/Shaders/geometry.vertex";
  53529. /**
  53530. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53531. */
  53532. export class GeometryBufferRenderer {
  53533. /**
  53534. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53535. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53536. */
  53537. static readonly POSITION_TEXTURE_TYPE: number;
  53538. /**
  53539. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53540. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53541. */
  53542. static readonly VELOCITY_TEXTURE_TYPE: number;
  53543. /**
  53544. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53545. * in order to compute objects velocities when enableVelocity is set to "true"
  53546. * @hidden
  53547. */
  53548. _previousTransformationMatrices: {
  53549. [index: number]: Matrix;
  53550. };
  53551. private _scene;
  53552. private _multiRenderTarget;
  53553. private _ratio;
  53554. private _enablePosition;
  53555. private _enableVelocity;
  53556. private _positionIndex;
  53557. private _velocityIndex;
  53558. protected _effect: Effect;
  53559. protected _cachedDefines: string;
  53560. /**
  53561. * Set the render list (meshes to be rendered) used in the G buffer.
  53562. */
  53563. renderList: Mesh[];
  53564. /**
  53565. * Gets wether or not G buffer are supported by the running hardware.
  53566. * This requires draw buffer supports
  53567. */
  53568. readonly isSupported: boolean;
  53569. /**
  53570. * Returns the index of the given texture type in the G-Buffer textures array
  53571. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53572. * @returns the index of the given texture type in the G-Buffer textures array
  53573. */
  53574. getTextureIndex(textureType: number): number;
  53575. /**
  53576. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53577. */
  53578. /**
  53579. * Sets whether or not objects positions are enabled for the G buffer.
  53580. */
  53581. enablePosition: boolean;
  53582. /**
  53583. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53584. */
  53585. /**
  53586. * Sets wether or not objects velocities are enabled for the G buffer.
  53587. */
  53588. enableVelocity: boolean;
  53589. /**
  53590. * Gets the scene associated with the buffer.
  53591. */
  53592. readonly scene: Scene;
  53593. /**
  53594. * Gets the ratio used by the buffer during its creation.
  53595. * How big is the buffer related to the main canvas.
  53596. */
  53597. readonly ratio: number;
  53598. /** @hidden */
  53599. static _SceneComponentInitialization: (scene: Scene) => void;
  53600. /**
  53601. * Creates a new G Buffer for the scene
  53602. * @param scene The scene the buffer belongs to
  53603. * @param ratio How big is the buffer related to the main canvas.
  53604. */
  53605. constructor(scene: Scene, ratio?: number);
  53606. /**
  53607. * Checks wether everything is ready to render a submesh to the G buffer.
  53608. * @param subMesh the submesh to check readiness for
  53609. * @param useInstances is the mesh drawn using instance or not
  53610. * @returns true if ready otherwise false
  53611. */
  53612. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53613. /**
  53614. * Gets the current underlying G Buffer.
  53615. * @returns the buffer
  53616. */
  53617. getGBuffer(): MultiRenderTarget;
  53618. /**
  53619. * Gets the number of samples used to render the buffer (anti aliasing).
  53620. */
  53621. /**
  53622. * Sets the number of samples used to render the buffer (anti aliasing).
  53623. */
  53624. samples: number;
  53625. /**
  53626. * Disposes the renderer and frees up associated resources.
  53627. */
  53628. dispose(): void;
  53629. protected _createRenderTargets(): void;
  53630. }
  53631. }
  53632. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53633. import { Nullable } from "babylonjs/types";
  53634. import { Scene } from "babylonjs/scene";
  53635. import { ISceneComponent } from "babylonjs/sceneComponent";
  53636. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53637. module "babylonjs/scene" {
  53638. interface Scene {
  53639. /** @hidden (Backing field) */
  53640. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53641. /**
  53642. * Gets or Sets the current geometry buffer associated to the scene.
  53643. */
  53644. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53645. /**
  53646. * Enables a GeometryBufferRender and associates it with the scene
  53647. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53648. * @returns the GeometryBufferRenderer
  53649. */
  53650. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53651. /**
  53652. * Disables the GeometryBufferRender associated with the scene
  53653. */
  53654. disableGeometryBufferRenderer(): void;
  53655. }
  53656. }
  53657. /**
  53658. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53659. * in several rendering techniques.
  53660. */
  53661. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53662. /**
  53663. * The component name helpful to identify the component in the list of scene components.
  53664. */
  53665. readonly name: string;
  53666. /**
  53667. * The scene the component belongs to.
  53668. */
  53669. scene: Scene;
  53670. /**
  53671. * Creates a new instance of the component for the given scene
  53672. * @param scene Defines the scene to register the component in
  53673. */
  53674. constructor(scene: Scene);
  53675. /**
  53676. * Registers the component in a given scene
  53677. */
  53678. register(): void;
  53679. /**
  53680. * Rebuilds the elements related to this component in case of
  53681. * context lost for instance.
  53682. */
  53683. rebuild(): void;
  53684. /**
  53685. * Disposes the component and the associated ressources
  53686. */
  53687. dispose(): void;
  53688. private _gatherRenderTargets;
  53689. }
  53690. }
  53691. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53692. /** @hidden */
  53693. export var motionBlurPixelShader: {
  53694. name: string;
  53695. shader: string;
  53696. };
  53697. }
  53698. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53699. import { Nullable } from "babylonjs/types";
  53700. import { Camera } from "babylonjs/Cameras/camera";
  53701. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53702. import { Scene } from "babylonjs/scene";
  53703. import "babylonjs/Animations/animatable";
  53704. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53705. import "babylonjs/Shaders/motionBlur.fragment";
  53706. import { Engine } from "babylonjs/Engines/engine";
  53707. /**
  53708. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53709. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53710. * As an example, all you have to do is to create the post-process:
  53711. * var mb = new BABYLON.MotionBlurPostProcess(
  53712. * 'mb', // The name of the effect.
  53713. * scene, // The scene containing the objects to blur according to their velocity.
  53714. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53715. * camera // The camera to apply the render pass to.
  53716. * );
  53717. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53718. */
  53719. export class MotionBlurPostProcess extends PostProcess {
  53720. /**
  53721. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53722. */
  53723. motionStrength: number;
  53724. /**
  53725. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53726. */
  53727. /**
  53728. * Sets the number of iterations to be used for motion blur quality
  53729. */
  53730. motionBlurSamples: number;
  53731. private _motionBlurSamples;
  53732. private _geometryBufferRenderer;
  53733. /**
  53734. * Creates a new instance MotionBlurPostProcess
  53735. * @param name The name of the effect.
  53736. * @param scene The scene containing the objects to blur according to their velocity.
  53737. * @param options The required width/height ratio to downsize to before computing the render pass.
  53738. * @param camera The camera to apply the render pass to.
  53739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53740. * @param engine The engine which the post process will be applied. (default: current engine)
  53741. * @param reusable If the post process can be reused on the same frame. (default: false)
  53742. * @param textureType Type of textures used when performing the post process. (default: 0)
  53743. * @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)
  53744. */
  53745. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53746. /**
  53747. * Disposes the post process.
  53748. * @param camera The camera to dispose the post process on.
  53749. */
  53750. dispose(camera?: Camera): void;
  53751. }
  53752. }
  53753. declare module "babylonjs/Shaders/refraction.fragment" {
  53754. /** @hidden */
  53755. export var refractionPixelShader: {
  53756. name: string;
  53757. shader: string;
  53758. };
  53759. }
  53760. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53761. import { Color3 } from "babylonjs/Maths/math";
  53762. import { Camera } from "babylonjs/Cameras/camera";
  53763. import { Texture } from "babylonjs/Materials/Textures/texture";
  53764. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53765. import { Engine } from "babylonjs/Engines/engine";
  53766. import "babylonjs/Shaders/refraction.fragment";
  53767. /**
  53768. * Post process which applies a refractin texture
  53769. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53770. */
  53771. export class RefractionPostProcess extends PostProcess {
  53772. /** the base color of the refraction (used to taint the rendering) */
  53773. color: Color3;
  53774. /** simulated refraction depth */
  53775. depth: number;
  53776. /** the coefficient of the base color (0 to remove base color tainting) */
  53777. colorLevel: number;
  53778. private _refTexture;
  53779. private _ownRefractionTexture;
  53780. /**
  53781. * Gets or sets the refraction texture
  53782. * Please note that you are responsible for disposing the texture if you set it manually
  53783. */
  53784. refractionTexture: Texture;
  53785. /**
  53786. * Initializes the RefractionPostProcess
  53787. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53788. * @param name The name of the effect.
  53789. * @param refractionTextureUrl Url of the refraction texture to use
  53790. * @param color the base color of the refraction (used to taint the rendering)
  53791. * @param depth simulated refraction depth
  53792. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53793. * @param camera The camera to apply the render pass to.
  53794. * @param options The required width/height ratio to downsize to before computing the render pass.
  53795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53796. * @param engine The engine which the post process will be applied. (default: current engine)
  53797. * @param reusable If the post process can be reused on the same frame. (default: false)
  53798. */
  53799. constructor(name: string, refractionTextureUrl: string,
  53800. /** the base color of the refraction (used to taint the rendering) */
  53801. color: Color3,
  53802. /** simulated refraction depth */
  53803. depth: number,
  53804. /** the coefficient of the base color (0 to remove base color tainting) */
  53805. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53806. /**
  53807. * Disposes of the post process
  53808. * @param camera Camera to dispose post process on
  53809. */
  53810. dispose(camera: Camera): void;
  53811. }
  53812. }
  53813. declare module "babylonjs/Shaders/sharpen.fragment" {
  53814. /** @hidden */
  53815. export var sharpenPixelShader: {
  53816. name: string;
  53817. shader: string;
  53818. };
  53819. }
  53820. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53821. import { Nullable } from "babylonjs/types";
  53822. import { Camera } from "babylonjs/Cameras/camera";
  53823. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53824. import "babylonjs/Shaders/sharpen.fragment";
  53825. import { Engine } from "babylonjs/Engines/engine";
  53826. /**
  53827. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53828. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53829. */
  53830. export class SharpenPostProcess extends PostProcess {
  53831. /**
  53832. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53833. */
  53834. colorAmount: number;
  53835. /**
  53836. * How much sharpness should be applied (default: 0.3)
  53837. */
  53838. edgeAmount: number;
  53839. /**
  53840. * Creates a new instance ConvolutionPostProcess
  53841. * @param name The name of the effect.
  53842. * @param options The required width/height ratio to downsize to before computing the render pass.
  53843. * @param camera The camera to apply the render pass to.
  53844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53845. * @param engine The engine which the post process will be applied. (default: current engine)
  53846. * @param reusable If the post process can be reused on the same frame. (default: false)
  53847. * @param textureType Type of textures used when performing the post process. (default: 0)
  53848. * @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)
  53849. */
  53850. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53851. }
  53852. }
  53853. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53854. import { Nullable } from "babylonjs/types";
  53855. import { Camera } from "babylonjs/Cameras/camera";
  53856. import { Engine } from "babylonjs/Engines/engine";
  53857. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53858. /**
  53859. * PostProcessRenderPipeline
  53860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53861. */
  53862. export class PostProcessRenderPipeline {
  53863. private engine;
  53864. private _renderEffects;
  53865. private _renderEffectsForIsolatedPass;
  53866. /**
  53867. * @hidden
  53868. */
  53869. protected _cameras: Camera[];
  53870. /** @hidden */
  53871. _name: string;
  53872. /**
  53873. * Gets pipeline name
  53874. */
  53875. readonly name: string;
  53876. /**
  53877. * Initializes a PostProcessRenderPipeline
  53878. * @param engine engine to add the pipeline to
  53879. * @param name name of the pipeline
  53880. */
  53881. constructor(engine: Engine, name: string);
  53882. /**
  53883. * Gets the class name
  53884. * @returns "PostProcessRenderPipeline"
  53885. */
  53886. getClassName(): string;
  53887. /**
  53888. * If all the render effects in the pipeline are supported
  53889. */
  53890. readonly isSupported: boolean;
  53891. /**
  53892. * Adds an effect to the pipeline
  53893. * @param renderEffect the effect to add
  53894. */
  53895. addEffect(renderEffect: PostProcessRenderEffect): void;
  53896. /** @hidden */
  53897. _rebuild(): void;
  53898. /** @hidden */
  53899. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53900. /** @hidden */
  53901. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53902. /** @hidden */
  53903. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53904. /** @hidden */
  53905. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53906. /** @hidden */
  53907. _attachCameras(cameras: Camera, unique: boolean): void;
  53908. /** @hidden */
  53909. _attachCameras(cameras: Camera[], unique: boolean): void;
  53910. /** @hidden */
  53911. _detachCameras(cameras: Camera): void;
  53912. /** @hidden */
  53913. _detachCameras(cameras: Nullable<Camera[]>): void;
  53914. /** @hidden */
  53915. _update(): void;
  53916. /** @hidden */
  53917. _reset(): void;
  53918. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53919. /**
  53920. * Disposes of the pipeline
  53921. */
  53922. dispose(): void;
  53923. }
  53924. }
  53925. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53926. import { Camera } from "babylonjs/Cameras/camera";
  53927. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53928. /**
  53929. * PostProcessRenderPipelineManager class
  53930. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53931. */
  53932. export class PostProcessRenderPipelineManager {
  53933. private _renderPipelines;
  53934. /**
  53935. * Initializes a PostProcessRenderPipelineManager
  53936. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53937. */
  53938. constructor();
  53939. /**
  53940. * Gets the list of supported render pipelines
  53941. */
  53942. readonly supportedPipelines: PostProcessRenderPipeline[];
  53943. /**
  53944. * Adds a pipeline to the manager
  53945. * @param renderPipeline The pipeline to add
  53946. */
  53947. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53948. /**
  53949. * Attaches a camera to the pipeline
  53950. * @param renderPipelineName The name of the pipeline to attach to
  53951. * @param cameras the camera to attach
  53952. * @param unique if the camera can be attached multiple times to the pipeline
  53953. */
  53954. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53955. /**
  53956. * Detaches a camera from the pipeline
  53957. * @param renderPipelineName The name of the pipeline to detach from
  53958. * @param cameras the camera to detach
  53959. */
  53960. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53961. /**
  53962. * Enables an effect by name on a pipeline
  53963. * @param renderPipelineName the name of the pipeline to enable the effect in
  53964. * @param renderEffectName the name of the effect to enable
  53965. * @param cameras the cameras that the effect should be enabled on
  53966. */
  53967. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53968. /**
  53969. * Disables an effect by name on a pipeline
  53970. * @param renderPipelineName the name of the pipeline to disable the effect in
  53971. * @param renderEffectName the name of the effect to disable
  53972. * @param cameras the cameras that the effect should be disabled on
  53973. */
  53974. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53975. /**
  53976. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53977. */
  53978. update(): void;
  53979. /** @hidden */
  53980. _rebuild(): void;
  53981. /**
  53982. * Disposes of the manager and pipelines
  53983. */
  53984. dispose(): void;
  53985. }
  53986. }
  53987. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53988. import { ISceneComponent } from "babylonjs/sceneComponent";
  53989. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53990. import { Scene } from "babylonjs/scene";
  53991. module "babylonjs/scene" {
  53992. interface Scene {
  53993. /** @hidden (Backing field) */
  53994. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53995. /**
  53996. * Gets the postprocess render pipeline manager
  53997. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53998. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53999. */
  54000. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54001. }
  54002. }
  54003. /**
  54004. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54005. */
  54006. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54007. /**
  54008. * The component name helpfull to identify the component in the list of scene components.
  54009. */
  54010. readonly name: string;
  54011. /**
  54012. * The scene the component belongs to.
  54013. */
  54014. scene: Scene;
  54015. /**
  54016. * Creates a new instance of the component for the given scene
  54017. * @param scene Defines the scene to register the component in
  54018. */
  54019. constructor(scene: Scene);
  54020. /**
  54021. * Registers the component in a given scene
  54022. */
  54023. register(): void;
  54024. /**
  54025. * Rebuilds the elements related to this component in case of
  54026. * context lost for instance.
  54027. */
  54028. rebuild(): void;
  54029. /**
  54030. * Disposes the component and the associated ressources
  54031. */
  54032. dispose(): void;
  54033. private _gatherRenderTargets;
  54034. }
  54035. }
  54036. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54037. import { IAnimatable } from "babylonjs/Misc/tools";
  54038. import { Camera } from "babylonjs/Cameras/camera";
  54039. import { IDisposable } from "babylonjs/scene";
  54040. import { Scene } from "babylonjs/scene";
  54041. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54042. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54043. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54044. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54045. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54046. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54047. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54048. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54049. import { Animation } from "babylonjs/Animations/animation";
  54050. /**
  54051. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54052. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54053. */
  54054. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54055. private _scene;
  54056. private _camerasToBeAttached;
  54057. /**
  54058. * ID of the sharpen post process,
  54059. */
  54060. private readonly SharpenPostProcessId;
  54061. /**
  54062. * @ignore
  54063. * ID of the image processing post process;
  54064. */
  54065. readonly ImageProcessingPostProcessId: string;
  54066. /**
  54067. * @ignore
  54068. * ID of the Fast Approximate Anti-Aliasing post process;
  54069. */
  54070. readonly FxaaPostProcessId: string;
  54071. /**
  54072. * ID of the chromatic aberration post process,
  54073. */
  54074. private readonly ChromaticAberrationPostProcessId;
  54075. /**
  54076. * ID of the grain post process
  54077. */
  54078. private readonly GrainPostProcessId;
  54079. /**
  54080. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54081. */
  54082. sharpen: SharpenPostProcess;
  54083. private _sharpenEffect;
  54084. private bloom;
  54085. /**
  54086. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54087. */
  54088. depthOfField: DepthOfFieldEffect;
  54089. /**
  54090. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54091. */
  54092. fxaa: FxaaPostProcess;
  54093. /**
  54094. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54095. */
  54096. imageProcessing: ImageProcessingPostProcess;
  54097. /**
  54098. * Chromatic aberration post process which will shift rgb colors in the image
  54099. */
  54100. chromaticAberration: ChromaticAberrationPostProcess;
  54101. private _chromaticAberrationEffect;
  54102. /**
  54103. * Grain post process which add noise to the image
  54104. */
  54105. grain: GrainPostProcess;
  54106. private _grainEffect;
  54107. /**
  54108. * Glow post process which adds a glow to emissive areas of the image
  54109. */
  54110. private _glowLayer;
  54111. /**
  54112. * Animations which can be used to tweak settings over a period of time
  54113. */
  54114. animations: Animation[];
  54115. private _imageProcessingConfigurationObserver;
  54116. private _sharpenEnabled;
  54117. private _bloomEnabled;
  54118. private _depthOfFieldEnabled;
  54119. private _depthOfFieldBlurLevel;
  54120. private _fxaaEnabled;
  54121. private _imageProcessingEnabled;
  54122. private _defaultPipelineTextureType;
  54123. private _bloomScale;
  54124. private _chromaticAberrationEnabled;
  54125. private _grainEnabled;
  54126. private _buildAllowed;
  54127. /**
  54128. * Gets active scene
  54129. */
  54130. readonly scene: Scene;
  54131. /**
  54132. * Enable or disable the sharpen process from the pipeline
  54133. */
  54134. sharpenEnabled: boolean;
  54135. private _resizeObserver;
  54136. private _hardwareScaleLevel;
  54137. private _bloomKernel;
  54138. /**
  54139. * Specifies the size of the bloom blur kernel, relative to the final output size
  54140. */
  54141. bloomKernel: number;
  54142. /**
  54143. * Specifies the weight of the bloom in the final rendering
  54144. */
  54145. private _bloomWeight;
  54146. /**
  54147. * Specifies the luma threshold for the area that will be blurred by the bloom
  54148. */
  54149. private _bloomThreshold;
  54150. private _hdr;
  54151. /**
  54152. * The strength of the bloom.
  54153. */
  54154. bloomWeight: number;
  54155. /**
  54156. * The strength of the bloom.
  54157. */
  54158. bloomThreshold: number;
  54159. /**
  54160. * The scale of the bloom, lower value will provide better performance.
  54161. */
  54162. bloomScale: number;
  54163. /**
  54164. * Enable or disable the bloom from the pipeline
  54165. */
  54166. bloomEnabled: boolean;
  54167. private _rebuildBloom;
  54168. /**
  54169. * If the depth of field is enabled.
  54170. */
  54171. depthOfFieldEnabled: boolean;
  54172. /**
  54173. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54174. */
  54175. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54176. /**
  54177. * If the anti aliasing is enabled.
  54178. */
  54179. fxaaEnabled: boolean;
  54180. private _samples;
  54181. /**
  54182. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54183. */
  54184. samples: number;
  54185. /**
  54186. * If image processing is enabled.
  54187. */
  54188. imageProcessingEnabled: boolean;
  54189. /**
  54190. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54191. */
  54192. glowLayerEnabled: boolean;
  54193. /**
  54194. * Enable or disable the chromaticAberration process from the pipeline
  54195. */
  54196. chromaticAberrationEnabled: boolean;
  54197. /**
  54198. * Enable or disable the grain process from the pipeline
  54199. */
  54200. grainEnabled: boolean;
  54201. /**
  54202. * @constructor
  54203. * @param name - The rendering pipeline name (default: "")
  54204. * @param hdr - If high dynamic range textures should be used (default: true)
  54205. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54206. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54207. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54208. */
  54209. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54210. /**
  54211. * Get the class name
  54212. * @returns "DefaultRenderingPipeline"
  54213. */
  54214. getClassName(): string;
  54215. /**
  54216. * Force the compilation of the entire pipeline.
  54217. */
  54218. prepare(): void;
  54219. private _hasCleared;
  54220. private _prevPostProcess;
  54221. private _prevPrevPostProcess;
  54222. private _setAutoClearAndTextureSharing;
  54223. private _depthOfFieldSceneObserver;
  54224. private _buildPipeline;
  54225. private _disposePostProcesses;
  54226. /**
  54227. * Adds a camera to the pipeline
  54228. * @param camera the camera to be added
  54229. */
  54230. addCamera(camera: Camera): void;
  54231. /**
  54232. * Removes a camera from the pipeline
  54233. * @param camera the camera to remove
  54234. */
  54235. removeCamera(camera: Camera): void;
  54236. /**
  54237. * Dispose of the pipeline and stop all post processes
  54238. */
  54239. dispose(): void;
  54240. /**
  54241. * Serialize the rendering pipeline (Used when exporting)
  54242. * @returns the serialized object
  54243. */
  54244. serialize(): any;
  54245. /**
  54246. * Parse the serialized pipeline
  54247. * @param source Source pipeline.
  54248. * @param scene The scene to load the pipeline to.
  54249. * @param rootUrl The URL of the serialized pipeline.
  54250. * @returns An instantiated pipeline from the serialized object.
  54251. */
  54252. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54253. }
  54254. }
  54255. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54256. /** @hidden */
  54257. export var lensHighlightsPixelShader: {
  54258. name: string;
  54259. shader: string;
  54260. };
  54261. }
  54262. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54263. /** @hidden */
  54264. export var depthOfFieldPixelShader: {
  54265. name: string;
  54266. shader: string;
  54267. };
  54268. }
  54269. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54270. import { Camera } from "babylonjs/Cameras/camera";
  54271. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54272. import { Scene } from "babylonjs/scene";
  54273. import "babylonjs/Shaders/chromaticAberration.fragment";
  54274. import "babylonjs/Shaders/lensHighlights.fragment";
  54275. import "babylonjs/Shaders/depthOfField.fragment";
  54276. /**
  54277. * BABYLON.JS Chromatic Aberration GLSL Shader
  54278. * Author: Olivier Guyot
  54279. * Separates very slightly R, G and B colors on the edges of the screen
  54280. * Inspired by Francois Tarlier & Martins Upitis
  54281. */
  54282. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54283. /**
  54284. * @ignore
  54285. * The chromatic aberration PostProcess id in the pipeline
  54286. */
  54287. LensChromaticAberrationEffect: string;
  54288. /**
  54289. * @ignore
  54290. * The highlights enhancing PostProcess id in the pipeline
  54291. */
  54292. HighlightsEnhancingEffect: string;
  54293. /**
  54294. * @ignore
  54295. * The depth-of-field PostProcess id in the pipeline
  54296. */
  54297. LensDepthOfFieldEffect: string;
  54298. private _scene;
  54299. private _depthTexture;
  54300. private _grainTexture;
  54301. private _chromaticAberrationPostProcess;
  54302. private _highlightsPostProcess;
  54303. private _depthOfFieldPostProcess;
  54304. private _edgeBlur;
  54305. private _grainAmount;
  54306. private _chromaticAberration;
  54307. private _distortion;
  54308. private _highlightsGain;
  54309. private _highlightsThreshold;
  54310. private _dofDistance;
  54311. private _dofAperture;
  54312. private _dofDarken;
  54313. private _dofPentagon;
  54314. private _blurNoise;
  54315. /**
  54316. * @constructor
  54317. *
  54318. * Effect parameters are as follow:
  54319. * {
  54320. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54321. * edge_blur: number; // from 0 to x (1 for realism)
  54322. * distortion: number; // from 0 to x (1 for realism)
  54323. * grain_amount: number; // from 0 to 1
  54324. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54325. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54326. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54327. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54328. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54329. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54330. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54331. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54332. * }
  54333. * Note: if an effect parameter is unset, effect is disabled
  54334. *
  54335. * @param name The rendering pipeline name
  54336. * @param parameters - An object containing all parameters (see above)
  54337. * @param scene The scene linked to this pipeline
  54338. * @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)
  54339. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54340. */
  54341. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54342. /**
  54343. * Sets the amount of blur at the edges
  54344. * @param amount blur amount
  54345. */
  54346. setEdgeBlur(amount: number): void;
  54347. /**
  54348. * Sets edge blur to 0
  54349. */
  54350. disableEdgeBlur(): void;
  54351. /**
  54352. * Sets the amout of grain
  54353. * @param amount Amount of grain
  54354. */
  54355. setGrainAmount(amount: number): void;
  54356. /**
  54357. * Set grain amount to 0
  54358. */
  54359. disableGrain(): void;
  54360. /**
  54361. * Sets the chromatic aberration amount
  54362. * @param amount amount of chromatic aberration
  54363. */
  54364. setChromaticAberration(amount: number): void;
  54365. /**
  54366. * Sets chromatic aberration amount to 0
  54367. */
  54368. disableChromaticAberration(): void;
  54369. /**
  54370. * Sets the EdgeDistortion amount
  54371. * @param amount amount of EdgeDistortion
  54372. */
  54373. setEdgeDistortion(amount: number): void;
  54374. /**
  54375. * Sets edge distortion to 0
  54376. */
  54377. disableEdgeDistortion(): void;
  54378. /**
  54379. * Sets the FocusDistance amount
  54380. * @param amount amount of FocusDistance
  54381. */
  54382. setFocusDistance(amount: number): void;
  54383. /**
  54384. * Disables depth of field
  54385. */
  54386. disableDepthOfField(): void;
  54387. /**
  54388. * Sets the Aperture amount
  54389. * @param amount amount of Aperture
  54390. */
  54391. setAperture(amount: number): void;
  54392. /**
  54393. * Sets the DarkenOutOfFocus amount
  54394. * @param amount amount of DarkenOutOfFocus
  54395. */
  54396. setDarkenOutOfFocus(amount: number): void;
  54397. /**
  54398. * Creates a pentagon bokeh effect
  54399. */
  54400. enablePentagonBokeh(): void;
  54401. /**
  54402. * Disables the pentagon bokeh effect
  54403. */
  54404. disablePentagonBokeh(): void;
  54405. /**
  54406. * Enables noise blur
  54407. */
  54408. enableNoiseBlur(): void;
  54409. /**
  54410. * Disables noise blur
  54411. */
  54412. disableNoiseBlur(): void;
  54413. /**
  54414. * Sets the HighlightsGain amount
  54415. * @param amount amount of HighlightsGain
  54416. */
  54417. setHighlightsGain(amount: number): void;
  54418. /**
  54419. * Sets the HighlightsThreshold amount
  54420. * @param amount amount of HighlightsThreshold
  54421. */
  54422. setHighlightsThreshold(amount: number): void;
  54423. /**
  54424. * Disables highlights
  54425. */
  54426. disableHighlights(): void;
  54427. /**
  54428. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54429. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54430. */
  54431. dispose(disableDepthRender?: boolean): void;
  54432. private _createChromaticAberrationPostProcess;
  54433. private _createHighlightsPostProcess;
  54434. private _createDepthOfFieldPostProcess;
  54435. private _createGrainTexture;
  54436. }
  54437. }
  54438. declare module "babylonjs/Shaders/ssao2.fragment" {
  54439. /** @hidden */
  54440. export var ssao2PixelShader: {
  54441. name: string;
  54442. shader: string;
  54443. };
  54444. }
  54445. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54446. /** @hidden */
  54447. export var ssaoCombinePixelShader: {
  54448. name: string;
  54449. shader: string;
  54450. };
  54451. }
  54452. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54453. import { Camera } from "babylonjs/Cameras/camera";
  54454. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54455. import { Scene } from "babylonjs/scene";
  54456. import "babylonjs/Shaders/ssao2.fragment";
  54457. import "babylonjs/Shaders/ssaoCombine.fragment";
  54458. /**
  54459. * Render pipeline to produce ssao effect
  54460. */
  54461. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54462. /**
  54463. * @ignore
  54464. * The PassPostProcess id in the pipeline that contains the original scene color
  54465. */
  54466. SSAOOriginalSceneColorEffect: string;
  54467. /**
  54468. * @ignore
  54469. * The SSAO PostProcess id in the pipeline
  54470. */
  54471. SSAORenderEffect: string;
  54472. /**
  54473. * @ignore
  54474. * The horizontal blur PostProcess id in the pipeline
  54475. */
  54476. SSAOBlurHRenderEffect: string;
  54477. /**
  54478. * @ignore
  54479. * The vertical blur PostProcess id in the pipeline
  54480. */
  54481. SSAOBlurVRenderEffect: string;
  54482. /**
  54483. * @ignore
  54484. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54485. */
  54486. SSAOCombineRenderEffect: string;
  54487. /**
  54488. * The output strength of the SSAO post-process. Default value is 1.0.
  54489. */
  54490. totalStrength: number;
  54491. /**
  54492. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54493. */
  54494. maxZ: number;
  54495. /**
  54496. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54497. */
  54498. minZAspect: number;
  54499. private _samples;
  54500. /**
  54501. * Number of samples used for the SSAO calculations. Default value is 8
  54502. */
  54503. samples: number;
  54504. private _textureSamples;
  54505. /**
  54506. * Number of samples to use for antialiasing
  54507. */
  54508. textureSamples: number;
  54509. /**
  54510. * Ratio object used for SSAO ratio and blur ratio
  54511. */
  54512. private _ratio;
  54513. /**
  54514. * Dynamically generated sphere sampler.
  54515. */
  54516. private _sampleSphere;
  54517. /**
  54518. * Blur filter offsets
  54519. */
  54520. private _samplerOffsets;
  54521. private _expensiveBlur;
  54522. /**
  54523. * If bilateral blur should be used
  54524. */
  54525. expensiveBlur: boolean;
  54526. /**
  54527. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54528. */
  54529. radius: number;
  54530. /**
  54531. * The base color of the SSAO post-process
  54532. * The final result is "base + ssao" between [0, 1]
  54533. */
  54534. base: number;
  54535. /**
  54536. * Support test.
  54537. */
  54538. static readonly IsSupported: boolean;
  54539. private _scene;
  54540. private _depthTexture;
  54541. private _normalTexture;
  54542. private _randomTexture;
  54543. private _originalColorPostProcess;
  54544. private _ssaoPostProcess;
  54545. private _blurHPostProcess;
  54546. private _blurVPostProcess;
  54547. private _ssaoCombinePostProcess;
  54548. private _firstUpdate;
  54549. /**
  54550. * Gets active scene
  54551. */
  54552. readonly scene: Scene;
  54553. /**
  54554. * @constructor
  54555. * @param name The rendering pipeline name
  54556. * @param scene The scene linked to this pipeline
  54557. * @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 }
  54558. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54559. */
  54560. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54561. /**
  54562. * Get the class name
  54563. * @returns "SSAO2RenderingPipeline"
  54564. */
  54565. getClassName(): string;
  54566. /**
  54567. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54568. */
  54569. dispose(disableGeometryBufferRenderer?: boolean): void;
  54570. private _createBlurPostProcess;
  54571. /** @hidden */
  54572. _rebuild(): void;
  54573. private _bits;
  54574. private _radicalInverse_VdC;
  54575. private _hammersley;
  54576. private _hemisphereSample_uniform;
  54577. private _generateHemisphere;
  54578. private _createSSAOPostProcess;
  54579. private _createSSAOCombinePostProcess;
  54580. private _createRandomTexture;
  54581. /**
  54582. * Serialize the rendering pipeline (Used when exporting)
  54583. * @returns the serialized object
  54584. */
  54585. serialize(): any;
  54586. /**
  54587. * Parse the serialized pipeline
  54588. * @param source Source pipeline.
  54589. * @param scene The scene to load the pipeline to.
  54590. * @param rootUrl The URL of the serialized pipeline.
  54591. * @returns An instantiated pipeline from the serialized object.
  54592. */
  54593. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54594. }
  54595. }
  54596. declare module "babylonjs/Shaders/ssao.fragment" {
  54597. /** @hidden */
  54598. export var ssaoPixelShader: {
  54599. name: string;
  54600. shader: string;
  54601. };
  54602. }
  54603. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54604. import { Camera } from "babylonjs/Cameras/camera";
  54605. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54606. import { Scene } from "babylonjs/scene";
  54607. import "babylonjs/Shaders/ssao.fragment";
  54608. import "babylonjs/Shaders/ssaoCombine.fragment";
  54609. /**
  54610. * Render pipeline to produce ssao effect
  54611. */
  54612. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54613. /**
  54614. * @ignore
  54615. * The PassPostProcess id in the pipeline that contains the original scene color
  54616. */
  54617. SSAOOriginalSceneColorEffect: string;
  54618. /**
  54619. * @ignore
  54620. * The SSAO PostProcess id in the pipeline
  54621. */
  54622. SSAORenderEffect: string;
  54623. /**
  54624. * @ignore
  54625. * The horizontal blur PostProcess id in the pipeline
  54626. */
  54627. SSAOBlurHRenderEffect: string;
  54628. /**
  54629. * @ignore
  54630. * The vertical blur PostProcess id in the pipeline
  54631. */
  54632. SSAOBlurVRenderEffect: string;
  54633. /**
  54634. * @ignore
  54635. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54636. */
  54637. SSAOCombineRenderEffect: string;
  54638. /**
  54639. * The output strength of the SSAO post-process. Default value is 1.0.
  54640. */
  54641. totalStrength: number;
  54642. /**
  54643. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54644. */
  54645. radius: number;
  54646. /**
  54647. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54648. * Must not be equal to fallOff and superior to fallOff.
  54649. * Default value is 0.0075
  54650. */
  54651. area: number;
  54652. /**
  54653. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54654. * Must not be equal to area and inferior to area.
  54655. * Default value is 0.000001
  54656. */
  54657. fallOff: number;
  54658. /**
  54659. * The base color of the SSAO post-process
  54660. * The final result is "base + ssao" between [0, 1]
  54661. */
  54662. base: number;
  54663. private _scene;
  54664. private _depthTexture;
  54665. private _randomTexture;
  54666. private _originalColorPostProcess;
  54667. private _ssaoPostProcess;
  54668. private _blurHPostProcess;
  54669. private _blurVPostProcess;
  54670. private _ssaoCombinePostProcess;
  54671. private _firstUpdate;
  54672. /**
  54673. * Gets active scene
  54674. */
  54675. readonly scene: Scene;
  54676. /**
  54677. * @constructor
  54678. * @param name - The rendering pipeline name
  54679. * @param scene - The scene linked to this pipeline
  54680. * @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 }
  54681. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54682. */
  54683. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54684. /**
  54685. * Get the class name
  54686. * @returns "SSAORenderingPipeline"
  54687. */
  54688. getClassName(): string;
  54689. /**
  54690. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54691. */
  54692. dispose(disableDepthRender?: boolean): void;
  54693. private _createBlurPostProcess;
  54694. /** @hidden */
  54695. _rebuild(): void;
  54696. private _createSSAOPostProcess;
  54697. private _createSSAOCombinePostProcess;
  54698. private _createRandomTexture;
  54699. }
  54700. }
  54701. declare module "babylonjs/Shaders/standard.fragment" {
  54702. /** @hidden */
  54703. export var standardPixelShader: {
  54704. name: string;
  54705. shader: string;
  54706. };
  54707. }
  54708. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54709. import { Nullable } from "babylonjs/types";
  54710. import { IAnimatable } from "babylonjs/Misc/tools";
  54711. import { Camera } from "babylonjs/Cameras/camera";
  54712. import { Texture } from "babylonjs/Materials/Textures/texture";
  54713. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54714. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54715. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54716. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54717. import { IDisposable } from "babylonjs/scene";
  54718. import { SpotLight } from "babylonjs/Lights/spotLight";
  54719. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54720. import { Scene } from "babylonjs/scene";
  54721. import { Animation } from "babylonjs/Animations/animation";
  54722. import "babylonjs/Shaders/standard.fragment";
  54723. /**
  54724. * Standard rendering pipeline
  54725. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54726. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54727. */
  54728. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54729. /**
  54730. * Public members
  54731. */
  54732. /**
  54733. * Post-process which contains the original scene color before the pipeline applies all the effects
  54734. */
  54735. originalPostProcess: Nullable<PostProcess>;
  54736. /**
  54737. * Post-process used to down scale an image x4
  54738. */
  54739. downSampleX4PostProcess: Nullable<PostProcess>;
  54740. /**
  54741. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54742. */
  54743. brightPassPostProcess: Nullable<PostProcess>;
  54744. /**
  54745. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54746. */
  54747. blurHPostProcesses: PostProcess[];
  54748. /**
  54749. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54750. */
  54751. blurVPostProcesses: PostProcess[];
  54752. /**
  54753. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54754. */
  54755. textureAdderPostProcess: Nullable<PostProcess>;
  54756. /**
  54757. * Post-process used to create volumetric lighting effect
  54758. */
  54759. volumetricLightPostProcess: Nullable<PostProcess>;
  54760. /**
  54761. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54762. */
  54763. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54764. /**
  54765. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54766. */
  54767. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54768. /**
  54769. * Post-process used to merge the volumetric light effect and the real scene color
  54770. */
  54771. volumetricLightMergePostProces: Nullable<PostProcess>;
  54772. /**
  54773. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54774. */
  54775. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54776. /**
  54777. * Base post-process used to calculate the average luminance of the final image for HDR
  54778. */
  54779. luminancePostProcess: Nullable<PostProcess>;
  54780. /**
  54781. * Post-processes used to create down sample post-processes in order to get
  54782. * the average luminance of the final image for HDR
  54783. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54784. */
  54785. luminanceDownSamplePostProcesses: PostProcess[];
  54786. /**
  54787. * Post-process used to create a HDR effect (light adaptation)
  54788. */
  54789. hdrPostProcess: Nullable<PostProcess>;
  54790. /**
  54791. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54792. */
  54793. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54794. /**
  54795. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54796. */
  54797. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54798. /**
  54799. * Post-process used to merge the final HDR post-process and the real scene color
  54800. */
  54801. hdrFinalPostProcess: Nullable<PostProcess>;
  54802. /**
  54803. * Post-process used to create a lens flare effect
  54804. */
  54805. lensFlarePostProcess: Nullable<PostProcess>;
  54806. /**
  54807. * Post-process that merges the result of the lens flare post-process and the real scene color
  54808. */
  54809. lensFlareComposePostProcess: Nullable<PostProcess>;
  54810. /**
  54811. * Post-process used to create a motion blur effect
  54812. */
  54813. motionBlurPostProcess: Nullable<PostProcess>;
  54814. /**
  54815. * Post-process used to create a depth of field effect
  54816. */
  54817. depthOfFieldPostProcess: Nullable<PostProcess>;
  54818. /**
  54819. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54820. */
  54821. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54822. /**
  54823. * Represents the brightness threshold in order to configure the illuminated surfaces
  54824. */
  54825. brightThreshold: number;
  54826. /**
  54827. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54828. */
  54829. blurWidth: number;
  54830. /**
  54831. * Sets if the blur for highlighted surfaces must be only horizontal
  54832. */
  54833. horizontalBlur: boolean;
  54834. /**
  54835. * Sets the overall exposure used by the pipeline
  54836. */
  54837. exposure: number;
  54838. /**
  54839. * Texture used typically to simulate "dirty" on camera lens
  54840. */
  54841. lensTexture: Nullable<Texture>;
  54842. /**
  54843. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54844. */
  54845. volumetricLightCoefficient: number;
  54846. /**
  54847. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54848. */
  54849. volumetricLightPower: number;
  54850. /**
  54851. * Used the set the blur intensity to smooth the volumetric lights
  54852. */
  54853. volumetricLightBlurScale: number;
  54854. /**
  54855. * Light (spot or directional) used to generate the volumetric lights rays
  54856. * The source light must have a shadow generate so the pipeline can get its
  54857. * depth map
  54858. */
  54859. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54860. /**
  54861. * For eye adaptation, represents the minimum luminance the eye can see
  54862. */
  54863. hdrMinimumLuminance: number;
  54864. /**
  54865. * For eye adaptation, represents the decrease luminance speed
  54866. */
  54867. hdrDecreaseRate: number;
  54868. /**
  54869. * For eye adaptation, represents the increase luminance speed
  54870. */
  54871. hdrIncreaseRate: number;
  54872. /**
  54873. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54874. */
  54875. lensColorTexture: Nullable<Texture>;
  54876. /**
  54877. * The overall strengh for the lens flare effect
  54878. */
  54879. lensFlareStrength: number;
  54880. /**
  54881. * Dispersion coefficient for lens flare ghosts
  54882. */
  54883. lensFlareGhostDispersal: number;
  54884. /**
  54885. * Main lens flare halo width
  54886. */
  54887. lensFlareHaloWidth: number;
  54888. /**
  54889. * Based on the lens distortion effect, defines how much the lens flare result
  54890. * is distorted
  54891. */
  54892. lensFlareDistortionStrength: number;
  54893. /**
  54894. * Lens star texture must be used to simulate rays on the flares and is available
  54895. * in the documentation
  54896. */
  54897. lensStarTexture: Nullable<Texture>;
  54898. /**
  54899. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54900. * flare effect by taking account of the dirt texture
  54901. */
  54902. lensFlareDirtTexture: Nullable<Texture>;
  54903. /**
  54904. * Represents the focal length for the depth of field effect
  54905. */
  54906. depthOfFieldDistance: number;
  54907. /**
  54908. * Represents the blur intensity for the blurred part of the depth of field effect
  54909. */
  54910. depthOfFieldBlurWidth: number;
  54911. /**
  54912. * For motion blur, defines how much the image is blurred by the movement
  54913. */
  54914. motionStrength: number;
  54915. /**
  54916. * List of animations for the pipeline (IAnimatable implementation)
  54917. */
  54918. animations: Animation[];
  54919. /**
  54920. * Private members
  54921. */
  54922. private _scene;
  54923. private _currentDepthOfFieldSource;
  54924. private _basePostProcess;
  54925. private _hdrCurrentLuminance;
  54926. private _floatTextureType;
  54927. private _ratio;
  54928. private _bloomEnabled;
  54929. private _depthOfFieldEnabled;
  54930. private _vlsEnabled;
  54931. private _lensFlareEnabled;
  54932. private _hdrEnabled;
  54933. private _motionBlurEnabled;
  54934. private _fxaaEnabled;
  54935. private _motionBlurSamples;
  54936. private _volumetricLightStepsCount;
  54937. private _samples;
  54938. /**
  54939. * @ignore
  54940. * Specifies if the bloom pipeline is enabled
  54941. */
  54942. BloomEnabled: boolean;
  54943. /**
  54944. * @ignore
  54945. * Specifies if the depth of field pipeline is enabed
  54946. */
  54947. DepthOfFieldEnabled: boolean;
  54948. /**
  54949. * @ignore
  54950. * Specifies if the lens flare pipeline is enabed
  54951. */
  54952. LensFlareEnabled: boolean;
  54953. /**
  54954. * @ignore
  54955. * Specifies if the HDR pipeline is enabled
  54956. */
  54957. HDREnabled: boolean;
  54958. /**
  54959. * @ignore
  54960. * Specifies if the volumetric lights scattering effect is enabled
  54961. */
  54962. VLSEnabled: boolean;
  54963. /**
  54964. * @ignore
  54965. * Specifies if the motion blur effect is enabled
  54966. */
  54967. MotionBlurEnabled: boolean;
  54968. /**
  54969. * Specifies if anti-aliasing is enabled
  54970. */
  54971. fxaaEnabled: boolean;
  54972. /**
  54973. * Specifies the number of steps used to calculate the volumetric lights
  54974. * Typically in interval [50, 200]
  54975. */
  54976. volumetricLightStepsCount: number;
  54977. /**
  54978. * Specifies the number of samples used for the motion blur effect
  54979. * Typically in interval [16, 64]
  54980. */
  54981. motionBlurSamples: number;
  54982. /**
  54983. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54984. */
  54985. samples: number;
  54986. /**
  54987. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54988. * @constructor
  54989. * @param name The rendering pipeline name
  54990. * @param scene The scene linked to this pipeline
  54991. * @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)
  54992. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54993. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54994. */
  54995. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54996. private _buildPipeline;
  54997. private _createDownSampleX4PostProcess;
  54998. private _createBrightPassPostProcess;
  54999. private _createBlurPostProcesses;
  55000. private _createTextureAdderPostProcess;
  55001. private _createVolumetricLightPostProcess;
  55002. private _createLuminancePostProcesses;
  55003. private _createHdrPostProcess;
  55004. private _createLensFlarePostProcess;
  55005. private _createDepthOfFieldPostProcess;
  55006. private _createMotionBlurPostProcess;
  55007. private _getDepthTexture;
  55008. private _disposePostProcesses;
  55009. /**
  55010. * Dispose of the pipeline and stop all post processes
  55011. */
  55012. dispose(): void;
  55013. /**
  55014. * Serialize the rendering pipeline (Used when exporting)
  55015. * @returns the serialized object
  55016. */
  55017. serialize(): any;
  55018. /**
  55019. * Parse the serialized pipeline
  55020. * @param source Source pipeline.
  55021. * @param scene The scene to load the pipeline to.
  55022. * @param rootUrl The URL of the serialized pipeline.
  55023. * @returns An instantiated pipeline from the serialized object.
  55024. */
  55025. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55026. /**
  55027. * Luminance steps
  55028. */
  55029. static LuminanceSteps: number;
  55030. }
  55031. }
  55032. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55033. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55034. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55035. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55036. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55037. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55038. }
  55039. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55040. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55041. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55042. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55043. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55044. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55045. }
  55046. declare module "babylonjs/Shaders/tonemap.fragment" {
  55047. /** @hidden */
  55048. export var tonemapPixelShader: {
  55049. name: string;
  55050. shader: string;
  55051. };
  55052. }
  55053. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55054. import { Camera } from "babylonjs/Cameras/camera";
  55055. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55056. import "babylonjs/Shaders/tonemap.fragment";
  55057. import { Engine } from "babylonjs/Engines/engine";
  55058. /** Defines operator used for tonemapping */
  55059. export enum TonemappingOperator {
  55060. /** Hable */
  55061. Hable = 0,
  55062. /** Reinhard */
  55063. Reinhard = 1,
  55064. /** HejiDawson */
  55065. HejiDawson = 2,
  55066. /** Photographic */
  55067. Photographic = 3
  55068. }
  55069. /**
  55070. * Defines a post process to apply tone mapping
  55071. */
  55072. export class TonemapPostProcess extends PostProcess {
  55073. private _operator;
  55074. /** Defines the required exposure adjustement */
  55075. exposureAdjustment: number;
  55076. /**
  55077. * Creates a new TonemapPostProcess
  55078. * @param name defines the name of the postprocess
  55079. * @param _operator defines the operator to use
  55080. * @param exposureAdjustment defines the required exposure adjustement
  55081. * @param camera defines the camera to use (can be null)
  55082. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55083. * @param engine defines the hosting engine (can be ignore if camera is set)
  55084. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55085. */
  55086. constructor(name: string, _operator: TonemappingOperator,
  55087. /** Defines the required exposure adjustement */
  55088. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55089. }
  55090. }
  55091. declare module "babylonjs/Shaders/depth.vertex" {
  55092. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55093. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55094. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55095. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55096. /** @hidden */
  55097. export var depthVertexShader: {
  55098. name: string;
  55099. shader: string;
  55100. };
  55101. }
  55102. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55103. /** @hidden */
  55104. export var volumetricLightScatteringPixelShader: {
  55105. name: string;
  55106. shader: string;
  55107. };
  55108. }
  55109. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55110. /** @hidden */
  55111. export var volumetricLightScatteringPassPixelShader: {
  55112. name: string;
  55113. shader: string;
  55114. };
  55115. }
  55116. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55117. import { Vector3 } from "babylonjs/Maths/math";
  55118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55119. import { Mesh } from "babylonjs/Meshes/mesh";
  55120. import { Camera } from "babylonjs/Cameras/camera";
  55121. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55122. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55123. import { Scene } from "babylonjs/scene";
  55124. import "babylonjs/Meshes/Builders/planeBuilder";
  55125. import "babylonjs/Shaders/depth.vertex";
  55126. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55127. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55128. import { Engine } from "babylonjs/Engines/engine";
  55129. /**
  55130. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55131. */
  55132. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55133. private _volumetricLightScatteringPass;
  55134. private _volumetricLightScatteringRTT;
  55135. private _viewPort;
  55136. private _screenCoordinates;
  55137. private _cachedDefines;
  55138. /**
  55139. * If not undefined, the mesh position is computed from the attached node position
  55140. */
  55141. attachedNode: {
  55142. position: Vector3;
  55143. };
  55144. /**
  55145. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55146. */
  55147. customMeshPosition: Vector3;
  55148. /**
  55149. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55150. */
  55151. useCustomMeshPosition: boolean;
  55152. /**
  55153. * If the post-process should inverse the light scattering direction
  55154. */
  55155. invert: boolean;
  55156. /**
  55157. * The internal mesh used by the post-process
  55158. */
  55159. mesh: Mesh;
  55160. /**
  55161. * @hidden
  55162. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55163. */
  55164. useDiffuseColor: boolean;
  55165. /**
  55166. * Array containing the excluded meshes not rendered in the internal pass
  55167. */
  55168. excludedMeshes: AbstractMesh[];
  55169. /**
  55170. * Controls the overall intensity of the post-process
  55171. */
  55172. exposure: number;
  55173. /**
  55174. * Dissipates each sample's contribution in range [0, 1]
  55175. */
  55176. decay: number;
  55177. /**
  55178. * Controls the overall intensity of each sample
  55179. */
  55180. weight: number;
  55181. /**
  55182. * Controls the density of each sample
  55183. */
  55184. density: number;
  55185. /**
  55186. * @constructor
  55187. * @param name The post-process name
  55188. * @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)
  55189. * @param camera The camera that the post-process will be attached to
  55190. * @param mesh The mesh used to create the light scattering
  55191. * @param samples The post-process quality, default 100
  55192. * @param samplingModeThe post-process filtering mode
  55193. * @param engine The babylon engine
  55194. * @param reusable If the post-process is reusable
  55195. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55196. */
  55197. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55198. /**
  55199. * Returns the string "VolumetricLightScatteringPostProcess"
  55200. * @returns "VolumetricLightScatteringPostProcess"
  55201. */
  55202. getClassName(): string;
  55203. private _isReady;
  55204. /**
  55205. * Sets the new light position for light scattering effect
  55206. * @param position The new custom light position
  55207. */
  55208. setCustomMeshPosition(position: Vector3): void;
  55209. /**
  55210. * Returns the light position for light scattering effect
  55211. * @return Vector3 The custom light position
  55212. */
  55213. getCustomMeshPosition(): Vector3;
  55214. /**
  55215. * Disposes the internal assets and detaches the post-process from the camera
  55216. */
  55217. dispose(camera: Camera): void;
  55218. /**
  55219. * Returns the render target texture used by the post-process
  55220. * @return the render target texture used by the post-process
  55221. */
  55222. getPass(): RenderTargetTexture;
  55223. private _meshExcluded;
  55224. private _createPass;
  55225. private _updateMeshScreenCoordinates;
  55226. /**
  55227. * Creates a default mesh for the Volumeric Light Scattering post-process
  55228. * @param name The mesh name
  55229. * @param scene The scene where to create the mesh
  55230. * @return the default mesh
  55231. */
  55232. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55233. }
  55234. }
  55235. declare module "babylonjs/PostProcesses/index" {
  55236. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55237. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55238. export * from "babylonjs/PostProcesses/bloomEffect";
  55239. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55240. export * from "babylonjs/PostProcesses/blurPostProcess";
  55241. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55242. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55243. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55244. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55245. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55246. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55247. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55248. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55249. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55250. export * from "babylonjs/PostProcesses/filterPostProcess";
  55251. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55252. export * from "babylonjs/PostProcesses/grainPostProcess";
  55253. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55254. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55255. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55256. export * from "babylonjs/PostProcesses/passPostProcess";
  55257. export * from "babylonjs/PostProcesses/postProcess";
  55258. export * from "babylonjs/PostProcesses/postProcessManager";
  55259. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55260. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55261. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55262. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55263. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55264. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55265. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55266. }
  55267. declare module "babylonjs/Probes/index" {
  55268. export * from "babylonjs/Probes/reflectionProbe";
  55269. }
  55270. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55271. import { Scene } from "babylonjs/scene";
  55272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55273. import { Color3 } from "babylonjs/Maths/math";
  55274. import { SmartArray } from "babylonjs/Misc/smartArray";
  55275. import { ISceneComponent } from "babylonjs/sceneComponent";
  55276. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55277. import "babylonjs/Meshes/Builders/boxBuilder";
  55278. import "babylonjs/Shaders/color.fragment";
  55279. import "babylonjs/Shaders/color.vertex";
  55280. module "babylonjs/scene" {
  55281. interface Scene {
  55282. /** @hidden (Backing field) */
  55283. _boundingBoxRenderer: BoundingBoxRenderer;
  55284. /** @hidden (Backing field) */
  55285. _forceShowBoundingBoxes: boolean;
  55286. /**
  55287. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55288. */
  55289. forceShowBoundingBoxes: boolean;
  55290. /**
  55291. * Gets the bounding box renderer associated with the scene
  55292. * @returns a BoundingBoxRenderer
  55293. */
  55294. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55295. }
  55296. }
  55297. module "babylonjs/Meshes/abstractMesh" {
  55298. interface AbstractMesh {
  55299. /** @hidden (Backing field) */
  55300. _showBoundingBox: boolean;
  55301. /**
  55302. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55303. */
  55304. showBoundingBox: boolean;
  55305. }
  55306. }
  55307. /**
  55308. * Component responsible of rendering the bounding box of the meshes in a scene.
  55309. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55310. */
  55311. export class BoundingBoxRenderer implements ISceneComponent {
  55312. /**
  55313. * The component name helpfull to identify the component in the list of scene components.
  55314. */
  55315. readonly name: string;
  55316. /**
  55317. * The scene the component belongs to.
  55318. */
  55319. scene: Scene;
  55320. /**
  55321. * Color of the bounding box lines placed in front of an object
  55322. */
  55323. frontColor: Color3;
  55324. /**
  55325. * Color of the bounding box lines placed behind an object
  55326. */
  55327. backColor: Color3;
  55328. /**
  55329. * Defines if the renderer should show the back lines or not
  55330. */
  55331. showBackLines: boolean;
  55332. /**
  55333. * @hidden
  55334. */
  55335. renderList: SmartArray<BoundingBox>;
  55336. private _colorShader;
  55337. private _vertexBuffers;
  55338. private _indexBuffer;
  55339. /**
  55340. * Instantiates a new bounding box renderer in a scene.
  55341. * @param scene the scene the renderer renders in
  55342. */
  55343. constructor(scene: Scene);
  55344. /**
  55345. * Registers the component in a given scene
  55346. */
  55347. register(): void;
  55348. private _evaluateSubMesh;
  55349. private _activeMesh;
  55350. private _prepareRessources;
  55351. private _createIndexBuffer;
  55352. /**
  55353. * Rebuilds the elements related to this component in case of
  55354. * context lost for instance.
  55355. */
  55356. rebuild(): void;
  55357. /**
  55358. * @hidden
  55359. */
  55360. reset(): void;
  55361. /**
  55362. * Render the bounding boxes of a specific rendering group
  55363. * @param renderingGroupId defines the rendering group to render
  55364. */
  55365. render(renderingGroupId: number): void;
  55366. /**
  55367. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55368. * @param mesh Define the mesh to render the occlusion bounding box for
  55369. */
  55370. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55371. /**
  55372. * Dispose and release the resources attached to this renderer.
  55373. */
  55374. dispose(): void;
  55375. }
  55376. }
  55377. declare module "babylonjs/Shaders/depth.fragment" {
  55378. /** @hidden */
  55379. export var depthPixelShader: {
  55380. name: string;
  55381. shader: string;
  55382. };
  55383. }
  55384. declare module "babylonjs/Rendering/depthRenderer" {
  55385. import { Nullable } from "babylonjs/types";
  55386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55387. import { Scene } from "babylonjs/scene";
  55388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55389. import { Camera } from "babylonjs/Cameras/camera";
  55390. import "babylonjs/Shaders/depth.fragment";
  55391. import "babylonjs/Shaders/depth.vertex";
  55392. /**
  55393. * This represents a depth renderer in Babylon.
  55394. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55395. */
  55396. export class DepthRenderer {
  55397. private _scene;
  55398. private _depthMap;
  55399. private _effect;
  55400. private _cachedDefines;
  55401. private _camera;
  55402. /**
  55403. * Specifiess that the depth renderer will only be used within
  55404. * the camera it is created for.
  55405. * This can help forcing its rendering during the camera processing.
  55406. */
  55407. useOnlyInActiveCamera: boolean;
  55408. /** @hidden */
  55409. static _SceneComponentInitialization: (scene: Scene) => void;
  55410. /**
  55411. * Instantiates a depth renderer
  55412. * @param scene The scene the renderer belongs to
  55413. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55414. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55415. */
  55416. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55417. /**
  55418. * Creates the depth rendering effect and checks if the effect is ready.
  55419. * @param subMesh The submesh to be used to render the depth map of
  55420. * @param useInstances If multiple world instances should be used
  55421. * @returns if the depth renderer is ready to render the depth map
  55422. */
  55423. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55424. /**
  55425. * Gets the texture which the depth map will be written to.
  55426. * @returns The depth map texture
  55427. */
  55428. getDepthMap(): RenderTargetTexture;
  55429. /**
  55430. * Disposes of the depth renderer.
  55431. */
  55432. dispose(): void;
  55433. }
  55434. }
  55435. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55436. import { Nullable } from "babylonjs/types";
  55437. import { Scene } from "babylonjs/scene";
  55438. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55439. import { Camera } from "babylonjs/Cameras/camera";
  55440. import { ISceneComponent } from "babylonjs/sceneComponent";
  55441. module "babylonjs/scene" {
  55442. interface Scene {
  55443. /** @hidden (Backing field) */
  55444. _depthRenderer: {
  55445. [id: string]: DepthRenderer;
  55446. };
  55447. /**
  55448. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55449. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55450. * @returns the created depth renderer
  55451. */
  55452. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55453. /**
  55454. * Disables a depth renderer for a given camera
  55455. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55456. */
  55457. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55458. }
  55459. }
  55460. /**
  55461. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55462. * in several rendering techniques.
  55463. */
  55464. export class DepthRendererSceneComponent implements ISceneComponent {
  55465. /**
  55466. * The component name helpfull to identify the component in the list of scene components.
  55467. */
  55468. readonly name: string;
  55469. /**
  55470. * The scene the component belongs to.
  55471. */
  55472. scene: Scene;
  55473. /**
  55474. * Creates a new instance of the component for the given scene
  55475. * @param scene Defines the scene to register the component in
  55476. */
  55477. constructor(scene: Scene);
  55478. /**
  55479. * Registers the component in a given scene
  55480. */
  55481. register(): void;
  55482. /**
  55483. * Rebuilds the elements related to this component in case of
  55484. * context lost for instance.
  55485. */
  55486. rebuild(): void;
  55487. /**
  55488. * Disposes the component and the associated ressources
  55489. */
  55490. dispose(): void;
  55491. private _gatherRenderTargets;
  55492. private _gatherActiveCameraRenderTargets;
  55493. }
  55494. }
  55495. declare module "babylonjs/Shaders/outline.fragment" {
  55496. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55497. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55498. /** @hidden */
  55499. export var outlinePixelShader: {
  55500. name: string;
  55501. shader: string;
  55502. };
  55503. }
  55504. declare module "babylonjs/Shaders/outline.vertex" {
  55505. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55506. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55507. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55508. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55509. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55510. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55511. /** @hidden */
  55512. export var outlineVertexShader: {
  55513. name: string;
  55514. shader: string;
  55515. };
  55516. }
  55517. declare module "babylonjs/Rendering/outlineRenderer" {
  55518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55519. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55520. import { Scene } from "babylonjs/scene";
  55521. import { ISceneComponent } from "babylonjs/sceneComponent";
  55522. import "babylonjs/Shaders/outline.fragment";
  55523. import "babylonjs/Shaders/outline.vertex";
  55524. module "babylonjs/scene" {
  55525. interface Scene {
  55526. /** @hidden */
  55527. _outlineRenderer: OutlineRenderer;
  55528. /**
  55529. * Gets the outline renderer associated with the scene
  55530. * @returns a OutlineRenderer
  55531. */
  55532. getOutlineRenderer(): OutlineRenderer;
  55533. }
  55534. }
  55535. module "babylonjs/Meshes/abstractMesh" {
  55536. interface AbstractMesh {
  55537. /** @hidden (Backing field) */
  55538. _renderOutline: boolean;
  55539. /**
  55540. * Gets or sets a boolean indicating if the outline must be rendered as well
  55541. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55542. */
  55543. renderOutline: boolean;
  55544. /** @hidden (Backing field) */
  55545. _renderOverlay: boolean;
  55546. /**
  55547. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55548. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55549. */
  55550. renderOverlay: boolean;
  55551. }
  55552. }
  55553. /**
  55554. * This class is responsible to draw bothe outline/overlay of meshes.
  55555. * It should not be used directly but through the available method on mesh.
  55556. */
  55557. export class OutlineRenderer implements ISceneComponent {
  55558. /**
  55559. * The name of the component. Each component must have a unique name.
  55560. */
  55561. name: string;
  55562. /**
  55563. * The scene the component belongs to.
  55564. */
  55565. scene: Scene;
  55566. /**
  55567. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55568. */
  55569. zOffset: number;
  55570. private _engine;
  55571. private _effect;
  55572. private _cachedDefines;
  55573. private _savedDepthWrite;
  55574. /**
  55575. * Instantiates a new outline renderer. (There could be only one per scene).
  55576. * @param scene Defines the scene it belongs to
  55577. */
  55578. constructor(scene: Scene);
  55579. /**
  55580. * Register the component to one instance of a scene.
  55581. */
  55582. register(): void;
  55583. /**
  55584. * Rebuilds the elements related to this component in case of
  55585. * context lost for instance.
  55586. */
  55587. rebuild(): void;
  55588. /**
  55589. * Disposes the component and the associated ressources.
  55590. */
  55591. dispose(): void;
  55592. /**
  55593. * Renders the outline in the canvas.
  55594. * @param subMesh Defines the sumesh to render
  55595. * @param batch Defines the batch of meshes in case of instances
  55596. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55597. */
  55598. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55599. /**
  55600. * Returns whether or not the outline renderer is ready for a given submesh.
  55601. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55602. * @param subMesh Defines the submesh to check readyness for
  55603. * @param useInstances Defines wheter wee are trying to render instances or not
  55604. * @returns true if ready otherwise false
  55605. */
  55606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55607. private _beforeRenderingMesh;
  55608. private _afterRenderingMesh;
  55609. }
  55610. }
  55611. declare module "babylonjs/Rendering/index" {
  55612. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55613. export * from "babylonjs/Rendering/depthRenderer";
  55614. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55615. export * from "babylonjs/Rendering/edgesRenderer";
  55616. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55617. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55618. export * from "babylonjs/Rendering/outlineRenderer";
  55619. export * from "babylonjs/Rendering/renderingGroup";
  55620. export * from "babylonjs/Rendering/renderingManager";
  55621. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55622. }
  55623. declare module "babylonjs/Sprites/index" {
  55624. export * from "babylonjs/Sprites/sprite";
  55625. export * from "babylonjs/Sprites/spriteManager";
  55626. export * from "babylonjs/Sprites/spriteSceneComponent";
  55627. }
  55628. declare module "babylonjs/Misc/assetsManager" {
  55629. import { Scene } from "babylonjs/scene";
  55630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55631. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55632. import { Skeleton } from "babylonjs/Bones/skeleton";
  55633. import { Observable } from "babylonjs/Misc/observable";
  55634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55635. import { Texture } from "babylonjs/Materials/Textures/texture";
  55636. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55637. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55638. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55639. /**
  55640. * Defines the list of states available for a task inside a AssetsManager
  55641. */
  55642. export enum AssetTaskState {
  55643. /**
  55644. * Initialization
  55645. */
  55646. INIT = 0,
  55647. /**
  55648. * Running
  55649. */
  55650. RUNNING = 1,
  55651. /**
  55652. * Done
  55653. */
  55654. DONE = 2,
  55655. /**
  55656. * Error
  55657. */
  55658. ERROR = 3
  55659. }
  55660. /**
  55661. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55662. */
  55663. export abstract class AbstractAssetTask {
  55664. /**
  55665. * Task name
  55666. */ name: string;
  55667. /**
  55668. * Callback called when the task is successful
  55669. */
  55670. onSuccess: (task: any) => void;
  55671. /**
  55672. * Callback called when the task is not successful
  55673. */
  55674. onError: (task: any, message?: string, exception?: any) => void;
  55675. /**
  55676. * Creates a new AssetsManager
  55677. * @param name defines the name of the task
  55678. */
  55679. constructor(
  55680. /**
  55681. * Task name
  55682. */ name: string);
  55683. private _isCompleted;
  55684. private _taskState;
  55685. private _errorObject;
  55686. /**
  55687. * Get if the task is completed
  55688. */
  55689. readonly isCompleted: boolean;
  55690. /**
  55691. * Gets the current state of the task
  55692. */
  55693. readonly taskState: AssetTaskState;
  55694. /**
  55695. * Gets the current error object (if task is in error)
  55696. */
  55697. readonly errorObject: {
  55698. message?: string;
  55699. exception?: any;
  55700. };
  55701. /**
  55702. * Internal only
  55703. * @hidden
  55704. */
  55705. _setErrorObject(message?: string, exception?: any): void;
  55706. /**
  55707. * Execute the current task
  55708. * @param scene defines the scene where you want your assets to be loaded
  55709. * @param onSuccess is a callback called when the task is successfully executed
  55710. * @param onError is a callback called if an error occurs
  55711. */
  55712. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55713. /**
  55714. * Execute the current task
  55715. * @param scene defines the scene where you want your assets to be loaded
  55716. * @param onSuccess is a callback called when the task is successfully executed
  55717. * @param onError is a callback called if an error occurs
  55718. */
  55719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55720. /**
  55721. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55722. * This can be used with failed tasks that have the reason for failure fixed.
  55723. */
  55724. reset(): void;
  55725. private onErrorCallback;
  55726. private onDoneCallback;
  55727. }
  55728. /**
  55729. * Define the interface used by progress events raised during assets loading
  55730. */
  55731. export interface IAssetsProgressEvent {
  55732. /**
  55733. * Defines the number of remaining tasks to process
  55734. */
  55735. remainingCount: number;
  55736. /**
  55737. * Defines the total number of tasks
  55738. */
  55739. totalCount: number;
  55740. /**
  55741. * Defines the task that was just processed
  55742. */
  55743. task: AbstractAssetTask;
  55744. }
  55745. /**
  55746. * Class used to share progress information about assets loading
  55747. */
  55748. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55749. /**
  55750. * Defines the number of remaining tasks to process
  55751. */
  55752. remainingCount: number;
  55753. /**
  55754. * Defines the total number of tasks
  55755. */
  55756. totalCount: number;
  55757. /**
  55758. * Defines the task that was just processed
  55759. */
  55760. task: AbstractAssetTask;
  55761. /**
  55762. * Creates a AssetsProgressEvent
  55763. * @param remainingCount defines the number of remaining tasks to process
  55764. * @param totalCount defines the total number of tasks
  55765. * @param task defines the task that was just processed
  55766. */
  55767. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55768. }
  55769. /**
  55770. * Define a task used by AssetsManager to load meshes
  55771. */
  55772. export class MeshAssetTask extends AbstractAssetTask {
  55773. /**
  55774. * Defines the name of the task
  55775. */
  55776. name: string;
  55777. /**
  55778. * Defines the list of mesh's names you want to load
  55779. */
  55780. meshesNames: any;
  55781. /**
  55782. * Defines the root url to use as a base to load your meshes and associated resources
  55783. */
  55784. rootUrl: string;
  55785. /**
  55786. * Defines the filename of the scene to load from
  55787. */
  55788. sceneFilename: string;
  55789. /**
  55790. * Gets the list of loaded meshes
  55791. */
  55792. loadedMeshes: Array<AbstractMesh>;
  55793. /**
  55794. * Gets the list of loaded particle systems
  55795. */
  55796. loadedParticleSystems: Array<IParticleSystem>;
  55797. /**
  55798. * Gets the list of loaded skeletons
  55799. */
  55800. loadedSkeletons: Array<Skeleton>;
  55801. /**
  55802. * Gets the list of loaded animation groups
  55803. */
  55804. loadedAnimationGroups: Array<AnimationGroup>;
  55805. /**
  55806. * Callback called when the task is successful
  55807. */
  55808. onSuccess: (task: MeshAssetTask) => void;
  55809. /**
  55810. * Callback called when the task is successful
  55811. */
  55812. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55813. /**
  55814. * Creates a new MeshAssetTask
  55815. * @param name defines the name of the task
  55816. * @param meshesNames defines the list of mesh's names you want to load
  55817. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55818. * @param sceneFilename defines the filename of the scene to load from
  55819. */
  55820. constructor(
  55821. /**
  55822. * Defines the name of the task
  55823. */
  55824. name: string,
  55825. /**
  55826. * Defines the list of mesh's names you want to load
  55827. */
  55828. meshesNames: any,
  55829. /**
  55830. * Defines the root url to use as a base to load your meshes and associated resources
  55831. */
  55832. rootUrl: string,
  55833. /**
  55834. * Defines the filename of the scene to load from
  55835. */
  55836. sceneFilename: string);
  55837. /**
  55838. * Execute the current task
  55839. * @param scene defines the scene where you want your assets to be loaded
  55840. * @param onSuccess is a callback called when the task is successfully executed
  55841. * @param onError is a callback called if an error occurs
  55842. */
  55843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55844. }
  55845. /**
  55846. * Define a task used by AssetsManager to load text content
  55847. */
  55848. export class TextFileAssetTask extends AbstractAssetTask {
  55849. /**
  55850. * Defines the name of the task
  55851. */
  55852. name: string;
  55853. /**
  55854. * Defines the location of the file to load
  55855. */
  55856. url: string;
  55857. /**
  55858. * Gets the loaded text string
  55859. */
  55860. text: string;
  55861. /**
  55862. * Callback called when the task is successful
  55863. */
  55864. onSuccess: (task: TextFileAssetTask) => void;
  55865. /**
  55866. * Callback called when the task is successful
  55867. */
  55868. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55869. /**
  55870. * Creates a new TextFileAssetTask object
  55871. * @param name defines the name of the task
  55872. * @param url defines the location of the file to load
  55873. */
  55874. constructor(
  55875. /**
  55876. * Defines the name of the task
  55877. */
  55878. name: string,
  55879. /**
  55880. * Defines the location of the file to load
  55881. */
  55882. url: string);
  55883. /**
  55884. * Execute the current task
  55885. * @param scene defines the scene where you want your assets to be loaded
  55886. * @param onSuccess is a callback called when the task is successfully executed
  55887. * @param onError is a callback called if an error occurs
  55888. */
  55889. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55890. }
  55891. /**
  55892. * Define a task used by AssetsManager to load binary data
  55893. */
  55894. export class BinaryFileAssetTask extends AbstractAssetTask {
  55895. /**
  55896. * Defines the name of the task
  55897. */
  55898. name: string;
  55899. /**
  55900. * Defines the location of the file to load
  55901. */
  55902. url: string;
  55903. /**
  55904. * Gets the lodaded data (as an array buffer)
  55905. */
  55906. data: ArrayBuffer;
  55907. /**
  55908. * Callback called when the task is successful
  55909. */
  55910. onSuccess: (task: BinaryFileAssetTask) => void;
  55911. /**
  55912. * Callback called when the task is successful
  55913. */
  55914. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55915. /**
  55916. * Creates a new BinaryFileAssetTask object
  55917. * @param name defines the name of the new task
  55918. * @param url defines the location of the file to load
  55919. */
  55920. constructor(
  55921. /**
  55922. * Defines the name of the task
  55923. */
  55924. name: string,
  55925. /**
  55926. * Defines the location of the file to load
  55927. */
  55928. url: string);
  55929. /**
  55930. * Execute the current task
  55931. * @param scene defines the scene where you want your assets to be loaded
  55932. * @param onSuccess is a callback called when the task is successfully executed
  55933. * @param onError is a callback called if an error occurs
  55934. */
  55935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55936. }
  55937. /**
  55938. * Define a task used by AssetsManager to load images
  55939. */
  55940. export class ImageAssetTask extends AbstractAssetTask {
  55941. /**
  55942. * Defines the name of the task
  55943. */
  55944. name: string;
  55945. /**
  55946. * Defines the location of the image to load
  55947. */
  55948. url: string;
  55949. /**
  55950. * Gets the loaded images
  55951. */
  55952. image: HTMLImageElement;
  55953. /**
  55954. * Callback called when the task is successful
  55955. */
  55956. onSuccess: (task: ImageAssetTask) => void;
  55957. /**
  55958. * Callback called when the task is successful
  55959. */
  55960. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55961. /**
  55962. * Creates a new ImageAssetTask
  55963. * @param name defines the name of the task
  55964. * @param url defines the location of the image to load
  55965. */
  55966. constructor(
  55967. /**
  55968. * Defines the name of the task
  55969. */
  55970. name: string,
  55971. /**
  55972. * Defines the location of the image to load
  55973. */
  55974. url: string);
  55975. /**
  55976. * Execute the current task
  55977. * @param scene defines the scene where you want your assets to be loaded
  55978. * @param onSuccess is a callback called when the task is successfully executed
  55979. * @param onError is a callback called if an error occurs
  55980. */
  55981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55982. }
  55983. /**
  55984. * Defines the interface used by texture loading tasks
  55985. */
  55986. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55987. /**
  55988. * Gets the loaded texture
  55989. */
  55990. texture: TEX;
  55991. }
  55992. /**
  55993. * Define a task used by AssetsManager to load 2D textures
  55994. */
  55995. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55996. /**
  55997. * Defines the name of the task
  55998. */
  55999. name: string;
  56000. /**
  56001. * Defines the location of the file to load
  56002. */
  56003. url: string;
  56004. /**
  56005. * Defines if mipmap should not be generated (default is false)
  56006. */
  56007. noMipmap?: boolean | undefined;
  56008. /**
  56009. * Defines if texture must be inverted on Y axis (default is false)
  56010. */
  56011. invertY?: boolean | undefined;
  56012. /**
  56013. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56014. */
  56015. samplingMode: number;
  56016. /**
  56017. * Gets the loaded texture
  56018. */
  56019. texture: Texture;
  56020. /**
  56021. * Callback called when the task is successful
  56022. */
  56023. onSuccess: (task: TextureAssetTask) => void;
  56024. /**
  56025. * Callback called when the task is successful
  56026. */
  56027. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56028. /**
  56029. * Creates a new TextureAssetTask object
  56030. * @param name defines the name of the task
  56031. * @param url defines the location of the file to load
  56032. * @param noMipmap defines if mipmap should not be generated (default is false)
  56033. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56034. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56035. */
  56036. constructor(
  56037. /**
  56038. * Defines the name of the task
  56039. */
  56040. name: string,
  56041. /**
  56042. * Defines the location of the file to load
  56043. */
  56044. url: string,
  56045. /**
  56046. * Defines if mipmap should not be generated (default is false)
  56047. */
  56048. noMipmap?: boolean | undefined,
  56049. /**
  56050. * Defines if texture must be inverted on Y axis (default is false)
  56051. */
  56052. invertY?: boolean | undefined,
  56053. /**
  56054. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56055. */
  56056. samplingMode?: number);
  56057. /**
  56058. * Execute the current task
  56059. * @param scene defines the scene where you want your assets to be loaded
  56060. * @param onSuccess is a callback called when the task is successfully executed
  56061. * @param onError is a callback called if an error occurs
  56062. */
  56063. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56064. }
  56065. /**
  56066. * Define a task used by AssetsManager to load cube textures
  56067. */
  56068. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56069. /**
  56070. * Defines the name of the task
  56071. */
  56072. name: string;
  56073. /**
  56074. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56075. */
  56076. url: string;
  56077. /**
  56078. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56079. */
  56080. extensions?: string[] | undefined;
  56081. /**
  56082. * Defines if mipmaps should not be generated (default is false)
  56083. */
  56084. noMipmap?: boolean | undefined;
  56085. /**
  56086. * Defines the explicit list of files (undefined by default)
  56087. */
  56088. files?: string[] | undefined;
  56089. /**
  56090. * Gets the loaded texture
  56091. */
  56092. texture: CubeTexture;
  56093. /**
  56094. * Callback called when the task is successful
  56095. */
  56096. onSuccess: (task: CubeTextureAssetTask) => void;
  56097. /**
  56098. * Callback called when the task is successful
  56099. */
  56100. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56101. /**
  56102. * Creates a new CubeTextureAssetTask
  56103. * @param name defines the name of the task
  56104. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56105. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56106. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56107. * @param files defines the explicit list of files (undefined by default)
  56108. */
  56109. constructor(
  56110. /**
  56111. * Defines the name of the task
  56112. */
  56113. name: string,
  56114. /**
  56115. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56116. */
  56117. url: string,
  56118. /**
  56119. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56120. */
  56121. extensions?: string[] | undefined,
  56122. /**
  56123. * Defines if mipmaps should not be generated (default is false)
  56124. */
  56125. noMipmap?: boolean | undefined,
  56126. /**
  56127. * Defines the explicit list of files (undefined by default)
  56128. */
  56129. files?: string[] | undefined);
  56130. /**
  56131. * Execute the current task
  56132. * @param scene defines the scene where you want your assets to be loaded
  56133. * @param onSuccess is a callback called when the task is successfully executed
  56134. * @param onError is a callback called if an error occurs
  56135. */
  56136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56137. }
  56138. /**
  56139. * Define a task used by AssetsManager to load HDR cube textures
  56140. */
  56141. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56142. /**
  56143. * Defines the name of the task
  56144. */
  56145. name: string;
  56146. /**
  56147. * Defines the location of the file to load
  56148. */
  56149. url: string;
  56150. /**
  56151. * Defines the desired size (the more it increases the longer the generation will be)
  56152. */
  56153. size: number;
  56154. /**
  56155. * Defines if mipmaps should not be generated (default is false)
  56156. */
  56157. noMipmap: boolean;
  56158. /**
  56159. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56160. */
  56161. generateHarmonics: boolean;
  56162. /**
  56163. * 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)
  56164. */
  56165. gammaSpace: boolean;
  56166. /**
  56167. * Internal Use Only
  56168. */
  56169. reserved: boolean;
  56170. /**
  56171. * Gets the loaded texture
  56172. */
  56173. texture: HDRCubeTexture;
  56174. /**
  56175. * Callback called when the task is successful
  56176. */
  56177. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56178. /**
  56179. * Callback called when the task is successful
  56180. */
  56181. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56182. /**
  56183. * Creates a new HDRCubeTextureAssetTask object
  56184. * @param name defines the name of the task
  56185. * @param url defines the location of the file to load
  56186. * @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.
  56187. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56188. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56189. * @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)
  56190. * @param reserved Internal use only
  56191. */
  56192. constructor(
  56193. /**
  56194. * Defines the name of the task
  56195. */
  56196. name: string,
  56197. /**
  56198. * Defines the location of the file to load
  56199. */
  56200. url: string,
  56201. /**
  56202. * Defines the desired size (the more it increases the longer the generation will be)
  56203. */
  56204. size: number,
  56205. /**
  56206. * Defines if mipmaps should not be generated (default is false)
  56207. */
  56208. noMipmap?: boolean,
  56209. /**
  56210. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56211. */
  56212. generateHarmonics?: boolean,
  56213. /**
  56214. * 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)
  56215. */
  56216. gammaSpace?: boolean,
  56217. /**
  56218. * Internal Use Only
  56219. */
  56220. reserved?: boolean);
  56221. /**
  56222. * Execute the current task
  56223. * @param scene defines the scene where you want your assets to be loaded
  56224. * @param onSuccess is a callback called when the task is successfully executed
  56225. * @param onError is a callback called if an error occurs
  56226. */
  56227. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56228. }
  56229. /**
  56230. * This class can be used to easily import assets into a scene
  56231. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56232. */
  56233. export class AssetsManager {
  56234. private _scene;
  56235. private _isLoading;
  56236. protected _tasks: AbstractAssetTask[];
  56237. protected _waitingTasksCount: number;
  56238. protected _totalTasksCount: number;
  56239. /**
  56240. * Callback called when all tasks are processed
  56241. */
  56242. onFinish: (tasks: AbstractAssetTask[]) => void;
  56243. /**
  56244. * Callback called when a task is successful
  56245. */
  56246. onTaskSuccess: (task: AbstractAssetTask) => void;
  56247. /**
  56248. * Callback called when a task had an error
  56249. */
  56250. onTaskError: (task: AbstractAssetTask) => void;
  56251. /**
  56252. * Callback called when a task is done (whatever the result is)
  56253. */
  56254. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56255. /**
  56256. * Observable called when all tasks are processed
  56257. */
  56258. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56259. /**
  56260. * Observable called when a task had an error
  56261. */
  56262. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56263. /**
  56264. * Observable called when all tasks were executed
  56265. */
  56266. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56267. /**
  56268. * Observable called when a task is done (whatever the result is)
  56269. */
  56270. onProgressObservable: Observable<IAssetsProgressEvent>;
  56271. /**
  56272. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56273. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56274. */
  56275. useDefaultLoadingScreen: boolean;
  56276. /**
  56277. * Creates a new AssetsManager
  56278. * @param scene defines the scene to work on
  56279. */
  56280. constructor(scene: Scene);
  56281. /**
  56282. * Add a MeshAssetTask to the list of active tasks
  56283. * @param taskName defines the name of the new task
  56284. * @param meshesNames defines the name of meshes to load
  56285. * @param rootUrl defines the root url to use to locate files
  56286. * @param sceneFilename defines the filename of the scene file
  56287. * @returns a new MeshAssetTask object
  56288. */
  56289. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56290. /**
  56291. * Add a TextFileAssetTask to the list of active tasks
  56292. * @param taskName defines the name of the new task
  56293. * @param url defines the url of the file to load
  56294. * @returns a new TextFileAssetTask object
  56295. */
  56296. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56297. /**
  56298. * Add a BinaryFileAssetTask to the list of active tasks
  56299. * @param taskName defines the name of the new task
  56300. * @param url defines the url of the file to load
  56301. * @returns a new BinaryFileAssetTask object
  56302. */
  56303. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56304. /**
  56305. * Add a ImageAssetTask to the list of active tasks
  56306. * @param taskName defines the name of the new task
  56307. * @param url defines the url of the file to load
  56308. * @returns a new ImageAssetTask object
  56309. */
  56310. addImageTask(taskName: string, url: string): ImageAssetTask;
  56311. /**
  56312. * Add a TextureAssetTask to the list of active tasks
  56313. * @param taskName defines the name of the new task
  56314. * @param url defines the url of the file to load
  56315. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56316. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56317. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56318. * @returns a new TextureAssetTask object
  56319. */
  56320. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56321. /**
  56322. * Add a CubeTextureAssetTask to the list of active tasks
  56323. * @param taskName defines the name of the new task
  56324. * @param url defines the url of the file to load
  56325. * @param extensions defines the extension to use to load the cube map (can be null)
  56326. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56327. * @param files defines the list of files to load (can be null)
  56328. * @returns a new CubeTextureAssetTask object
  56329. */
  56330. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56331. /**
  56332. *
  56333. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56334. * @param taskName defines the name of the new task
  56335. * @param url defines the url of the file to load
  56336. * @param size defines the size you want for the cubemap (can be null)
  56337. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56338. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56339. * @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)
  56340. * @param reserved Internal use only
  56341. * @returns a new HDRCubeTextureAssetTask object
  56342. */
  56343. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56344. /**
  56345. * Remove a task from the assets manager.
  56346. * @param task the task to remove
  56347. */
  56348. removeTask(task: AbstractAssetTask): void;
  56349. private _decreaseWaitingTasksCount;
  56350. private _runTask;
  56351. /**
  56352. * Reset the AssetsManager and remove all tasks
  56353. * @return the current instance of the AssetsManager
  56354. */
  56355. reset(): AssetsManager;
  56356. /**
  56357. * Start the loading process
  56358. * @return the current instance of the AssetsManager
  56359. */
  56360. load(): AssetsManager;
  56361. /**
  56362. * Start the loading process as an async operation
  56363. * @return a promise returning the list of failed tasks
  56364. */
  56365. loadAsync(): Promise<void>;
  56366. }
  56367. }
  56368. declare module "babylonjs/Misc/deferred" {
  56369. /**
  56370. * Wrapper class for promise with external resolve and reject.
  56371. */
  56372. export class Deferred<T> {
  56373. /**
  56374. * The promise associated with this deferred object.
  56375. */
  56376. readonly promise: Promise<T>;
  56377. private _resolve;
  56378. private _reject;
  56379. /**
  56380. * The resolve method of the promise associated with this deferred object.
  56381. */
  56382. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56383. /**
  56384. * The reject method of the promise associated with this deferred object.
  56385. */
  56386. readonly reject: (reason?: any) => void;
  56387. /**
  56388. * Constructor for this deferred object.
  56389. */
  56390. constructor();
  56391. }
  56392. }
  56393. declare module "babylonjs/Misc/meshExploder" {
  56394. import { Mesh } from "babylonjs/Meshes/mesh";
  56395. /**
  56396. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56397. */
  56398. export class MeshExploder {
  56399. private _centerMesh;
  56400. private _meshes;
  56401. private _meshesOrigins;
  56402. private _toCenterVectors;
  56403. private _scaledDirection;
  56404. private _newPosition;
  56405. private _centerPosition;
  56406. /**
  56407. * Explodes meshes from a center mesh.
  56408. * @param meshes The meshes to explode.
  56409. * @param centerMesh The mesh to be center of explosion.
  56410. */
  56411. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  56412. private _setCenterMesh;
  56413. /**
  56414. * Get class name
  56415. * @returns "MeshExploder"
  56416. */
  56417. getClassName(): string;
  56418. /**
  56419. * "Exploded meshes"
  56420. * @returns Array of meshes with the centerMesh at index 0.
  56421. */
  56422. getMeshes(): Array<Mesh>;
  56423. /**
  56424. * Explodes meshes giving a specific direction
  56425. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  56426. */
  56427. explode(direction?: number): void;
  56428. }
  56429. }
  56430. declare module "babylonjs/Misc/filesInput" {
  56431. import { Engine } from "babylonjs/Engines/engine";
  56432. import { Scene } from "babylonjs/scene";
  56433. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56434. /**
  56435. * Class used to help managing file picking and drag'n'drop
  56436. */
  56437. export class FilesInput {
  56438. /**
  56439. * List of files ready to be loaded
  56440. */
  56441. static readonly FilesToLoad: {
  56442. [key: string]: File;
  56443. };
  56444. /**
  56445. * Callback called when a file is processed
  56446. */
  56447. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56448. private _engine;
  56449. private _currentScene;
  56450. private _sceneLoadedCallback;
  56451. private _progressCallback;
  56452. private _additionalRenderLoopLogicCallback;
  56453. private _textureLoadingCallback;
  56454. private _startingProcessingFilesCallback;
  56455. private _onReloadCallback;
  56456. private _errorCallback;
  56457. private _elementToMonitor;
  56458. private _sceneFileToLoad;
  56459. private _filesToLoad;
  56460. /**
  56461. * Creates a new FilesInput
  56462. * @param engine defines the rendering engine
  56463. * @param scene defines the hosting scene
  56464. * @param sceneLoadedCallback callback called when scene is loaded
  56465. * @param progressCallback callback called to track progress
  56466. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56467. * @param textureLoadingCallback callback called when a texture is loading
  56468. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56469. * @param onReloadCallback callback called when a reload is requested
  56470. * @param errorCallback callback call if an error occurs
  56471. */
  56472. 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);
  56473. private _dragEnterHandler;
  56474. private _dragOverHandler;
  56475. private _dropHandler;
  56476. /**
  56477. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56478. * @param elementToMonitor defines the DOM element to track
  56479. */
  56480. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56481. /**
  56482. * Release all associated resources
  56483. */
  56484. dispose(): void;
  56485. private renderFunction;
  56486. private drag;
  56487. private drop;
  56488. private _traverseFolder;
  56489. private _processFiles;
  56490. /**
  56491. * Load files from a drop event
  56492. * @param event defines the drop event to use as source
  56493. */
  56494. loadFiles(event: any): void;
  56495. private _processReload;
  56496. /**
  56497. * Reload the current scene from the loaded files
  56498. */
  56499. reload(): void;
  56500. }
  56501. }
  56502. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56503. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56504. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56505. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56506. }
  56507. declare module "babylonjs/Misc/sceneOptimizer" {
  56508. import { Scene, IDisposable } from "babylonjs/scene";
  56509. import { Observable } from "babylonjs/Misc/observable";
  56510. /**
  56511. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56513. */
  56514. export class SceneOptimization {
  56515. /**
  56516. * Defines the priority of this optimization (0 by default which means first in the list)
  56517. */
  56518. priority: number;
  56519. /**
  56520. * Gets a string describing the action executed by the current optimization
  56521. * @returns description string
  56522. */
  56523. getDescription(): string;
  56524. /**
  56525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56526. * @param scene defines the current scene where to apply this optimization
  56527. * @param optimizer defines the current optimizer
  56528. * @returns true if everything that can be done was applied
  56529. */
  56530. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56531. /**
  56532. * Creates the SceneOptimization object
  56533. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56534. * @param desc defines the description associated with the optimization
  56535. */
  56536. constructor(
  56537. /**
  56538. * Defines the priority of this optimization (0 by default which means first in the list)
  56539. */
  56540. priority?: number);
  56541. }
  56542. /**
  56543. * Defines an optimization used to reduce the size of render target textures
  56544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56545. */
  56546. export class TextureOptimization extends SceneOptimization {
  56547. /**
  56548. * Defines the priority of this optimization (0 by default which means first in the list)
  56549. */
  56550. priority: number;
  56551. /**
  56552. * 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
  56553. */
  56554. maximumSize: number;
  56555. /**
  56556. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56557. */
  56558. step: number;
  56559. /**
  56560. * Gets a string describing the action executed by the current optimization
  56561. * @returns description string
  56562. */
  56563. getDescription(): string;
  56564. /**
  56565. * Creates the TextureOptimization object
  56566. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56567. * @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
  56568. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56569. */
  56570. constructor(
  56571. /**
  56572. * Defines the priority of this optimization (0 by default which means first in the list)
  56573. */
  56574. priority?: number,
  56575. /**
  56576. * 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
  56577. */
  56578. maximumSize?: number,
  56579. /**
  56580. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56581. */
  56582. step?: number);
  56583. /**
  56584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56585. * @param scene defines the current scene where to apply this optimization
  56586. * @param optimizer defines the current optimizer
  56587. * @returns true if everything that can be done was applied
  56588. */
  56589. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56590. }
  56591. /**
  56592. * Defines an optimization used to increase or decrease the rendering resolution
  56593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56594. */
  56595. export class HardwareScalingOptimization extends SceneOptimization {
  56596. /**
  56597. * Defines the priority of this optimization (0 by default which means first in the list)
  56598. */
  56599. priority: number;
  56600. /**
  56601. * Defines the maximum scale to use (2 by default)
  56602. */
  56603. maximumScale: number;
  56604. /**
  56605. * Defines the step to use between two passes (0.5 by default)
  56606. */
  56607. step: number;
  56608. private _currentScale;
  56609. private _directionOffset;
  56610. /**
  56611. * Gets a string describing the action executed by the current optimization
  56612. * @return description string
  56613. */
  56614. getDescription(): string;
  56615. /**
  56616. * Creates the HardwareScalingOptimization object
  56617. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56618. * @param maximumScale defines the maximum scale to use (2 by default)
  56619. * @param step defines the step to use between two passes (0.5 by default)
  56620. */
  56621. constructor(
  56622. /**
  56623. * Defines the priority of this optimization (0 by default which means first in the list)
  56624. */
  56625. priority?: number,
  56626. /**
  56627. * Defines the maximum scale to use (2 by default)
  56628. */
  56629. maximumScale?: number,
  56630. /**
  56631. * Defines the step to use between two passes (0.5 by default)
  56632. */
  56633. step?: number);
  56634. /**
  56635. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56636. * @param scene defines the current scene where to apply this optimization
  56637. * @param optimizer defines the current optimizer
  56638. * @returns true if everything that can be done was applied
  56639. */
  56640. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56641. }
  56642. /**
  56643. * Defines an optimization used to remove shadows
  56644. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56645. */
  56646. export class ShadowsOptimization extends SceneOptimization {
  56647. /**
  56648. * Gets a string describing the action executed by the current optimization
  56649. * @return description string
  56650. */
  56651. getDescription(): string;
  56652. /**
  56653. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56654. * @param scene defines the current scene where to apply this optimization
  56655. * @param optimizer defines the current optimizer
  56656. * @returns true if everything that can be done was applied
  56657. */
  56658. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56659. }
  56660. /**
  56661. * Defines an optimization used to turn post-processes off
  56662. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56663. */
  56664. export class PostProcessesOptimization extends SceneOptimization {
  56665. /**
  56666. * Gets a string describing the action executed by the current optimization
  56667. * @return description string
  56668. */
  56669. getDescription(): string;
  56670. /**
  56671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56672. * @param scene defines the current scene where to apply this optimization
  56673. * @param optimizer defines the current optimizer
  56674. * @returns true if everything that can be done was applied
  56675. */
  56676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56677. }
  56678. /**
  56679. * Defines an optimization used to turn lens flares off
  56680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56681. */
  56682. export class LensFlaresOptimization extends SceneOptimization {
  56683. /**
  56684. * Gets a string describing the action executed by the current optimization
  56685. * @return description string
  56686. */
  56687. getDescription(): string;
  56688. /**
  56689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56690. * @param scene defines the current scene where to apply this optimization
  56691. * @param optimizer defines the current optimizer
  56692. * @returns true if everything that can be done was applied
  56693. */
  56694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56695. }
  56696. /**
  56697. * Defines an optimization based on user defined callback.
  56698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56699. */
  56700. export class CustomOptimization extends SceneOptimization {
  56701. /**
  56702. * Callback called to apply the custom optimization.
  56703. */
  56704. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56705. /**
  56706. * Callback called to get custom description
  56707. */
  56708. onGetDescription: () => string;
  56709. /**
  56710. * Gets a string describing the action executed by the current optimization
  56711. * @returns description string
  56712. */
  56713. getDescription(): string;
  56714. /**
  56715. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56716. * @param scene defines the current scene where to apply this optimization
  56717. * @param optimizer defines the current optimizer
  56718. * @returns true if everything that can be done was applied
  56719. */
  56720. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56721. }
  56722. /**
  56723. * Defines an optimization used to turn particles off
  56724. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56725. */
  56726. export class ParticlesOptimization extends SceneOptimization {
  56727. /**
  56728. * Gets a string describing the action executed by the current optimization
  56729. * @return description string
  56730. */
  56731. getDescription(): string;
  56732. /**
  56733. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56734. * @param scene defines the current scene where to apply this optimization
  56735. * @param optimizer defines the current optimizer
  56736. * @returns true if everything that can be done was applied
  56737. */
  56738. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56739. }
  56740. /**
  56741. * Defines an optimization used to turn render targets off
  56742. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56743. */
  56744. export class RenderTargetsOptimization extends SceneOptimization {
  56745. /**
  56746. * Gets a string describing the action executed by the current optimization
  56747. * @return description string
  56748. */
  56749. getDescription(): string;
  56750. /**
  56751. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56752. * @param scene defines the current scene where to apply this optimization
  56753. * @param optimizer defines the current optimizer
  56754. * @returns true if everything that can be done was applied
  56755. */
  56756. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56757. }
  56758. /**
  56759. * Defines an optimization used to merge meshes with compatible materials
  56760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56761. */
  56762. export class MergeMeshesOptimization extends SceneOptimization {
  56763. private static _UpdateSelectionTree;
  56764. /**
  56765. * Gets or sets a boolean which defines if optimization octree has to be updated
  56766. */
  56767. /**
  56768. * Gets or sets a boolean which defines if optimization octree has to be updated
  56769. */
  56770. static UpdateSelectionTree: boolean;
  56771. /**
  56772. * Gets a string describing the action executed by the current optimization
  56773. * @return description string
  56774. */
  56775. getDescription(): string;
  56776. private _canBeMerged;
  56777. /**
  56778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56779. * @param scene defines the current scene where to apply this optimization
  56780. * @param optimizer defines the current optimizer
  56781. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56782. * @returns true if everything that can be done was applied
  56783. */
  56784. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56785. }
  56786. /**
  56787. * Defines a list of options used by SceneOptimizer
  56788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56789. */
  56790. export class SceneOptimizerOptions {
  56791. /**
  56792. * Defines the target frame rate to reach (60 by default)
  56793. */
  56794. targetFrameRate: number;
  56795. /**
  56796. * Defines the interval between two checkes (2000ms by default)
  56797. */
  56798. trackerDuration: number;
  56799. /**
  56800. * Gets the list of optimizations to apply
  56801. */
  56802. optimizations: SceneOptimization[];
  56803. /**
  56804. * Creates a new list of options used by SceneOptimizer
  56805. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56806. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56807. */
  56808. constructor(
  56809. /**
  56810. * Defines the target frame rate to reach (60 by default)
  56811. */
  56812. targetFrameRate?: number,
  56813. /**
  56814. * Defines the interval between two checkes (2000ms by default)
  56815. */
  56816. trackerDuration?: number);
  56817. /**
  56818. * Add a new optimization
  56819. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56820. * @returns the current SceneOptimizerOptions
  56821. */
  56822. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56823. /**
  56824. * Add a new custom optimization
  56825. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56826. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56827. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56828. * @returns the current SceneOptimizerOptions
  56829. */
  56830. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56831. /**
  56832. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56833. * @param targetFrameRate defines the target frame rate (60 by default)
  56834. * @returns a SceneOptimizerOptions object
  56835. */
  56836. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56837. /**
  56838. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56839. * @param targetFrameRate defines the target frame rate (60 by default)
  56840. * @returns a SceneOptimizerOptions object
  56841. */
  56842. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56843. /**
  56844. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56845. * @param targetFrameRate defines the target frame rate (60 by default)
  56846. * @returns a SceneOptimizerOptions object
  56847. */
  56848. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56849. }
  56850. /**
  56851. * Class used to run optimizations in order to reach a target frame rate
  56852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56853. */
  56854. export class SceneOptimizer implements IDisposable {
  56855. private _isRunning;
  56856. private _options;
  56857. private _scene;
  56858. private _currentPriorityLevel;
  56859. private _targetFrameRate;
  56860. private _trackerDuration;
  56861. private _currentFrameRate;
  56862. private _sceneDisposeObserver;
  56863. private _improvementMode;
  56864. /**
  56865. * Defines an observable called when the optimizer reaches the target frame rate
  56866. */
  56867. onSuccessObservable: Observable<SceneOptimizer>;
  56868. /**
  56869. * Defines an observable called when the optimizer enables an optimization
  56870. */
  56871. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56872. /**
  56873. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56874. */
  56875. onFailureObservable: Observable<SceneOptimizer>;
  56876. /**
  56877. * Gets a boolean indicating if the optimizer is in improvement mode
  56878. */
  56879. readonly isInImprovementMode: boolean;
  56880. /**
  56881. * Gets the current priority level (0 at start)
  56882. */
  56883. readonly currentPriorityLevel: number;
  56884. /**
  56885. * Gets the current frame rate checked by the SceneOptimizer
  56886. */
  56887. readonly currentFrameRate: number;
  56888. /**
  56889. * Gets or sets the current target frame rate (60 by default)
  56890. */
  56891. /**
  56892. * Gets or sets the current target frame rate (60 by default)
  56893. */
  56894. targetFrameRate: number;
  56895. /**
  56896. * Gets or sets the current interval between two checks (every 2000ms by default)
  56897. */
  56898. /**
  56899. * Gets or sets the current interval between two checks (every 2000ms by default)
  56900. */
  56901. trackerDuration: number;
  56902. /**
  56903. * Gets the list of active optimizations
  56904. */
  56905. readonly optimizations: SceneOptimization[];
  56906. /**
  56907. * Creates a new SceneOptimizer
  56908. * @param scene defines the scene to work on
  56909. * @param options defines the options to use with the SceneOptimizer
  56910. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56911. * @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)
  56912. */
  56913. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56914. /**
  56915. * Stops the current optimizer
  56916. */
  56917. stop(): void;
  56918. /**
  56919. * Reset the optimizer to initial step (current priority level = 0)
  56920. */
  56921. reset(): void;
  56922. /**
  56923. * Start the optimizer. By default it will try to reach a specific framerate
  56924. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56925. */
  56926. start(): void;
  56927. private _checkCurrentState;
  56928. /**
  56929. * Release all resources
  56930. */
  56931. dispose(): void;
  56932. /**
  56933. * Helper function to create a SceneOptimizer with one single line of code
  56934. * @param scene defines the scene to work on
  56935. * @param options defines the options to use with the SceneOptimizer
  56936. * @param onSuccess defines a callback to call on success
  56937. * @param onFailure defines a callback to call on failure
  56938. * @returns the new SceneOptimizer object
  56939. */
  56940. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56941. }
  56942. }
  56943. declare module "babylonjs/Misc/sceneSerializer" {
  56944. import { Scene } from "babylonjs/scene";
  56945. /**
  56946. * Class used to serialize a scene into a string
  56947. */
  56948. export class SceneSerializer {
  56949. /**
  56950. * Clear cache used by a previous serialization
  56951. */
  56952. static ClearCache(): void;
  56953. /**
  56954. * Serialize a scene into a JSON compatible object
  56955. * @param scene defines the scene to serialize
  56956. * @returns a JSON compatible object
  56957. */
  56958. static Serialize(scene: Scene): any;
  56959. /**
  56960. * Serialize a mesh into a JSON compatible object
  56961. * @param toSerialize defines the mesh to serialize
  56962. * @param withParents defines if parents must be serialized as well
  56963. * @param withChildren defines if children must be serialized as well
  56964. * @returns a JSON compatible object
  56965. */
  56966. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56967. }
  56968. }
  56969. declare module "babylonjs/Misc/videoRecorder" {
  56970. import { Nullable } from "babylonjs/types";
  56971. import { Engine } from "babylonjs/Engines/engine";
  56972. /**
  56973. * This represents the different options avilable for the video capture.
  56974. */
  56975. export interface VideoRecorderOptions {
  56976. /** Defines the mime type of the video */
  56977. mimeType: string;
  56978. /** Defines the video the video should be recorded at */
  56979. fps: number;
  56980. /** Defines the chunk size for the recording data */
  56981. recordChunckSize: number;
  56982. /** The audio tracks to attach to the record */
  56983. audioTracks?: MediaStreamTrack[];
  56984. }
  56985. /**
  56986. * This can helps recording videos from BabylonJS.
  56987. * This is based on the available WebRTC functionalities of the browser.
  56988. *
  56989. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56990. */
  56991. export class VideoRecorder {
  56992. private static readonly _defaultOptions;
  56993. /**
  56994. * Returns wehther or not the VideoRecorder is available in your browser.
  56995. * @param engine Defines the Babylon Engine to check the support for
  56996. * @returns true if supported otherwise false
  56997. */
  56998. static IsSupported(engine: Engine): boolean;
  56999. private readonly _options;
  57000. private _canvas;
  57001. private _mediaRecorder;
  57002. private _recordedChunks;
  57003. private _fileName;
  57004. private _resolve;
  57005. private _reject;
  57006. /**
  57007. * True wether a recording is already in progress.
  57008. */
  57009. readonly isRecording: boolean;
  57010. /**
  57011. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57012. * a video file.
  57013. * @param engine Defines the BabylonJS Engine you wish to record
  57014. * @param options Defines options that can be used to customized the capture
  57015. */
  57016. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57017. /**
  57018. * Stops the current recording before the default capture timeout passed in the startRecording
  57019. * functions.
  57020. */
  57021. stopRecording(): void;
  57022. /**
  57023. * Starts recording the canvas for a max duration specified in parameters.
  57024. * @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.
  57025. * @param maxDuration Defines the maximum recording time in seconds.
  57026. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57027. * @return a promise callback at the end of the recording with the video data in Blob.
  57028. */
  57029. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57030. /**
  57031. * Releases internal resources used during the recording.
  57032. */
  57033. dispose(): void;
  57034. private _handleDataAvailable;
  57035. private _handleError;
  57036. private _handleStop;
  57037. }
  57038. }
  57039. declare module "babylonjs/Misc/workerPool" {
  57040. import { IDisposable } from "babylonjs/scene";
  57041. /**
  57042. * Helper class to push actions to a pool of workers.
  57043. */
  57044. export class WorkerPool implements IDisposable {
  57045. private _workerInfos;
  57046. private _pendingActions;
  57047. /**
  57048. * Constructor
  57049. * @param workers Array of workers to use for actions
  57050. */
  57051. constructor(workers: Array<Worker>);
  57052. /**
  57053. * Terminates all workers and clears any pending actions.
  57054. */
  57055. dispose(): void;
  57056. /**
  57057. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57058. * pended until a worker has completed its action.
  57059. * @param action The action to perform. Call onComplete when the action is complete.
  57060. */
  57061. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57062. private _execute;
  57063. }
  57064. }
  57065. declare module "babylonjs/Misc/screenshotTools" {
  57066. import { Camera } from "babylonjs/Cameras/camera";
  57067. import { Engine } from "babylonjs/Engines/engine";
  57068. /**
  57069. * Class containing a set of static utilities functions for screenshots
  57070. */
  57071. export class ScreenshotTools {
  57072. /**
  57073. * Captures a screenshot of the current rendering
  57074. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57075. * @param engine defines the rendering engine
  57076. * @param camera defines the source camera
  57077. * @param size This parameter can be set to a single number or to an object with the
  57078. * following (optional) properties: precision, width, height. If a single number is passed,
  57079. * it will be used for both width and height. If an object is passed, the screenshot size
  57080. * will be derived from the parameters. The precision property is a multiplier allowing
  57081. * rendering at a higher or lower resolution
  57082. * @param successCallback defines the callback receives a single parameter which contains the
  57083. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57084. * src parameter of an <img> to display it
  57085. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57086. * Check your browser for supported MIME types
  57087. */
  57088. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57089. /**
  57090. * Generates an image screenshot from the specified camera.
  57091. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57092. * @param engine The engine to use for rendering
  57093. * @param camera The camera to use for rendering
  57094. * @param size This parameter can be set to a single number or to an object with the
  57095. * following (optional) properties: precision, width, height. If a single number is passed,
  57096. * it will be used for both width and height. If an object is passed, the screenshot size
  57097. * will be derived from the parameters. The precision property is a multiplier allowing
  57098. * rendering at a higher or lower resolution
  57099. * @param successCallback The callback receives a single parameter which contains the
  57100. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57101. * src parameter of an <img> to display it
  57102. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57103. * Check your browser for supported MIME types
  57104. * @param samples Texture samples (default: 1)
  57105. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57106. * @param fileName A name for for the downloaded file.
  57107. */
  57108. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57109. }
  57110. }
  57111. declare module "babylonjs/Misc/index" {
  57112. export * from "babylonjs/Misc/andOrNotEvaluator";
  57113. export * from "babylonjs/Misc/assetsManager";
  57114. export * from "babylonjs/Misc/dds";
  57115. export * from "babylonjs/Misc/decorators";
  57116. export * from "babylonjs/Misc/deferred";
  57117. export * from "babylonjs/Misc/environmentTextureTools";
  57118. export * from "babylonjs/Misc/meshExploder";
  57119. export * from "babylonjs/Misc/filesInput";
  57120. export * from "babylonjs/Misc/HighDynamicRange/index";
  57121. export * from "babylonjs/Misc/khronosTextureContainer";
  57122. export * from "babylonjs/Misc/observable";
  57123. export * from "babylonjs/Misc/performanceMonitor";
  57124. export * from "babylonjs/Misc/promise";
  57125. export * from "babylonjs/Misc/sceneOptimizer";
  57126. export * from "babylonjs/Misc/sceneSerializer";
  57127. export * from "babylonjs/Misc/smartArray";
  57128. export * from "babylonjs/Misc/stringDictionary";
  57129. export * from "babylonjs/Misc/tags";
  57130. export * from "babylonjs/Misc/textureTools";
  57131. export * from "babylonjs/Misc/tga";
  57132. export * from "babylonjs/Misc/tools";
  57133. export * from "babylonjs/Misc/videoRecorder";
  57134. export * from "babylonjs/Misc/virtualJoystick";
  57135. export * from "babylonjs/Misc/workerPool";
  57136. export * from "babylonjs/Misc/logger";
  57137. export * from "babylonjs/Misc/typeStore";
  57138. export * from "babylonjs/Misc/filesInputStore";
  57139. export * from "babylonjs/Misc/deepCopier";
  57140. export * from "babylonjs/Misc/pivotTools";
  57141. export * from "babylonjs/Misc/precisionDate";
  57142. export * from "babylonjs/Misc/screenshotTools";
  57143. export * from "babylonjs/Misc/typeStore";
  57144. export * from "babylonjs/Misc/webRequest";
  57145. }
  57146. declare module "babylonjs/index" {
  57147. export * from "babylonjs/abstractScene";
  57148. export * from "babylonjs/Actions/index";
  57149. export * from "babylonjs/Animations/index";
  57150. export * from "babylonjs/assetContainer";
  57151. export * from "babylonjs/Audio/index";
  57152. export * from "babylonjs/Behaviors/index";
  57153. export * from "babylonjs/Bones/index";
  57154. export * from "babylonjs/Cameras/index";
  57155. export * from "babylonjs/Collisions/index";
  57156. export * from "babylonjs/Culling/index";
  57157. export * from "babylonjs/Debug/index";
  57158. export * from "babylonjs/Engines/index";
  57159. export * from "babylonjs/Events/index";
  57160. export * from "babylonjs/Gamepads/index";
  57161. export * from "babylonjs/Gizmos/index";
  57162. export * from "babylonjs/Helpers/index";
  57163. export * from "babylonjs/Instrumentation/index";
  57164. export * from "babylonjs/Layers/index";
  57165. export * from "babylonjs/LensFlares/index";
  57166. export * from "babylonjs/Lights/index";
  57167. export * from "babylonjs/Loading/index";
  57168. export * from "babylonjs/Materials/index";
  57169. export * from "babylonjs/Maths/index";
  57170. export * from "babylonjs/Meshes/index";
  57171. export * from "babylonjs/Morph/index";
  57172. export * from "babylonjs/node";
  57173. export * from "babylonjs/Offline/index";
  57174. export * from "babylonjs/Particles/index";
  57175. export * from "babylonjs/Physics/index";
  57176. export * from "babylonjs/PostProcesses/index";
  57177. export * from "babylonjs/Probes/index";
  57178. export * from "babylonjs/Rendering/index";
  57179. export * from "babylonjs/scene";
  57180. export * from "babylonjs/sceneComponent";
  57181. export * from "babylonjs/Sprites/index";
  57182. export * from "babylonjs/States/index";
  57183. export * from "babylonjs/Misc/index";
  57184. export * from "babylonjs/types";
  57185. }
  57186. declare module "babylonjs/Animations/pathCursor" {
  57187. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57188. /**
  57189. * A cursor which tracks a point on a path
  57190. */
  57191. export class PathCursor {
  57192. private path;
  57193. /**
  57194. * Stores path cursor callbacks for when an onchange event is triggered
  57195. */
  57196. private _onchange;
  57197. /**
  57198. * The value of the path cursor
  57199. */
  57200. value: number;
  57201. /**
  57202. * The animation array of the path cursor
  57203. */
  57204. animations: Animation[];
  57205. /**
  57206. * Initializes the path cursor
  57207. * @param path The path to track
  57208. */
  57209. constructor(path: Path2);
  57210. /**
  57211. * Gets the cursor point on the path
  57212. * @returns A point on the path cursor at the cursor location
  57213. */
  57214. getPoint(): Vector3;
  57215. /**
  57216. * Moves the cursor ahead by the step amount
  57217. * @param step The amount to move the cursor forward
  57218. * @returns This path cursor
  57219. */
  57220. moveAhead(step?: number): PathCursor;
  57221. /**
  57222. * Moves the cursor behind by the step amount
  57223. * @param step The amount to move the cursor back
  57224. * @returns This path cursor
  57225. */
  57226. moveBack(step?: number): PathCursor;
  57227. /**
  57228. * Moves the cursor by the step amount
  57229. * If the step amount is greater than one, an exception is thrown
  57230. * @param step The amount to move the cursor
  57231. * @returns This path cursor
  57232. */
  57233. move(step: number): PathCursor;
  57234. /**
  57235. * Ensures that the value is limited between zero and one
  57236. * @returns This path cursor
  57237. */
  57238. private ensureLimits;
  57239. /**
  57240. * Runs onchange callbacks on change (used by the animation engine)
  57241. * @returns This path cursor
  57242. */
  57243. private raiseOnChange;
  57244. /**
  57245. * Executes a function on change
  57246. * @param f A path cursor onchange callback
  57247. * @returns This path cursor
  57248. */
  57249. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57250. }
  57251. }
  57252. declare module "babylonjs/Legacy/legacy" {
  57253. import * as Babylon from "babylonjs/index";
  57254. export * from "babylonjs/index";
  57255. }
  57256. declare module "babylonjs/Shaders/blur.fragment" {
  57257. /** @hidden */
  57258. export var blurPixelShader: {
  57259. name: string;
  57260. shader: string;
  57261. };
  57262. }
  57263. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57264. /** @hidden */
  57265. export var bones300Declaration: {
  57266. name: string;
  57267. shader: string;
  57268. };
  57269. }
  57270. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57271. /** @hidden */
  57272. export var instances300Declaration: {
  57273. name: string;
  57274. shader: string;
  57275. };
  57276. }
  57277. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57278. /** @hidden */
  57279. export var pointCloudVertexDeclaration: {
  57280. name: string;
  57281. shader: string;
  57282. };
  57283. }
  57284. // Mixins
  57285. interface Window {
  57286. mozIndexedDB: IDBFactory;
  57287. webkitIndexedDB: IDBFactory;
  57288. msIndexedDB: IDBFactory;
  57289. webkitURL: typeof URL;
  57290. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57291. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57292. WebGLRenderingContext: WebGLRenderingContext;
  57293. MSGesture: MSGesture;
  57294. CANNON: any;
  57295. AudioContext: AudioContext;
  57296. webkitAudioContext: AudioContext;
  57297. PointerEvent: any;
  57298. Math: Math;
  57299. Uint8Array: Uint8ArrayConstructor;
  57300. Float32Array: Float32ArrayConstructor;
  57301. mozURL: typeof URL;
  57302. msURL: typeof URL;
  57303. VRFrameData: any; // WebVR, from specs 1.1
  57304. DracoDecoderModule: any;
  57305. setImmediate(handler: (...args: any[]) => void): number;
  57306. }
  57307. interface HTMLCanvasElement {
  57308. requestPointerLock(): void;
  57309. msRequestPointerLock?(): void;
  57310. mozRequestPointerLock?(): void;
  57311. webkitRequestPointerLock?(): void;
  57312. /** Track wether a record is in progress */
  57313. isRecording: boolean;
  57314. /** Capture Stream method defined by some browsers */
  57315. captureStream(fps?: number): MediaStream;
  57316. }
  57317. interface CanvasRenderingContext2D {
  57318. msImageSmoothingEnabled: boolean;
  57319. }
  57320. interface MouseEvent {
  57321. mozMovementX: number;
  57322. mozMovementY: number;
  57323. webkitMovementX: number;
  57324. webkitMovementY: number;
  57325. msMovementX: number;
  57326. msMovementY: number;
  57327. }
  57328. interface Navigator {
  57329. mozGetVRDevices: (any: any) => any;
  57330. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57331. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57332. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57333. webkitGetGamepads(): Gamepad[];
  57334. msGetGamepads(): Gamepad[];
  57335. webkitGamepads(): Gamepad[];
  57336. }
  57337. interface HTMLVideoElement {
  57338. mozSrcObject: any;
  57339. }
  57340. interface Math {
  57341. fround(x: number): number;
  57342. imul(a: number, b: number): number;
  57343. }
  57344. interface WebGLProgram {
  57345. context?: WebGLRenderingContext;
  57346. vertexShader?: WebGLShader;
  57347. fragmentShader?: WebGLShader;
  57348. isParallelCompiled: boolean;
  57349. onCompiled?: () => void;
  57350. }
  57351. interface WebGLRenderingContext {
  57352. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57353. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57354. vertexAttribDivisor(index: number, divisor: number): void;
  57355. createVertexArray(): any;
  57356. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57357. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57358. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57359. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57360. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57361. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57362. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57363. // Queries
  57364. createQuery(): WebGLQuery;
  57365. deleteQuery(query: WebGLQuery): void;
  57366. beginQuery(target: number, query: WebGLQuery): void;
  57367. endQuery(target: number): void;
  57368. getQueryParameter(query: WebGLQuery, pname: number): any;
  57369. getQuery(target: number, pname: number): any;
  57370. MAX_SAMPLES: number;
  57371. RGBA8: number;
  57372. READ_FRAMEBUFFER: number;
  57373. DRAW_FRAMEBUFFER: number;
  57374. UNIFORM_BUFFER: number;
  57375. HALF_FLOAT_OES: number;
  57376. RGBA16F: number;
  57377. RGBA32F: number;
  57378. R32F: number;
  57379. RG32F: number;
  57380. RGB32F: number;
  57381. R16F: number;
  57382. RG16F: number;
  57383. RGB16F: number;
  57384. RED: number;
  57385. RG: number;
  57386. R8: number;
  57387. RG8: number;
  57388. UNSIGNED_INT_24_8: number;
  57389. DEPTH24_STENCIL8: number;
  57390. /* Multiple Render Targets */
  57391. drawBuffers(buffers: number[]): void;
  57392. readBuffer(src: number): void;
  57393. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57394. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57395. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57396. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57397. // Occlusion Query
  57398. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57399. ANY_SAMPLES_PASSED: number;
  57400. QUERY_RESULT_AVAILABLE: number;
  57401. QUERY_RESULT: number;
  57402. }
  57403. interface WebGLBuffer {
  57404. references: number;
  57405. capacity: number;
  57406. is32Bits: boolean;
  57407. }
  57408. interface WebGLProgram {
  57409. transformFeedback?: WebGLTransformFeedback | null;
  57410. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57411. }
  57412. interface EXT_disjoint_timer_query {
  57413. QUERY_COUNTER_BITS_EXT: number;
  57414. TIME_ELAPSED_EXT: number;
  57415. TIMESTAMP_EXT: number;
  57416. GPU_DISJOINT_EXT: number;
  57417. QUERY_RESULT_EXT: number;
  57418. QUERY_RESULT_AVAILABLE_EXT: number;
  57419. queryCounterEXT(query: WebGLQuery, target: number): void;
  57420. createQueryEXT(): WebGLQuery;
  57421. beginQueryEXT(target: number, query: WebGLQuery): void;
  57422. endQueryEXT(target: number): void;
  57423. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57424. deleteQueryEXT(query: WebGLQuery): void;
  57425. }
  57426. interface WebGLUniformLocation {
  57427. _currentState: any;
  57428. }
  57429. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57430. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57431. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57432. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57433. interface WebGLRenderingContext {
  57434. readonly RASTERIZER_DISCARD: number;
  57435. readonly DEPTH_COMPONENT24: number;
  57436. readonly TEXTURE_3D: number;
  57437. readonly TEXTURE_2D_ARRAY: number;
  57438. readonly TEXTURE_COMPARE_FUNC: number;
  57439. readonly TEXTURE_COMPARE_MODE: number;
  57440. readonly COMPARE_REF_TO_TEXTURE: number;
  57441. readonly TEXTURE_WRAP_R: number;
  57442. readonly HALF_FLOAT: number;
  57443. readonly RGB8: number;
  57444. readonly RED_INTEGER: number;
  57445. readonly RG_INTEGER: number;
  57446. readonly RGB_INTEGER: number;
  57447. readonly RGBA_INTEGER: number;
  57448. readonly R8_SNORM: number;
  57449. readonly RG8_SNORM: number;
  57450. readonly RGB8_SNORM: number;
  57451. readonly RGBA8_SNORM: number;
  57452. readonly R8I: number;
  57453. readonly RG8I: number;
  57454. readonly RGB8I: number;
  57455. readonly RGBA8I: number;
  57456. readonly R8UI: number;
  57457. readonly RG8UI: number;
  57458. readonly RGB8UI: number;
  57459. readonly RGBA8UI: number;
  57460. readonly R16I: number;
  57461. readonly RG16I: number;
  57462. readonly RGB16I: number;
  57463. readonly RGBA16I: number;
  57464. readonly R16UI: number;
  57465. readonly RG16UI: number;
  57466. readonly RGB16UI: number;
  57467. readonly RGBA16UI: number;
  57468. readonly R32I: number;
  57469. readonly RG32I: number;
  57470. readonly RGB32I: number;
  57471. readonly RGBA32I: number;
  57472. readonly R32UI: number;
  57473. readonly RG32UI: number;
  57474. readonly RGB32UI: number;
  57475. readonly RGBA32UI: number;
  57476. readonly RGB10_A2UI: number;
  57477. readonly R11F_G11F_B10F: number;
  57478. readonly RGB9_E5: number;
  57479. readonly RGB10_A2: number;
  57480. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57481. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57482. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57483. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57484. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57485. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57486. 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;
  57487. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57488. readonly TRANSFORM_FEEDBACK: number;
  57489. readonly INTERLEAVED_ATTRIBS: number;
  57490. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57491. createTransformFeedback(): WebGLTransformFeedback;
  57492. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57493. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57494. beginTransformFeedback(primitiveMode: number): void;
  57495. endTransformFeedback(): void;
  57496. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57497. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57498. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57499. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57500. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57501. }
  57502. interface ImageBitmap {
  57503. readonly width: number;
  57504. readonly height: number;
  57505. close(): void;
  57506. }
  57507. interface WebGLQuery extends WebGLObject {
  57508. }
  57509. declare var WebGLQuery: {
  57510. prototype: WebGLQuery;
  57511. new(): WebGLQuery;
  57512. };
  57513. interface WebGLSampler extends WebGLObject {
  57514. }
  57515. declare var WebGLSampler: {
  57516. prototype: WebGLSampler;
  57517. new(): WebGLSampler;
  57518. };
  57519. interface WebGLSync extends WebGLObject {
  57520. }
  57521. declare var WebGLSync: {
  57522. prototype: WebGLSync;
  57523. new(): WebGLSync;
  57524. };
  57525. interface WebGLTransformFeedback extends WebGLObject {
  57526. }
  57527. declare var WebGLTransformFeedback: {
  57528. prototype: WebGLTransformFeedback;
  57529. new(): WebGLTransformFeedback;
  57530. };
  57531. interface WebGLVertexArrayObject extends WebGLObject {
  57532. }
  57533. declare var WebGLVertexArrayObject: {
  57534. prototype: WebGLVertexArrayObject;
  57535. new(): WebGLVertexArrayObject;
  57536. };
  57537. // Type definitions for WebVR API
  57538. // Project: https://w3c.github.io/webvr/
  57539. // Definitions by: six a <https://github.com/lostfictions>
  57540. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57541. interface VRDisplay extends EventTarget {
  57542. /**
  57543. * Dictionary of capabilities describing the VRDisplay.
  57544. */
  57545. readonly capabilities: VRDisplayCapabilities;
  57546. /**
  57547. * z-depth defining the far plane of the eye view frustum
  57548. * enables mapping of values in the render target depth
  57549. * attachment to scene coordinates. Initially set to 10000.0.
  57550. */
  57551. depthFar: number;
  57552. /**
  57553. * z-depth defining the near plane of the eye view frustum
  57554. * enables mapping of values in the render target depth
  57555. * attachment to scene coordinates. Initially set to 0.01.
  57556. */
  57557. depthNear: number;
  57558. /**
  57559. * An identifier for this distinct VRDisplay. Used as an
  57560. * association point in the Gamepad API.
  57561. */
  57562. readonly displayId: number;
  57563. /**
  57564. * A display name, a user-readable name identifying it.
  57565. */
  57566. readonly displayName: string;
  57567. readonly isConnected: boolean;
  57568. readonly isPresenting: boolean;
  57569. /**
  57570. * If this VRDisplay supports room-scale experiences, the optional
  57571. * stage attribute contains details on the room-scale parameters.
  57572. */
  57573. readonly stageParameters: VRStageParameters | null;
  57574. /**
  57575. * Passing the value returned by `requestAnimationFrame` to
  57576. * `cancelAnimationFrame` will unregister the callback.
  57577. * @param handle Define the hanle of the request to cancel
  57578. */
  57579. cancelAnimationFrame(handle: number): void;
  57580. /**
  57581. * Stops presenting to the VRDisplay.
  57582. * @returns a promise to know when it stopped
  57583. */
  57584. exitPresent(): Promise<void>;
  57585. /**
  57586. * Return the current VREyeParameters for the given eye.
  57587. * @param whichEye Define the eye we want the parameter for
  57588. * @returns the eye parameters
  57589. */
  57590. getEyeParameters(whichEye: string): VREyeParameters;
  57591. /**
  57592. * Populates the passed VRFrameData with the information required to render
  57593. * the current frame.
  57594. * @param frameData Define the data structure to populate
  57595. * @returns true if ok otherwise false
  57596. */
  57597. getFrameData(frameData: VRFrameData): boolean;
  57598. /**
  57599. * Get the layers currently being presented.
  57600. * @returns the list of VR layers
  57601. */
  57602. getLayers(): VRLayer[];
  57603. /**
  57604. * Return a VRPose containing the future predicted pose of the VRDisplay
  57605. * when the current frame will be presented. The value returned will not
  57606. * change until JavaScript has returned control to the browser.
  57607. *
  57608. * The VRPose will contain the position, orientation, velocity,
  57609. * and acceleration of each of these properties.
  57610. * @returns the pose object
  57611. */
  57612. getPose(): VRPose;
  57613. /**
  57614. * Return the current instantaneous pose of the VRDisplay, with no
  57615. * prediction applied.
  57616. * @returns the current instantaneous pose
  57617. */
  57618. getImmediatePose(): VRPose;
  57619. /**
  57620. * The callback passed to `requestAnimationFrame` will be called
  57621. * any time a new frame should be rendered. When the VRDisplay is
  57622. * presenting the callback will be called at the native refresh
  57623. * rate of the HMD. When not presenting this function acts
  57624. * identically to how window.requestAnimationFrame acts. Content should
  57625. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57626. * asynchronously from other displays and at differing refresh rates.
  57627. * @param callback Define the eaction to run next frame
  57628. * @returns the request handle it
  57629. */
  57630. requestAnimationFrame(callback: FrameRequestCallback): number;
  57631. /**
  57632. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57633. * Repeat calls while already presenting will update the VRLayers being displayed.
  57634. * @param layers Define the list of layer to present
  57635. * @returns a promise to know when the request has been fulfilled
  57636. */
  57637. requestPresent(layers: VRLayer[]): Promise<void>;
  57638. /**
  57639. * Reset the pose for this display, treating its current position and
  57640. * orientation as the "origin/zero" values. VRPose.position,
  57641. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57642. * updated when calling resetPose(). This should be called in only
  57643. * sitting-space experiences.
  57644. */
  57645. resetPose(): void;
  57646. /**
  57647. * The VRLayer provided to the VRDisplay will be captured and presented
  57648. * in the HMD. Calling this function has the same effect on the source
  57649. * canvas as any other operation that uses its source image, and canvases
  57650. * created without preserveDrawingBuffer set to true will be cleared.
  57651. * @param pose Define the pose to submit
  57652. */
  57653. submitFrame(pose?: VRPose): void;
  57654. }
  57655. declare var VRDisplay: {
  57656. prototype: VRDisplay;
  57657. new(): VRDisplay;
  57658. };
  57659. interface VRLayer {
  57660. leftBounds?: number[] | Float32Array | null;
  57661. rightBounds?: number[] | Float32Array | null;
  57662. source?: HTMLCanvasElement | null;
  57663. }
  57664. interface VRDisplayCapabilities {
  57665. readonly canPresent: boolean;
  57666. readonly hasExternalDisplay: boolean;
  57667. readonly hasOrientation: boolean;
  57668. readonly hasPosition: boolean;
  57669. readonly maxLayers: number;
  57670. }
  57671. interface VREyeParameters {
  57672. /** @deprecated */
  57673. readonly fieldOfView: VRFieldOfView;
  57674. readonly offset: Float32Array;
  57675. readonly renderHeight: number;
  57676. readonly renderWidth: number;
  57677. }
  57678. interface VRFieldOfView {
  57679. readonly downDegrees: number;
  57680. readonly leftDegrees: number;
  57681. readonly rightDegrees: number;
  57682. readonly upDegrees: number;
  57683. }
  57684. interface VRFrameData {
  57685. readonly leftProjectionMatrix: Float32Array;
  57686. readonly leftViewMatrix: Float32Array;
  57687. readonly pose: VRPose;
  57688. readonly rightProjectionMatrix: Float32Array;
  57689. readonly rightViewMatrix: Float32Array;
  57690. readonly timestamp: number;
  57691. }
  57692. interface VRPose {
  57693. readonly angularAcceleration: Float32Array | null;
  57694. readonly angularVelocity: Float32Array | null;
  57695. readonly linearAcceleration: Float32Array | null;
  57696. readonly linearVelocity: Float32Array | null;
  57697. readonly orientation: Float32Array | null;
  57698. readonly position: Float32Array | null;
  57699. readonly timestamp: number;
  57700. }
  57701. interface VRStageParameters {
  57702. sittingToStandingTransform?: Float32Array;
  57703. sizeX?: number;
  57704. sizeY?: number;
  57705. }
  57706. interface Navigator {
  57707. getVRDisplays(): Promise<VRDisplay[]>;
  57708. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57709. }
  57710. interface Window {
  57711. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57712. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57713. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57714. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57715. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57716. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57717. }
  57718. interface Gamepad {
  57719. readonly displayId: number;
  57720. }
  57721. interface XRDevice {
  57722. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57723. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57724. }
  57725. interface XRSession {
  57726. getInputSources(): Array<any>;
  57727. baseLayer: XRWebGLLayer;
  57728. requestFrameOfReference(type: string): Promise<void>;
  57729. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57730. end(): Promise<void>;
  57731. requestAnimationFrame: Function;
  57732. addEventListener: Function;
  57733. }
  57734. interface XRSessionCreationOptions {
  57735. outputContext?: WebGLRenderingContext | null;
  57736. immersive?: boolean;
  57737. environmentIntegration?: boolean;
  57738. }
  57739. interface XRLayer {
  57740. getViewport: Function;
  57741. framebufferWidth: number;
  57742. framebufferHeight: number;
  57743. }
  57744. interface XRView {
  57745. projectionMatrix: Float32Array;
  57746. }
  57747. interface XRFrame {
  57748. getDevicePose: Function;
  57749. getInputPose: Function;
  57750. views: Array<XRView>;
  57751. baseLayer: XRLayer;
  57752. }
  57753. interface XRFrameOfReference {
  57754. }
  57755. interface XRWebGLLayer extends XRLayer {
  57756. framebuffer: WebGLFramebuffer;
  57757. }
  57758. declare var XRWebGLLayer: {
  57759. prototype: XRWebGLLayer;
  57760. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57761. };
  57762. declare module "babylonjs" {
  57763. export * from "babylonjs/Legacy/legacy";
  57764. }
  57765. declare module BABYLON {
  57766. /** Alias type for value that can be null */
  57767. export type Nullable<T> = T | null;
  57768. /**
  57769. * Alias type for number that are floats
  57770. * @ignorenaming
  57771. */
  57772. export type float = number;
  57773. /**
  57774. * Alias type for number that are doubles.
  57775. * @ignorenaming
  57776. */
  57777. export type double = number;
  57778. /**
  57779. * Alias type for number that are integer
  57780. * @ignorenaming
  57781. */
  57782. export type int = number;
  57783. /** Alias type for number array or Float32Array */
  57784. export type FloatArray = number[] | Float32Array;
  57785. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57786. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57787. /**
  57788. * Alias for types that can be used by a Buffer or VertexBuffer.
  57789. */
  57790. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57791. /**
  57792. * Alias type for primitive types
  57793. * @ignorenaming
  57794. */
  57795. type Primitive = undefined | null | boolean | string | number | Function;
  57796. /**
  57797. * Type modifier to make all the properties of an object Readonly
  57798. */
  57799. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57800. /**
  57801. * Type modifier to make all the properties of an object Readonly recursively
  57802. */
  57803. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57804. /** @hidden */
  57805. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57806. }
  57807. /** @hidden */
  57808. /** @hidden */
  57809. type DeepImmutableObject<T> = {
  57810. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57811. };
  57812. }
  57813. declare module BABYLON {
  57814. /**
  57815. * Class containing a set of static utilities functions for arrays.
  57816. */
  57817. export class ArrayTools {
  57818. /**
  57819. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57820. * @param size the number of element to construct and put in the array
  57821. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57822. * @returns a new array filled with new objects
  57823. */
  57824. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57825. }
  57826. }
  57827. declare module BABYLON {
  57828. /**
  57829. * Scalar computation library
  57830. */
  57831. export class Scalar {
  57832. /**
  57833. * Two pi constants convenient for computation.
  57834. */
  57835. static TwoPi: number;
  57836. /**
  57837. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57838. * @param a number
  57839. * @param b number
  57840. * @param epsilon (default = 1.401298E-45)
  57841. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57842. */
  57843. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57844. /**
  57845. * Returns a string : the upper case translation of the number i to hexadecimal.
  57846. * @param i number
  57847. * @returns the upper case translation of the number i to hexadecimal.
  57848. */
  57849. static ToHex(i: number): string;
  57850. /**
  57851. * Returns -1 if value is negative and +1 is value is positive.
  57852. * @param value the value
  57853. * @returns the value itself if it's equal to zero.
  57854. */
  57855. static Sign(value: number): number;
  57856. /**
  57857. * Returns the value itself if it's between min and max.
  57858. * Returns min if the value is lower than min.
  57859. * Returns max if the value is greater than max.
  57860. * @param value the value to clmap
  57861. * @param min the min value to clamp to (default: 0)
  57862. * @param max the max value to clamp to (default: 1)
  57863. * @returns the clamped value
  57864. */
  57865. static Clamp(value: number, min?: number, max?: number): number;
  57866. /**
  57867. * the log2 of value.
  57868. * @param value the value to compute log2 of
  57869. * @returns the log2 of value.
  57870. */
  57871. static Log2(value: number): number;
  57872. /**
  57873. * Loops the value, so that it is never larger than length and never smaller than 0.
  57874. *
  57875. * This is similar to the modulo operator but it works with floating point numbers.
  57876. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57877. * With t = 5 and length = 2.5, the result would be 0.0.
  57878. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57879. * @param value the value
  57880. * @param length the length
  57881. * @returns the looped value
  57882. */
  57883. static Repeat(value: number, length: number): number;
  57884. /**
  57885. * Normalize the value between 0.0 and 1.0 using min and max values
  57886. * @param value value to normalize
  57887. * @param min max to normalize between
  57888. * @param max min to normalize between
  57889. * @returns the normalized value
  57890. */
  57891. static Normalize(value: number, min: number, max: number): number;
  57892. /**
  57893. * Denormalize the value from 0.0 and 1.0 using min and max values
  57894. * @param normalized value to denormalize
  57895. * @param min max to denormalize between
  57896. * @param max min to denormalize between
  57897. * @returns the denormalized value
  57898. */
  57899. static Denormalize(normalized: number, min: number, max: number): number;
  57900. /**
  57901. * Calculates the shortest difference between two given angles given in degrees.
  57902. * @param current current angle in degrees
  57903. * @param target target angle in degrees
  57904. * @returns the delta
  57905. */
  57906. static DeltaAngle(current: number, target: number): number;
  57907. /**
  57908. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57909. * @param tx value
  57910. * @param length length
  57911. * @returns The returned value will move back and forth between 0 and length
  57912. */
  57913. static PingPong(tx: number, length: number): number;
  57914. /**
  57915. * Interpolates between min and max with smoothing at the limits.
  57916. *
  57917. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57918. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57919. * @param from from
  57920. * @param to to
  57921. * @param tx value
  57922. * @returns the smooth stepped value
  57923. */
  57924. static SmoothStep(from: number, to: number, tx: number): number;
  57925. /**
  57926. * Moves a value current towards target.
  57927. *
  57928. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57929. * Negative values of maxDelta pushes the value away from target.
  57930. * @param current current value
  57931. * @param target target value
  57932. * @param maxDelta max distance to move
  57933. * @returns resulting value
  57934. */
  57935. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57936. /**
  57937. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57938. *
  57939. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57940. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57941. * @param current current value
  57942. * @param target target value
  57943. * @param maxDelta max distance to move
  57944. * @returns resulting angle
  57945. */
  57946. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57947. /**
  57948. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57949. * @param start start value
  57950. * @param end target value
  57951. * @param amount amount to lerp between
  57952. * @returns the lerped value
  57953. */
  57954. static Lerp(start: number, end: number, amount: number): number;
  57955. /**
  57956. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57957. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57958. * @param start start value
  57959. * @param end target value
  57960. * @param amount amount to lerp between
  57961. * @returns the lerped value
  57962. */
  57963. static LerpAngle(start: number, end: number, amount: number): number;
  57964. /**
  57965. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57966. * @param a start value
  57967. * @param b target value
  57968. * @param value value between a and b
  57969. * @returns the inverseLerp value
  57970. */
  57971. static InverseLerp(a: number, b: number, value: number): number;
  57972. /**
  57973. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57974. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57975. * @param value1 spline value
  57976. * @param tangent1 spline value
  57977. * @param value2 spline value
  57978. * @param tangent2 spline value
  57979. * @param amount input value
  57980. * @returns hermite result
  57981. */
  57982. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57983. /**
  57984. * Returns a random float number between and min and max values
  57985. * @param min min value of random
  57986. * @param max max value of random
  57987. * @returns random value
  57988. */
  57989. static RandomRange(min: number, max: number): number;
  57990. /**
  57991. * This function returns percentage of a number in a given range.
  57992. *
  57993. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57994. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57995. * @param number to convert to percentage
  57996. * @param min min range
  57997. * @param max max range
  57998. * @returns the percentage
  57999. */
  58000. static RangeToPercent(number: number, min: number, max: number): number;
  58001. /**
  58002. * This function returns number that corresponds to the percentage in a given range.
  58003. *
  58004. * PercentToRange(0.34,0,100) will return 34.
  58005. * @param percent to convert to number
  58006. * @param min min range
  58007. * @param max max range
  58008. * @returns the number
  58009. */
  58010. static PercentToRange(percent: number, min: number, max: number): number;
  58011. /**
  58012. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58013. * @param angle The angle to normalize in radian.
  58014. * @return The converted angle.
  58015. */
  58016. static NormalizeRadians(angle: number): number;
  58017. }
  58018. }
  58019. declare module BABYLON {
  58020. /**
  58021. * Constant used to convert a value to gamma space
  58022. * @ignorenaming
  58023. */
  58024. export const ToGammaSpace: number;
  58025. /**
  58026. * Constant used to convert a value to linear space
  58027. * @ignorenaming
  58028. */
  58029. export const ToLinearSpace = 2.2;
  58030. /**
  58031. * Constant used to define the minimal number value in Babylon.js
  58032. * @ignorenaming
  58033. */
  58034. export const Epsilon = 0.001;
  58035. /**
  58036. * Class used to hold a RBG color
  58037. */
  58038. export class Color3 {
  58039. /**
  58040. * Defines the red component (between 0 and 1, default is 0)
  58041. */
  58042. r: number;
  58043. /**
  58044. * Defines the green component (between 0 and 1, default is 0)
  58045. */
  58046. g: number;
  58047. /**
  58048. * Defines the blue component (between 0 and 1, default is 0)
  58049. */
  58050. b: number;
  58051. /**
  58052. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58053. * @param r defines the red component (between 0 and 1, default is 0)
  58054. * @param g defines the green component (between 0 and 1, default is 0)
  58055. * @param b defines the blue component (between 0 and 1, default is 0)
  58056. */
  58057. constructor(
  58058. /**
  58059. * Defines the red component (between 0 and 1, default is 0)
  58060. */
  58061. r?: number,
  58062. /**
  58063. * Defines the green component (between 0 and 1, default is 0)
  58064. */
  58065. g?: number,
  58066. /**
  58067. * Defines the blue component (between 0 and 1, default is 0)
  58068. */
  58069. b?: number);
  58070. /**
  58071. * Creates a string with the Color3 current values
  58072. * @returns the string representation of the Color3 object
  58073. */
  58074. toString(): string;
  58075. /**
  58076. * Returns the string "Color3"
  58077. * @returns "Color3"
  58078. */
  58079. getClassName(): string;
  58080. /**
  58081. * Compute the Color3 hash code
  58082. * @returns an unique number that can be used to hash Color3 objects
  58083. */
  58084. getHashCode(): number;
  58085. /**
  58086. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58087. * @param array defines the array where to store the r,g,b components
  58088. * @param index defines an optional index in the target array to define where to start storing values
  58089. * @returns the current Color3 object
  58090. */
  58091. toArray(array: FloatArray, index?: number): Color3;
  58092. /**
  58093. * Returns a new Color4 object from the current Color3 and the given alpha
  58094. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58095. * @returns a new Color4 object
  58096. */
  58097. toColor4(alpha?: number): Color4;
  58098. /**
  58099. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58100. * @returns the new array
  58101. */
  58102. asArray(): number[];
  58103. /**
  58104. * Returns the luminance value
  58105. * @returns a float value
  58106. */
  58107. toLuminance(): number;
  58108. /**
  58109. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58110. * @param otherColor defines the second operand
  58111. * @returns the new Color3 object
  58112. */
  58113. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58114. /**
  58115. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58116. * @param otherColor defines the second operand
  58117. * @param result defines the Color3 object where to store the result
  58118. * @returns the current Color3
  58119. */
  58120. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58121. /**
  58122. * Determines equality between Color3 objects
  58123. * @param otherColor defines the second operand
  58124. * @returns true if the rgb values are equal to the given ones
  58125. */
  58126. equals(otherColor: DeepImmutable<Color3>): boolean;
  58127. /**
  58128. * Determines equality between the current Color3 object and a set of r,b,g values
  58129. * @param r defines the red component to check
  58130. * @param g defines the green component to check
  58131. * @param b defines the blue component to check
  58132. * @returns true if the rgb values are equal to the given ones
  58133. */
  58134. equalsFloats(r: number, g: number, b: number): boolean;
  58135. /**
  58136. * Multiplies in place each rgb value by scale
  58137. * @param scale defines the scaling factor
  58138. * @returns the updated Color3
  58139. */
  58140. scale(scale: number): Color3;
  58141. /**
  58142. * Multiplies the rgb values by scale and stores the result into "result"
  58143. * @param scale defines the scaling factor
  58144. * @param result defines the Color3 object where to store the result
  58145. * @returns the unmodified current Color3
  58146. */
  58147. scaleToRef(scale: number, result: Color3): Color3;
  58148. /**
  58149. * Scale the current Color3 values by a factor and add the result to a given Color3
  58150. * @param scale defines the scale factor
  58151. * @param result defines color to store the result into
  58152. * @returns the unmodified current Color3
  58153. */
  58154. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58155. /**
  58156. * Clamps the rgb values by the min and max values and stores the result into "result"
  58157. * @param min defines minimum clamping value (default is 0)
  58158. * @param max defines maximum clamping value (default is 1)
  58159. * @param result defines color to store the result into
  58160. * @returns the original Color3
  58161. */
  58162. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58163. /**
  58164. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58165. * @param otherColor defines the second operand
  58166. * @returns the new Color3
  58167. */
  58168. add(otherColor: DeepImmutable<Color3>): Color3;
  58169. /**
  58170. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58171. * @param otherColor defines the second operand
  58172. * @param result defines Color3 object to store the result into
  58173. * @returns the unmodified current Color3
  58174. */
  58175. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58176. /**
  58177. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58178. * @param otherColor defines the second operand
  58179. * @returns the new Color3
  58180. */
  58181. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58182. /**
  58183. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58184. * @param otherColor defines the second operand
  58185. * @param result defines Color3 object to store the result into
  58186. * @returns the unmodified current Color3
  58187. */
  58188. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58189. /**
  58190. * Copy the current object
  58191. * @returns a new Color3 copied the current one
  58192. */
  58193. clone(): Color3;
  58194. /**
  58195. * Copies the rgb values from the source in the current Color3
  58196. * @param source defines the source Color3 object
  58197. * @returns the updated Color3 object
  58198. */
  58199. copyFrom(source: DeepImmutable<Color3>): Color3;
  58200. /**
  58201. * Updates the Color3 rgb values from the given floats
  58202. * @param r defines the red component to read from
  58203. * @param g defines the green component to read from
  58204. * @param b defines the blue component to read from
  58205. * @returns the current Color3 object
  58206. */
  58207. copyFromFloats(r: number, g: number, b: number): Color3;
  58208. /**
  58209. * Updates the Color3 rgb values from the given floats
  58210. * @param r defines the red component to read from
  58211. * @param g defines the green component to read from
  58212. * @param b defines the blue component to read from
  58213. * @returns the current Color3 object
  58214. */
  58215. set(r: number, g: number, b: number): Color3;
  58216. /**
  58217. * Compute the Color3 hexadecimal code as a string
  58218. * @returns a string containing the hexadecimal representation of the Color3 object
  58219. */
  58220. toHexString(): string;
  58221. /**
  58222. * Computes a new Color3 converted from the current one to linear space
  58223. * @returns a new Color3 object
  58224. */
  58225. toLinearSpace(): Color3;
  58226. /**
  58227. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58228. * @param convertedColor defines the Color3 object where to store the linear space version
  58229. * @returns the unmodified Color3
  58230. */
  58231. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58232. /**
  58233. * Computes a new Color3 converted from the current one to gamma space
  58234. * @returns a new Color3 object
  58235. */
  58236. toGammaSpace(): Color3;
  58237. /**
  58238. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58239. * @param convertedColor defines the Color3 object where to store the gamma space version
  58240. * @returns the unmodified Color3
  58241. */
  58242. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58243. private static _BlackReadOnly;
  58244. /**
  58245. * Creates a new Color3 from the string containing valid hexadecimal values
  58246. * @param hex defines a string containing valid hexadecimal values
  58247. * @returns a new Color3 object
  58248. */
  58249. static FromHexString(hex: string): Color3;
  58250. /**
  58251. * Creates a new Vector3 from the starting index of the given array
  58252. * @param array defines the source array
  58253. * @param offset defines an offset in the source array
  58254. * @returns a new Color3 object
  58255. */
  58256. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58257. /**
  58258. * Creates a new Color3 from integer values (< 256)
  58259. * @param r defines the red component to read from (value between 0 and 255)
  58260. * @param g defines the green component to read from (value between 0 and 255)
  58261. * @param b defines the blue component to read from (value between 0 and 255)
  58262. * @returns a new Color3 object
  58263. */
  58264. static FromInts(r: number, g: number, b: number): Color3;
  58265. /**
  58266. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58267. * @param start defines the start Color3 value
  58268. * @param end defines the end Color3 value
  58269. * @param amount defines the gradient value between start and end
  58270. * @returns a new Color3 object
  58271. */
  58272. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58273. /**
  58274. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58275. * @param left defines the start value
  58276. * @param right defines the end value
  58277. * @param amount defines the gradient factor
  58278. * @param result defines the Color3 object where to store the result
  58279. */
  58280. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58281. /**
  58282. * Returns a Color3 value containing a red color
  58283. * @returns a new Color3 object
  58284. */
  58285. static Red(): Color3;
  58286. /**
  58287. * Returns a Color3 value containing a green color
  58288. * @returns a new Color3 object
  58289. */
  58290. static Green(): Color3;
  58291. /**
  58292. * Returns a Color3 value containing a blue color
  58293. * @returns a new Color3 object
  58294. */
  58295. static Blue(): Color3;
  58296. /**
  58297. * Returns a Color3 value containing a black color
  58298. * @returns a new Color3 object
  58299. */
  58300. static Black(): Color3;
  58301. /**
  58302. * Gets a Color3 value containing a black color that must not be updated
  58303. */
  58304. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58305. /**
  58306. * Returns a Color3 value containing a white color
  58307. * @returns a new Color3 object
  58308. */
  58309. static White(): Color3;
  58310. /**
  58311. * Returns a Color3 value containing a purple color
  58312. * @returns a new Color3 object
  58313. */
  58314. static Purple(): Color3;
  58315. /**
  58316. * Returns a Color3 value containing a magenta color
  58317. * @returns a new Color3 object
  58318. */
  58319. static Magenta(): Color3;
  58320. /**
  58321. * Returns a Color3 value containing a yellow color
  58322. * @returns a new Color3 object
  58323. */
  58324. static Yellow(): Color3;
  58325. /**
  58326. * Returns a Color3 value containing a gray color
  58327. * @returns a new Color3 object
  58328. */
  58329. static Gray(): Color3;
  58330. /**
  58331. * Returns a Color3 value containing a teal color
  58332. * @returns a new Color3 object
  58333. */
  58334. static Teal(): Color3;
  58335. /**
  58336. * Returns a Color3 value containing a random color
  58337. * @returns a new Color3 object
  58338. */
  58339. static Random(): Color3;
  58340. }
  58341. /**
  58342. * Class used to hold a RBGA color
  58343. */
  58344. export class Color4 {
  58345. /**
  58346. * Defines the red component (between 0 and 1, default is 0)
  58347. */
  58348. r: number;
  58349. /**
  58350. * Defines the green component (between 0 and 1, default is 0)
  58351. */
  58352. g: number;
  58353. /**
  58354. * Defines the blue component (between 0 and 1, default is 0)
  58355. */
  58356. b: number;
  58357. /**
  58358. * Defines the alpha component (between 0 and 1, default is 1)
  58359. */
  58360. a: number;
  58361. /**
  58362. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58363. * @param r defines the red component (between 0 and 1, default is 0)
  58364. * @param g defines the green component (between 0 and 1, default is 0)
  58365. * @param b defines the blue component (between 0 and 1, default is 0)
  58366. * @param a defines the alpha component (between 0 and 1, default is 1)
  58367. */
  58368. constructor(
  58369. /**
  58370. * Defines the red component (between 0 and 1, default is 0)
  58371. */
  58372. r?: number,
  58373. /**
  58374. * Defines the green component (between 0 and 1, default is 0)
  58375. */
  58376. g?: number,
  58377. /**
  58378. * Defines the blue component (between 0 and 1, default is 0)
  58379. */
  58380. b?: number,
  58381. /**
  58382. * Defines the alpha component (between 0 and 1, default is 1)
  58383. */
  58384. a?: number);
  58385. /**
  58386. * Adds in place the given Color4 values to the current Color4 object
  58387. * @param right defines the second operand
  58388. * @returns the current updated Color4 object
  58389. */
  58390. addInPlace(right: DeepImmutable<Color4>): Color4;
  58391. /**
  58392. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58393. * @returns the new array
  58394. */
  58395. asArray(): number[];
  58396. /**
  58397. * Stores from the starting index in the given array the Color4 successive values
  58398. * @param array defines the array where to store the r,g,b components
  58399. * @param index defines an optional index in the target array to define where to start storing values
  58400. * @returns the current Color4 object
  58401. */
  58402. toArray(array: number[], index?: number): Color4;
  58403. /**
  58404. * Determines equality between Color4 objects
  58405. * @param otherColor defines the second operand
  58406. * @returns true if the rgba values are equal to the given ones
  58407. */
  58408. equals(otherColor: DeepImmutable<Color4>): boolean;
  58409. /**
  58410. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58411. * @param right defines the second operand
  58412. * @returns a new Color4 object
  58413. */
  58414. add(right: DeepImmutable<Color4>): Color4;
  58415. /**
  58416. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58417. * @param right defines the second operand
  58418. * @returns a new Color4 object
  58419. */
  58420. subtract(right: DeepImmutable<Color4>): Color4;
  58421. /**
  58422. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58423. * @param right defines the second operand
  58424. * @param result defines the Color4 object where to store the result
  58425. * @returns the current Color4 object
  58426. */
  58427. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58428. /**
  58429. * Creates a new Color4 with the current Color4 values multiplied by scale
  58430. * @param scale defines the scaling factor to apply
  58431. * @returns a new Color4 object
  58432. */
  58433. scale(scale: number): Color4;
  58434. /**
  58435. * Multiplies the current Color4 values by scale and stores the result in "result"
  58436. * @param scale defines the scaling factor to apply
  58437. * @param result defines the Color4 object where to store the result
  58438. * @returns the current unmodified Color4
  58439. */
  58440. scaleToRef(scale: number, result: Color4): Color4;
  58441. /**
  58442. * Scale the current Color4 values by a factor and add the result to a given Color4
  58443. * @param scale defines the scale factor
  58444. * @param result defines the Color4 object where to store the result
  58445. * @returns the unmodified current Color4
  58446. */
  58447. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58448. /**
  58449. * Clamps the rgb values by the min and max values and stores the result into "result"
  58450. * @param min defines minimum clamping value (default is 0)
  58451. * @param max defines maximum clamping value (default is 1)
  58452. * @param result defines color to store the result into.
  58453. * @returns the cuurent Color4
  58454. */
  58455. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58456. /**
  58457. * Multipy an Color4 value by another and return a new Color4 object
  58458. * @param color defines the Color4 value to multiply by
  58459. * @returns a new Color4 object
  58460. */
  58461. multiply(color: Color4): Color4;
  58462. /**
  58463. * Multipy a Color4 value by another and push the result in a reference value
  58464. * @param color defines the Color4 value to multiply by
  58465. * @param result defines the Color4 to fill the result in
  58466. * @returns the result Color4
  58467. */
  58468. multiplyToRef(color: Color4, result: Color4): Color4;
  58469. /**
  58470. * Creates a string with the Color4 current values
  58471. * @returns the string representation of the Color4 object
  58472. */
  58473. toString(): string;
  58474. /**
  58475. * Returns the string "Color4"
  58476. * @returns "Color4"
  58477. */
  58478. getClassName(): string;
  58479. /**
  58480. * Compute the Color4 hash code
  58481. * @returns an unique number that can be used to hash Color4 objects
  58482. */
  58483. getHashCode(): number;
  58484. /**
  58485. * Creates a new Color4 copied from the current one
  58486. * @returns a new Color4 object
  58487. */
  58488. clone(): Color4;
  58489. /**
  58490. * Copies the given Color4 values into the current one
  58491. * @param source defines the source Color4 object
  58492. * @returns the current updated Color4 object
  58493. */
  58494. copyFrom(source: Color4): Color4;
  58495. /**
  58496. * Copies the given float values into the current one
  58497. * @param r defines the red component to read from
  58498. * @param g defines the green component to read from
  58499. * @param b defines the blue component to read from
  58500. * @param a defines the alpha component to read from
  58501. * @returns the current updated Color4 object
  58502. */
  58503. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58504. /**
  58505. * Copies the given float values into the current one
  58506. * @param r defines the red component to read from
  58507. * @param g defines the green component to read from
  58508. * @param b defines the blue component to read from
  58509. * @param a defines the alpha component to read from
  58510. * @returns the current updated Color4 object
  58511. */
  58512. set(r: number, g: number, b: number, a: number): Color4;
  58513. /**
  58514. * Compute the Color4 hexadecimal code as a string
  58515. * @returns a string containing the hexadecimal representation of the Color4 object
  58516. */
  58517. toHexString(): string;
  58518. /**
  58519. * Computes a new Color4 converted from the current one to linear space
  58520. * @returns a new Color4 object
  58521. */
  58522. toLinearSpace(): Color4;
  58523. /**
  58524. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58525. * @param convertedColor defines the Color4 object where to store the linear space version
  58526. * @returns the unmodified Color4
  58527. */
  58528. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58529. /**
  58530. * Computes a new Color4 converted from the current one to gamma space
  58531. * @returns a new Color4 object
  58532. */
  58533. toGammaSpace(): Color4;
  58534. /**
  58535. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58536. * @param convertedColor defines the Color4 object where to store the gamma space version
  58537. * @returns the unmodified Color4
  58538. */
  58539. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58540. /**
  58541. * Creates a new Color4 from the string containing valid hexadecimal values
  58542. * @param hex defines a string containing valid hexadecimal values
  58543. * @returns a new Color4 object
  58544. */
  58545. static FromHexString(hex: string): Color4;
  58546. /**
  58547. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58548. * @param left defines the start value
  58549. * @param right defines the end value
  58550. * @param amount defines the gradient factor
  58551. * @returns a new Color4 object
  58552. */
  58553. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58554. /**
  58555. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58556. * @param left defines the start value
  58557. * @param right defines the end value
  58558. * @param amount defines the gradient factor
  58559. * @param result defines the Color4 object where to store data
  58560. */
  58561. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58562. /**
  58563. * Creates a new Color4 from a Color3 and an alpha value
  58564. * @param color3 defines the source Color3 to read from
  58565. * @param alpha defines the alpha component (1.0 by default)
  58566. * @returns a new Color4 object
  58567. */
  58568. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58569. /**
  58570. * Creates a new Color4 from the starting index element of the given array
  58571. * @param array defines the source array to read from
  58572. * @param offset defines the offset in the source array
  58573. * @returns a new Color4 object
  58574. */
  58575. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58576. /**
  58577. * Creates a new Color3 from integer values (< 256)
  58578. * @param r defines the red component to read from (value between 0 and 255)
  58579. * @param g defines the green component to read from (value between 0 and 255)
  58580. * @param b defines the blue component to read from (value between 0 and 255)
  58581. * @param a defines the alpha component to read from (value between 0 and 255)
  58582. * @returns a new Color3 object
  58583. */
  58584. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58585. /**
  58586. * Check the content of a given array and convert it to an array containing RGBA data
  58587. * If the original array was already containing count * 4 values then it is returned directly
  58588. * @param colors defines the array to check
  58589. * @param count defines the number of RGBA data to expect
  58590. * @returns an array containing count * 4 values (RGBA)
  58591. */
  58592. static CheckColors4(colors: number[], count: number): number[];
  58593. }
  58594. /**
  58595. * Class representing a vector containing 2 coordinates
  58596. */
  58597. export class Vector2 {
  58598. /** defines the first coordinate */
  58599. x: number;
  58600. /** defines the second coordinate */
  58601. y: number;
  58602. /**
  58603. * Creates a new Vector2 from the given x and y coordinates
  58604. * @param x defines the first coordinate
  58605. * @param y defines the second coordinate
  58606. */
  58607. constructor(
  58608. /** defines the first coordinate */
  58609. x?: number,
  58610. /** defines the second coordinate */
  58611. y?: number);
  58612. /**
  58613. * Gets a string with the Vector2 coordinates
  58614. * @returns a string with the Vector2 coordinates
  58615. */
  58616. toString(): string;
  58617. /**
  58618. * Gets class name
  58619. * @returns the string "Vector2"
  58620. */
  58621. getClassName(): string;
  58622. /**
  58623. * Gets current vector hash code
  58624. * @returns the Vector2 hash code as a number
  58625. */
  58626. getHashCode(): number;
  58627. /**
  58628. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58629. * @param array defines the source array
  58630. * @param index defines the offset in source array
  58631. * @returns the current Vector2
  58632. */
  58633. toArray(array: FloatArray, index?: number): Vector2;
  58634. /**
  58635. * Copy the current vector to an array
  58636. * @returns a new array with 2 elements: the Vector2 coordinates.
  58637. */
  58638. asArray(): number[];
  58639. /**
  58640. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58641. * @param source defines the source Vector2
  58642. * @returns the current updated Vector2
  58643. */
  58644. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58645. /**
  58646. * Sets the Vector2 coordinates with the given floats
  58647. * @param x defines the first coordinate
  58648. * @param y defines the second coordinate
  58649. * @returns the current updated Vector2
  58650. */
  58651. copyFromFloats(x: number, y: number): Vector2;
  58652. /**
  58653. * Sets the Vector2 coordinates with the given floats
  58654. * @param x defines the first coordinate
  58655. * @param y defines the second coordinate
  58656. * @returns the current updated Vector2
  58657. */
  58658. set(x: number, y: number): Vector2;
  58659. /**
  58660. * Add another vector with the current one
  58661. * @param otherVector defines the other vector
  58662. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58663. */
  58664. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58665. /**
  58666. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58667. * @param otherVector defines the other vector
  58668. * @param result defines the target vector
  58669. * @returns the unmodified current Vector2
  58670. */
  58671. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58672. /**
  58673. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58674. * @param otherVector defines the other vector
  58675. * @returns the current updated Vector2
  58676. */
  58677. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58678. /**
  58679. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58680. * @param otherVector defines the other vector
  58681. * @returns a new Vector2
  58682. */
  58683. addVector3(otherVector: Vector3): Vector2;
  58684. /**
  58685. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58686. * @param otherVector defines the other vector
  58687. * @returns a new Vector2
  58688. */
  58689. subtract(otherVector: Vector2): Vector2;
  58690. /**
  58691. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58692. * @param otherVector defines the other vector
  58693. * @param result defines the target vector
  58694. * @returns the unmodified current Vector2
  58695. */
  58696. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58697. /**
  58698. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58699. * @param otherVector defines the other vector
  58700. * @returns the current updated Vector2
  58701. */
  58702. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58703. /**
  58704. * Multiplies in place the current Vector2 coordinates by the given ones
  58705. * @param otherVector defines the other vector
  58706. * @returns the current updated Vector2
  58707. */
  58708. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58709. /**
  58710. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58711. * @param otherVector defines the other vector
  58712. * @returns a new Vector2
  58713. */
  58714. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58715. /**
  58716. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58717. * @param otherVector defines the other vector
  58718. * @param result defines the target vector
  58719. * @returns the unmodified current Vector2
  58720. */
  58721. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58722. /**
  58723. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58724. * @param x defines the first coordinate
  58725. * @param y defines the second coordinate
  58726. * @returns a new Vector2
  58727. */
  58728. multiplyByFloats(x: number, y: number): Vector2;
  58729. /**
  58730. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58731. * @param otherVector defines the other vector
  58732. * @returns a new Vector2
  58733. */
  58734. divide(otherVector: Vector2): Vector2;
  58735. /**
  58736. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58737. * @param otherVector defines the other vector
  58738. * @param result defines the target vector
  58739. * @returns the unmodified current Vector2
  58740. */
  58741. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58742. /**
  58743. * Divides the current Vector2 coordinates by the given ones
  58744. * @param otherVector defines the other vector
  58745. * @returns the current updated Vector2
  58746. */
  58747. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58748. /**
  58749. * Gets a new Vector2 with current Vector2 negated coordinates
  58750. * @returns a new Vector2
  58751. */
  58752. negate(): Vector2;
  58753. /**
  58754. * Multiply the Vector2 coordinates by scale
  58755. * @param scale defines the scaling factor
  58756. * @returns the current updated Vector2
  58757. */
  58758. scaleInPlace(scale: number): Vector2;
  58759. /**
  58760. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58761. * @param scale defines the scaling factor
  58762. * @returns a new Vector2
  58763. */
  58764. scale(scale: number): Vector2;
  58765. /**
  58766. * Scale the current Vector2 values by a factor to a given Vector2
  58767. * @param scale defines the scale factor
  58768. * @param result defines the Vector2 object where to store the result
  58769. * @returns the unmodified current Vector2
  58770. */
  58771. scaleToRef(scale: number, result: Vector2): Vector2;
  58772. /**
  58773. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58774. * @param scale defines the scale factor
  58775. * @param result defines the Vector2 object where to store the result
  58776. * @returns the unmodified current Vector2
  58777. */
  58778. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58779. /**
  58780. * Gets a boolean if two vectors are equals
  58781. * @param otherVector defines the other vector
  58782. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58783. */
  58784. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58785. /**
  58786. * Gets a boolean if two vectors are equals (using an epsilon value)
  58787. * @param otherVector defines the other vector
  58788. * @param epsilon defines the minimal distance to consider equality
  58789. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58790. */
  58791. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58792. /**
  58793. * Gets a new Vector2 from current Vector2 floored values
  58794. * @returns a new Vector2
  58795. */
  58796. floor(): Vector2;
  58797. /**
  58798. * Gets a new Vector2 from current Vector2 floored values
  58799. * @returns a new Vector2
  58800. */
  58801. fract(): Vector2;
  58802. /**
  58803. * Gets the length of the vector
  58804. * @returns the vector length (float)
  58805. */
  58806. length(): number;
  58807. /**
  58808. * Gets the vector squared length
  58809. * @returns the vector squared length (float)
  58810. */
  58811. lengthSquared(): number;
  58812. /**
  58813. * Normalize the vector
  58814. * @returns the current updated Vector2
  58815. */
  58816. normalize(): Vector2;
  58817. /**
  58818. * Gets a new Vector2 copied from the Vector2
  58819. * @returns a new Vector2
  58820. */
  58821. clone(): Vector2;
  58822. /**
  58823. * Gets a new Vector2(0, 0)
  58824. * @returns a new Vector2
  58825. */
  58826. static Zero(): Vector2;
  58827. /**
  58828. * Gets a new Vector2(1, 1)
  58829. * @returns a new Vector2
  58830. */
  58831. static One(): Vector2;
  58832. /**
  58833. * Gets a new Vector2 set from the given index element of the given array
  58834. * @param array defines the data source
  58835. * @param offset defines the offset in the data source
  58836. * @returns a new Vector2
  58837. */
  58838. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58839. /**
  58840. * Sets "result" from the given index element of the given array
  58841. * @param array defines the data source
  58842. * @param offset defines the offset in the data source
  58843. * @param result defines the target vector
  58844. */
  58845. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58846. /**
  58847. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58848. * @param value1 defines 1st point of control
  58849. * @param value2 defines 2nd point of control
  58850. * @param value3 defines 3rd point of control
  58851. * @param value4 defines 4th point of control
  58852. * @param amount defines the interpolation factor
  58853. * @returns a new Vector2
  58854. */
  58855. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58856. /**
  58857. * 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".
  58858. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58859. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58860. * @param value defines the value to clamp
  58861. * @param min defines the lower limit
  58862. * @param max defines the upper limit
  58863. * @returns a new Vector2
  58864. */
  58865. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58866. /**
  58867. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58868. * @param value1 defines the 1st control point
  58869. * @param tangent1 defines the outgoing tangent
  58870. * @param value2 defines the 2nd control point
  58871. * @param tangent2 defines the incoming tangent
  58872. * @param amount defines the interpolation factor
  58873. * @returns a new Vector2
  58874. */
  58875. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58876. /**
  58877. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58878. * @param start defines the start vector
  58879. * @param end defines the end vector
  58880. * @param amount defines the interpolation factor
  58881. * @returns a new Vector2
  58882. */
  58883. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58884. /**
  58885. * Gets the dot product of the vector "left" and the vector "right"
  58886. * @param left defines first vector
  58887. * @param right defines second vector
  58888. * @returns the dot product (float)
  58889. */
  58890. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58891. /**
  58892. * Returns a new Vector2 equal to the normalized given vector
  58893. * @param vector defines the vector to normalize
  58894. * @returns a new Vector2
  58895. */
  58896. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58897. /**
  58898. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58899. * @param left defines 1st vector
  58900. * @param right defines 2nd vector
  58901. * @returns a new Vector2
  58902. */
  58903. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58904. /**
  58905. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58906. * @param left defines 1st vector
  58907. * @param right defines 2nd vector
  58908. * @returns a new Vector2
  58909. */
  58910. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58911. /**
  58912. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58913. * @param vector defines the vector to transform
  58914. * @param transformation defines the matrix to apply
  58915. * @returns a new Vector2
  58916. */
  58917. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58918. /**
  58919. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58920. * @param vector defines the vector to transform
  58921. * @param transformation defines the matrix to apply
  58922. * @param result defines the target vector
  58923. */
  58924. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58925. /**
  58926. * Determines if a given vector is included in a triangle
  58927. * @param p defines the vector to test
  58928. * @param p0 defines 1st triangle point
  58929. * @param p1 defines 2nd triangle point
  58930. * @param p2 defines 3rd triangle point
  58931. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58932. */
  58933. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58934. /**
  58935. * Gets the distance between the vectors "value1" and "value2"
  58936. * @param value1 defines first vector
  58937. * @param value2 defines second vector
  58938. * @returns the distance between vectors
  58939. */
  58940. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58941. /**
  58942. * Returns the squared distance between the vectors "value1" and "value2"
  58943. * @param value1 defines first vector
  58944. * @param value2 defines second vector
  58945. * @returns the squared distance between vectors
  58946. */
  58947. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58948. /**
  58949. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58950. * @param value1 defines first vector
  58951. * @param value2 defines second vector
  58952. * @returns a new Vector2
  58953. */
  58954. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58955. /**
  58956. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58957. * @param p defines the middle point
  58958. * @param segA defines one point of the segment
  58959. * @param segB defines the other point of the segment
  58960. * @returns the shortest distance
  58961. */
  58962. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58963. }
  58964. /**
  58965. * Classed used to store (x,y,z) vector representation
  58966. * A Vector3 is the main object used in 3D geometry
  58967. * It can represent etiher the coordinates of a point the space, either a direction
  58968. * Reminder: js uses a left handed forward facing system
  58969. */
  58970. export class Vector3 {
  58971. /**
  58972. * Defines the first coordinates (on X axis)
  58973. */
  58974. x: number;
  58975. /**
  58976. * Defines the second coordinates (on Y axis)
  58977. */
  58978. y: number;
  58979. /**
  58980. * Defines the third coordinates (on Z axis)
  58981. */
  58982. z: number;
  58983. private static _UpReadOnly;
  58984. /**
  58985. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58986. * @param x defines the first coordinates (on X axis)
  58987. * @param y defines the second coordinates (on Y axis)
  58988. * @param z defines the third coordinates (on Z axis)
  58989. */
  58990. constructor(
  58991. /**
  58992. * Defines the first coordinates (on X axis)
  58993. */
  58994. x?: number,
  58995. /**
  58996. * Defines the second coordinates (on Y axis)
  58997. */
  58998. y?: number,
  58999. /**
  59000. * Defines the third coordinates (on Z axis)
  59001. */
  59002. z?: number);
  59003. /**
  59004. * Creates a string representation of the Vector3
  59005. * @returns a string with the Vector3 coordinates.
  59006. */
  59007. toString(): string;
  59008. /**
  59009. * Gets the class name
  59010. * @returns the string "Vector3"
  59011. */
  59012. getClassName(): string;
  59013. /**
  59014. * Creates the Vector3 hash code
  59015. * @returns a number which tends to be unique between Vector3 instances
  59016. */
  59017. getHashCode(): number;
  59018. /**
  59019. * Creates an array containing three elements : the coordinates of the Vector3
  59020. * @returns a new array of numbers
  59021. */
  59022. asArray(): number[];
  59023. /**
  59024. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59025. * @param array defines the destination array
  59026. * @param index defines the offset in the destination array
  59027. * @returns the current Vector3
  59028. */
  59029. toArray(array: FloatArray, index?: number): Vector3;
  59030. /**
  59031. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59032. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59033. */
  59034. toQuaternion(): Quaternion;
  59035. /**
  59036. * Adds the given vector to the current Vector3
  59037. * @param otherVector defines the second operand
  59038. * @returns the current updated Vector3
  59039. */
  59040. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59041. /**
  59042. * Adds the given coordinates to the current Vector3
  59043. * @param x defines the x coordinate of the operand
  59044. * @param y defines the y coordinate of the operand
  59045. * @param z defines the z coordinate of the operand
  59046. * @returns the current updated Vector3
  59047. */
  59048. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59049. /**
  59050. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59051. * @param otherVector defines the second operand
  59052. * @returns the resulting Vector3
  59053. */
  59054. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59055. /**
  59056. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59057. * @param otherVector defines the second operand
  59058. * @param result defines the Vector3 object where to store the result
  59059. * @returns the current Vector3
  59060. */
  59061. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59062. /**
  59063. * Subtract the given vector from the current Vector3
  59064. * @param otherVector defines the second operand
  59065. * @returns the current updated Vector3
  59066. */
  59067. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59068. /**
  59069. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59070. * @param otherVector defines the second operand
  59071. * @returns the resulting Vector3
  59072. */
  59073. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59074. /**
  59075. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59076. * @param otherVector defines the second operand
  59077. * @param result defines the Vector3 object where to store the result
  59078. * @returns the current Vector3
  59079. */
  59080. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59081. /**
  59082. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59083. * @param x defines the x coordinate of the operand
  59084. * @param y defines the y coordinate of the operand
  59085. * @param z defines the z coordinate of the operand
  59086. * @returns the resulting Vector3
  59087. */
  59088. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59089. /**
  59090. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59091. * @param x defines the x coordinate of the operand
  59092. * @param y defines the y coordinate of the operand
  59093. * @param z defines the z coordinate of the operand
  59094. * @param result defines the Vector3 object where to store the result
  59095. * @returns the current Vector3
  59096. */
  59097. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59098. /**
  59099. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59100. * @returns a new Vector3
  59101. */
  59102. negate(): Vector3;
  59103. /**
  59104. * Multiplies the Vector3 coordinates by the float "scale"
  59105. * @param scale defines the multiplier factor
  59106. * @returns the current updated Vector3
  59107. */
  59108. scaleInPlace(scale: number): Vector3;
  59109. /**
  59110. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59111. * @param scale defines the multiplier factor
  59112. * @returns a new Vector3
  59113. */
  59114. scale(scale: number): Vector3;
  59115. /**
  59116. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59117. * @param scale defines the multiplier factor
  59118. * @param result defines the Vector3 object where to store the result
  59119. * @returns the current Vector3
  59120. */
  59121. scaleToRef(scale: number, result: Vector3): Vector3;
  59122. /**
  59123. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59124. * @param scale defines the scale factor
  59125. * @param result defines the Vector3 object where to store the result
  59126. * @returns the unmodified current Vector3
  59127. */
  59128. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59129. /**
  59130. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59131. * @param otherVector defines the second operand
  59132. * @returns true if both vectors are equals
  59133. */
  59134. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59135. /**
  59136. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59137. * @param otherVector defines the second operand
  59138. * @param epsilon defines the minimal distance to define values as equals
  59139. * @returns true if both vectors are distant less than epsilon
  59140. */
  59141. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59142. /**
  59143. * Returns true if the current Vector3 coordinates equals the given floats
  59144. * @param x defines the x coordinate of the operand
  59145. * @param y defines the y coordinate of the operand
  59146. * @param z defines the z coordinate of the operand
  59147. * @returns true if both vectors are equals
  59148. */
  59149. equalsToFloats(x: number, y: number, z: number): boolean;
  59150. /**
  59151. * Multiplies the current Vector3 coordinates by the given ones
  59152. * @param otherVector defines the second operand
  59153. * @returns the current updated Vector3
  59154. */
  59155. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59156. /**
  59157. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59158. * @param otherVector defines the second operand
  59159. * @returns the new Vector3
  59160. */
  59161. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59162. /**
  59163. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59164. * @param otherVector defines the second operand
  59165. * @param result defines the Vector3 object where to store the result
  59166. * @returns the current Vector3
  59167. */
  59168. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59169. /**
  59170. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59171. * @param x defines the x coordinate of the operand
  59172. * @param y defines the y coordinate of the operand
  59173. * @param z defines the z coordinate of the operand
  59174. * @returns the new Vector3
  59175. */
  59176. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59177. /**
  59178. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59179. * @param otherVector defines the second operand
  59180. * @returns the new Vector3
  59181. */
  59182. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59183. /**
  59184. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59185. * @param otherVector defines the second operand
  59186. * @param result defines the Vector3 object where to store the result
  59187. * @returns the current Vector3
  59188. */
  59189. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59190. /**
  59191. * Divides the current Vector3 coordinates by the given ones.
  59192. * @param otherVector defines the second operand
  59193. * @returns the current updated Vector3
  59194. */
  59195. divideInPlace(otherVector: Vector3): Vector3;
  59196. /**
  59197. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59198. * @param other defines the second operand
  59199. * @returns the current updated Vector3
  59200. */
  59201. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59202. /**
  59203. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59204. * @param other defines the second operand
  59205. * @returns the current updated Vector3
  59206. */
  59207. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59208. /**
  59209. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59210. * @param x defines the x coordinate of the operand
  59211. * @param y defines the y coordinate of the operand
  59212. * @param z defines the z coordinate of the operand
  59213. * @returns the current updated Vector3
  59214. */
  59215. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59216. /**
  59217. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59218. * @param x defines the x coordinate of the operand
  59219. * @param y defines the y coordinate of the operand
  59220. * @param z defines the z coordinate of the operand
  59221. * @returns the current updated Vector3
  59222. */
  59223. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59224. /**
  59225. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59226. * Check if is non uniform within a certain amount of decimal places to account for this
  59227. * @param epsilon the amount the values can differ
  59228. * @returns if the the vector is non uniform to a certain number of decimal places
  59229. */
  59230. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59231. /**
  59232. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59233. */
  59234. readonly isNonUniform: boolean;
  59235. /**
  59236. * Gets a new Vector3 from current Vector3 floored values
  59237. * @returns a new Vector3
  59238. */
  59239. floor(): Vector3;
  59240. /**
  59241. * Gets a new Vector3 from current Vector3 floored values
  59242. * @returns a new Vector3
  59243. */
  59244. fract(): Vector3;
  59245. /**
  59246. * Gets the length of the Vector3
  59247. * @returns the length of the Vecto3
  59248. */
  59249. length(): number;
  59250. /**
  59251. * Gets the squared length of the Vector3
  59252. * @returns squared length of the Vector3
  59253. */
  59254. lengthSquared(): number;
  59255. /**
  59256. * Normalize the current Vector3.
  59257. * Please note that this is an in place operation.
  59258. * @returns the current updated Vector3
  59259. */
  59260. normalize(): Vector3;
  59261. /**
  59262. * Reorders the x y z properties of the vector in place
  59263. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59264. * @returns the current updated vector
  59265. */
  59266. reorderInPlace(order: string): this;
  59267. /**
  59268. * Rotates the vector around 0,0,0 by a quaternion
  59269. * @param quaternion the rotation quaternion
  59270. * @param result vector to store the result
  59271. * @returns the resulting vector
  59272. */
  59273. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59274. /**
  59275. * Rotates a vector around a given point
  59276. * @param quaternion the rotation quaternion
  59277. * @param point the point to rotate around
  59278. * @param result vector to store the result
  59279. * @returns the resulting vector
  59280. */
  59281. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59282. /**
  59283. * Normalize the current Vector3 with the given input length.
  59284. * Please note that this is an in place operation.
  59285. * @param len the length of the vector
  59286. * @returns the current updated Vector3
  59287. */
  59288. normalizeFromLength(len: number): Vector3;
  59289. /**
  59290. * Normalize the current Vector3 to a new vector
  59291. * @returns the new Vector3
  59292. */
  59293. normalizeToNew(): Vector3;
  59294. /**
  59295. * Normalize the current Vector3 to the reference
  59296. * @param reference define the Vector3 to update
  59297. * @returns the updated Vector3
  59298. */
  59299. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59300. /**
  59301. * Creates a new Vector3 copied from the current Vector3
  59302. * @returns the new Vector3
  59303. */
  59304. clone(): Vector3;
  59305. /**
  59306. * Copies the given vector coordinates to the current Vector3 ones
  59307. * @param source defines the source Vector3
  59308. * @returns the current updated Vector3
  59309. */
  59310. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59311. /**
  59312. * Copies the given floats to the current Vector3 coordinates
  59313. * @param x defines the x coordinate of the operand
  59314. * @param y defines the y coordinate of the operand
  59315. * @param z defines the z coordinate of the operand
  59316. * @returns the current updated Vector3
  59317. */
  59318. copyFromFloats(x: number, y: number, z: number): Vector3;
  59319. /**
  59320. * Copies the given floats to the current Vector3 coordinates
  59321. * @param x defines the x coordinate of the operand
  59322. * @param y defines the y coordinate of the operand
  59323. * @param z defines the z coordinate of the operand
  59324. * @returns the current updated Vector3
  59325. */
  59326. set(x: number, y: number, z: number): Vector3;
  59327. /**
  59328. * Copies the given float to the current Vector3 coordinates
  59329. * @param v defines the x, y and z coordinates of the operand
  59330. * @returns the current updated Vector3
  59331. */
  59332. setAll(v: number): Vector3;
  59333. /**
  59334. * Get the clip factor between two vectors
  59335. * @param vector0 defines the first operand
  59336. * @param vector1 defines the second operand
  59337. * @param axis defines the axis to use
  59338. * @param size defines the size along the axis
  59339. * @returns the clip factor
  59340. */
  59341. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59342. /**
  59343. * Get angle between two vectors
  59344. * @param vector0 angle between vector0 and vector1
  59345. * @param vector1 angle between vector0 and vector1
  59346. * @param normal direction of the normal
  59347. * @return the angle between vector0 and vector1
  59348. */
  59349. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59350. /**
  59351. * Returns a new Vector3 set from the index "offset" of the given array
  59352. * @param array defines the source array
  59353. * @param offset defines the offset in the source array
  59354. * @returns the new Vector3
  59355. */
  59356. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59357. /**
  59358. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59359. * This function is deprecated. Use FromArray instead
  59360. * @param array defines the source array
  59361. * @param offset defines the offset in the source array
  59362. * @returns the new Vector3
  59363. */
  59364. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59365. /**
  59366. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59367. * @param array defines the source array
  59368. * @param offset defines the offset in the source array
  59369. * @param result defines the Vector3 where to store the result
  59370. */
  59371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59372. /**
  59373. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59374. * This function is deprecated. Use FromArrayToRef instead.
  59375. * @param array defines the source array
  59376. * @param offset defines the offset in the source array
  59377. * @param result defines the Vector3 where to store the result
  59378. */
  59379. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59380. /**
  59381. * Sets the given vector "result" with the given floats.
  59382. * @param x defines the x coordinate of the source
  59383. * @param y defines the y coordinate of the source
  59384. * @param z defines the z coordinate of the source
  59385. * @param result defines the Vector3 where to store the result
  59386. */
  59387. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59388. /**
  59389. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59390. * @returns a new empty Vector3
  59391. */
  59392. static Zero(): Vector3;
  59393. /**
  59394. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59395. * @returns a new unit Vector3
  59396. */
  59397. static One(): Vector3;
  59398. /**
  59399. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59400. * @returns a new up Vector3
  59401. */
  59402. static Up(): Vector3;
  59403. /**
  59404. * Gets a up Vector3 that must not be updated
  59405. */
  59406. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59407. /**
  59408. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59409. * @returns a new down Vector3
  59410. */
  59411. static Down(): Vector3;
  59412. /**
  59413. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59414. * @returns a new forward Vector3
  59415. */
  59416. static Forward(): Vector3;
  59417. /**
  59418. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59419. * @returns a new forward Vector3
  59420. */
  59421. static Backward(): Vector3;
  59422. /**
  59423. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59424. * @returns a new right Vector3
  59425. */
  59426. static Right(): Vector3;
  59427. /**
  59428. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59429. * @returns a new left Vector3
  59430. */
  59431. static Left(): Vector3;
  59432. /**
  59433. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59434. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59435. * @param vector defines the Vector3 to transform
  59436. * @param transformation defines the transformation matrix
  59437. * @returns the transformed Vector3
  59438. */
  59439. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59440. /**
  59441. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59442. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59443. * @param vector defines the Vector3 to transform
  59444. * @param transformation defines the transformation matrix
  59445. * @param result defines the Vector3 where to store the result
  59446. */
  59447. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59448. /**
  59449. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59450. * This method computes tranformed coordinates only, not transformed direction vectors
  59451. * @param x define the x coordinate of the source vector
  59452. * @param y define the y coordinate of the source vector
  59453. * @param z define the z coordinate of the source vector
  59454. * @param transformation defines the transformation matrix
  59455. * @param result defines the Vector3 where to store the result
  59456. */
  59457. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59458. /**
  59459. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59460. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59461. * @param vector defines the Vector3 to transform
  59462. * @param transformation defines the transformation matrix
  59463. * @returns the new Vector3
  59464. */
  59465. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59466. /**
  59467. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59468. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59469. * @param vector defines the Vector3 to transform
  59470. * @param transformation defines the transformation matrix
  59471. * @param result defines the Vector3 where to store the result
  59472. */
  59473. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59474. /**
  59475. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59476. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59477. * @param x define the x coordinate of the source vector
  59478. * @param y define the y coordinate of the source vector
  59479. * @param z define the z coordinate of the source vector
  59480. * @param transformation defines the transformation matrix
  59481. * @param result defines the Vector3 where to store the result
  59482. */
  59483. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59484. /**
  59485. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59486. * @param value1 defines the first control point
  59487. * @param value2 defines the second control point
  59488. * @param value3 defines the third control point
  59489. * @param value4 defines the fourth control point
  59490. * @param amount defines the amount on the spline to use
  59491. * @returns the new Vector3
  59492. */
  59493. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59494. /**
  59495. * 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"
  59496. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59497. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59498. * @param value defines the current value
  59499. * @param min defines the lower range value
  59500. * @param max defines the upper range value
  59501. * @returns the new Vector3
  59502. */
  59503. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59504. /**
  59505. * 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"
  59506. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59507. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59508. * @param value defines the current value
  59509. * @param min defines the lower range value
  59510. * @param max defines the upper range value
  59511. * @param result defines the Vector3 where to store the result
  59512. */
  59513. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59514. /**
  59515. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59516. * @param value1 defines the first control point
  59517. * @param tangent1 defines the first tangent vector
  59518. * @param value2 defines the second control point
  59519. * @param tangent2 defines the second tangent vector
  59520. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59521. * @returns the new Vector3
  59522. */
  59523. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59524. /**
  59525. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59526. * @param start defines the start value
  59527. * @param end defines the end value
  59528. * @param amount max defines amount between both (between 0 and 1)
  59529. * @returns the new Vector3
  59530. */
  59531. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59532. /**
  59533. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59534. * @param start defines the start value
  59535. * @param end defines the end value
  59536. * @param amount max defines amount between both (between 0 and 1)
  59537. * @param result defines the Vector3 where to store the result
  59538. */
  59539. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59540. /**
  59541. * Returns the dot product (float) between the vectors "left" and "right"
  59542. * @param left defines the left operand
  59543. * @param right defines the right operand
  59544. * @returns the dot product
  59545. */
  59546. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59547. /**
  59548. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59549. * The cross product is then orthogonal to both "left" and "right"
  59550. * @param left defines the left operand
  59551. * @param right defines the right operand
  59552. * @returns the cross product
  59553. */
  59554. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59555. /**
  59556. * Sets the given vector "result" with the cross product of "left" and "right"
  59557. * The cross product is then orthogonal to both "left" and "right"
  59558. * @param left defines the left operand
  59559. * @param right defines the right operand
  59560. * @param result defines the Vector3 where to store the result
  59561. */
  59562. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59563. /**
  59564. * Returns a new Vector3 as the normalization of the given vector
  59565. * @param vector defines the Vector3 to normalize
  59566. * @returns the new Vector3
  59567. */
  59568. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59569. /**
  59570. * Sets the given vector "result" with the normalization of the given first vector
  59571. * @param vector defines the Vector3 to normalize
  59572. * @param result defines the Vector3 where to store the result
  59573. */
  59574. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59575. /**
  59576. * Project a Vector3 onto screen space
  59577. * @param vector defines the Vector3 to project
  59578. * @param world defines the world matrix to use
  59579. * @param transform defines the transform (view x projection) matrix to use
  59580. * @param viewport defines the screen viewport to use
  59581. * @returns the new Vector3
  59582. */
  59583. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59584. /** @hidden */
  59585. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59586. /**
  59587. * Unproject from screen space to object space
  59588. * @param source defines the screen space Vector3 to use
  59589. * @param viewportWidth defines the current width of the viewport
  59590. * @param viewportHeight defines the current height of the viewport
  59591. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59592. * @param transform defines the transform (view x projection) matrix to use
  59593. * @returns the new Vector3
  59594. */
  59595. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59596. /**
  59597. * Unproject from screen space to object space
  59598. * @param source defines the screen space Vector3 to use
  59599. * @param viewportWidth defines the current width of the viewport
  59600. * @param viewportHeight defines the current height of the viewport
  59601. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59602. * @param view defines the view matrix to use
  59603. * @param projection defines the projection matrix to use
  59604. * @returns the new Vector3
  59605. */
  59606. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59607. /**
  59608. * Unproject from screen space to object space
  59609. * @param source defines the screen space Vector3 to use
  59610. * @param viewportWidth defines the current width of the viewport
  59611. * @param viewportHeight defines the current height of the viewport
  59612. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59613. * @param view defines the view matrix to use
  59614. * @param projection defines the projection matrix to use
  59615. * @param result defines the Vector3 where to store the result
  59616. */
  59617. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59618. /**
  59619. * Unproject from screen space to object space
  59620. * @param sourceX defines the screen space x coordinate to use
  59621. * @param sourceY defines the screen space y coordinate to use
  59622. * @param sourceZ defines the screen space z coordinate to use
  59623. * @param viewportWidth defines the current width of the viewport
  59624. * @param viewportHeight defines the current height of the viewport
  59625. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59626. * @param view defines the view matrix to use
  59627. * @param projection defines the projection matrix to use
  59628. * @param result defines the Vector3 where to store the result
  59629. */
  59630. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59631. /**
  59632. * Gets the minimal coordinate values between two Vector3
  59633. * @param left defines the first operand
  59634. * @param right defines the second operand
  59635. * @returns the new Vector3
  59636. */
  59637. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59638. /**
  59639. * Gets the maximal coordinate values between two Vector3
  59640. * @param left defines the first operand
  59641. * @param right defines the second operand
  59642. * @returns the new Vector3
  59643. */
  59644. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59645. /**
  59646. * Returns the distance between the vectors "value1" and "value2"
  59647. * @param value1 defines the first operand
  59648. * @param value2 defines the second operand
  59649. * @returns the distance
  59650. */
  59651. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59652. /**
  59653. * Returns the squared distance between the vectors "value1" and "value2"
  59654. * @param value1 defines the first operand
  59655. * @param value2 defines the second operand
  59656. * @returns the squared distance
  59657. */
  59658. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59659. /**
  59660. * Returns a new Vector3 located at the center between "value1" and "value2"
  59661. * @param value1 defines the first operand
  59662. * @param value2 defines the second operand
  59663. * @returns the new Vector3
  59664. */
  59665. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59666. /**
  59667. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59668. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59669. * to something in order to rotate it from its local system to the given target system
  59670. * Note: axis1, axis2 and axis3 are normalized during this operation
  59671. * @param axis1 defines the first axis
  59672. * @param axis2 defines the second axis
  59673. * @param axis3 defines the third axis
  59674. * @returns a new Vector3
  59675. */
  59676. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59677. /**
  59678. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59679. * @param axis1 defines the first axis
  59680. * @param axis2 defines the second axis
  59681. * @param axis3 defines the third axis
  59682. * @param ref defines the Vector3 where to store the result
  59683. */
  59684. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59685. }
  59686. /**
  59687. * Vector4 class created for EulerAngle class conversion to Quaternion
  59688. */
  59689. export class Vector4 {
  59690. /** x value of the vector */
  59691. x: number;
  59692. /** y value of the vector */
  59693. y: number;
  59694. /** z value of the vector */
  59695. z: number;
  59696. /** w value of the vector */
  59697. w: number;
  59698. /**
  59699. * Creates a Vector4 object from the given floats.
  59700. * @param x x value of the vector
  59701. * @param y y value of the vector
  59702. * @param z z value of the vector
  59703. * @param w w value of the vector
  59704. */
  59705. constructor(
  59706. /** x value of the vector */
  59707. x: number,
  59708. /** y value of the vector */
  59709. y: number,
  59710. /** z value of the vector */
  59711. z: number,
  59712. /** w value of the vector */
  59713. w: number);
  59714. /**
  59715. * Returns the string with the Vector4 coordinates.
  59716. * @returns a string containing all the vector values
  59717. */
  59718. toString(): string;
  59719. /**
  59720. * Returns the string "Vector4".
  59721. * @returns "Vector4"
  59722. */
  59723. getClassName(): string;
  59724. /**
  59725. * Returns the Vector4 hash code.
  59726. * @returns a unique hash code
  59727. */
  59728. getHashCode(): number;
  59729. /**
  59730. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59731. * @returns the resulting array
  59732. */
  59733. asArray(): number[];
  59734. /**
  59735. * Populates the given array from the given index with the Vector4 coordinates.
  59736. * @param array array to populate
  59737. * @param index index of the array to start at (default: 0)
  59738. * @returns the Vector4.
  59739. */
  59740. toArray(array: FloatArray, index?: number): Vector4;
  59741. /**
  59742. * Adds the given vector to the current Vector4.
  59743. * @param otherVector the vector to add
  59744. * @returns the updated Vector4.
  59745. */
  59746. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59747. /**
  59748. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59749. * @param otherVector the vector to add
  59750. * @returns the resulting vector
  59751. */
  59752. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59753. /**
  59754. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59755. * @param otherVector the vector to add
  59756. * @param result the vector to store the result
  59757. * @returns the current Vector4.
  59758. */
  59759. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59760. /**
  59761. * Subtract in place the given vector from the current Vector4.
  59762. * @param otherVector the vector to subtract
  59763. * @returns the updated Vector4.
  59764. */
  59765. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59766. /**
  59767. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59768. * @param otherVector the vector to add
  59769. * @returns the new vector with the result
  59770. */
  59771. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59772. /**
  59773. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59774. * @param otherVector the vector to subtract
  59775. * @param result the vector to store the result
  59776. * @returns the current Vector4.
  59777. */
  59778. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59779. /**
  59780. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59781. */
  59782. /**
  59783. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59784. * @param x value to subtract
  59785. * @param y value to subtract
  59786. * @param z value to subtract
  59787. * @param w value to subtract
  59788. * @returns new vector containing the result
  59789. */
  59790. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59791. /**
  59792. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59793. * @param x value to subtract
  59794. * @param y value to subtract
  59795. * @param z value to subtract
  59796. * @param w value to subtract
  59797. * @param result the vector to store the result in
  59798. * @returns the current Vector4.
  59799. */
  59800. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59801. /**
  59802. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59803. * @returns a new vector with the negated values
  59804. */
  59805. negate(): Vector4;
  59806. /**
  59807. * Multiplies the current Vector4 coordinates by scale (float).
  59808. * @param scale the number to scale with
  59809. * @returns the updated Vector4.
  59810. */
  59811. scaleInPlace(scale: number): Vector4;
  59812. /**
  59813. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59814. * @param scale the number to scale with
  59815. * @returns a new vector with the result
  59816. */
  59817. scale(scale: number): Vector4;
  59818. /**
  59819. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59820. * @param scale the number to scale with
  59821. * @param result a vector to store the result in
  59822. * @returns the current Vector4.
  59823. */
  59824. scaleToRef(scale: number, result: Vector4): Vector4;
  59825. /**
  59826. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59827. * @param scale defines the scale factor
  59828. * @param result defines the Vector4 object where to store the result
  59829. * @returns the unmodified current Vector4
  59830. */
  59831. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59832. /**
  59833. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59834. * @param otherVector the vector to compare against
  59835. * @returns true if they are equal
  59836. */
  59837. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59838. /**
  59839. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59840. * @param otherVector vector to compare against
  59841. * @param epsilon (Default: very small number)
  59842. * @returns true if they are equal
  59843. */
  59844. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59845. /**
  59846. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59847. * @param x x value to compare against
  59848. * @param y y value to compare against
  59849. * @param z z value to compare against
  59850. * @param w w value to compare against
  59851. * @returns true if equal
  59852. */
  59853. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59854. /**
  59855. * Multiplies in place the current Vector4 by the given one.
  59856. * @param otherVector vector to multiple with
  59857. * @returns the updated Vector4.
  59858. */
  59859. multiplyInPlace(otherVector: Vector4): Vector4;
  59860. /**
  59861. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59862. * @param otherVector vector to multiple with
  59863. * @returns resulting new vector
  59864. */
  59865. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59866. /**
  59867. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59868. * @param otherVector vector to multiple with
  59869. * @param result vector to store the result
  59870. * @returns the current Vector4.
  59871. */
  59872. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59873. /**
  59874. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59875. * @param x x value multiply with
  59876. * @param y y value multiply with
  59877. * @param z z value multiply with
  59878. * @param w w value multiply with
  59879. * @returns resulting new vector
  59880. */
  59881. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59882. /**
  59883. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59884. * @param otherVector vector to devide with
  59885. * @returns resulting new vector
  59886. */
  59887. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59888. /**
  59889. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59890. * @param otherVector vector to devide with
  59891. * @param result vector to store the result
  59892. * @returns the current Vector4.
  59893. */
  59894. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59895. /**
  59896. * Divides the current Vector3 coordinates by the given ones.
  59897. * @param otherVector vector to devide with
  59898. * @returns the updated Vector3.
  59899. */
  59900. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59901. /**
  59902. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59903. * @param other defines the second operand
  59904. * @returns the current updated Vector4
  59905. */
  59906. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59907. /**
  59908. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59909. * @param other defines the second operand
  59910. * @returns the current updated Vector4
  59911. */
  59912. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59913. /**
  59914. * Gets a new Vector4 from current Vector4 floored values
  59915. * @returns a new Vector4
  59916. */
  59917. floor(): Vector4;
  59918. /**
  59919. * Gets a new Vector4 from current Vector3 floored values
  59920. * @returns a new Vector4
  59921. */
  59922. fract(): Vector4;
  59923. /**
  59924. * Returns the Vector4 length (float).
  59925. * @returns the length
  59926. */
  59927. length(): number;
  59928. /**
  59929. * Returns the Vector4 squared length (float).
  59930. * @returns the length squared
  59931. */
  59932. lengthSquared(): number;
  59933. /**
  59934. * Normalizes in place the Vector4.
  59935. * @returns the updated Vector4.
  59936. */
  59937. normalize(): Vector4;
  59938. /**
  59939. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59940. * @returns this converted to a new vector3
  59941. */
  59942. toVector3(): Vector3;
  59943. /**
  59944. * Returns a new Vector4 copied from the current one.
  59945. * @returns the new cloned vector
  59946. */
  59947. clone(): Vector4;
  59948. /**
  59949. * Updates the current Vector4 with the given one coordinates.
  59950. * @param source the source vector to copy from
  59951. * @returns the updated Vector4.
  59952. */
  59953. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59954. /**
  59955. * Updates the current Vector4 coordinates with the given floats.
  59956. * @param x float to copy from
  59957. * @param y float to copy from
  59958. * @param z float to copy from
  59959. * @param w float to copy from
  59960. * @returns the updated Vector4.
  59961. */
  59962. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59963. /**
  59964. * Updates the current Vector4 coordinates with the given floats.
  59965. * @param x float to set from
  59966. * @param y float to set from
  59967. * @param z float to set from
  59968. * @param w float to set from
  59969. * @returns the updated Vector4.
  59970. */
  59971. set(x: number, y: number, z: number, w: number): Vector4;
  59972. /**
  59973. * Copies the given float to the current Vector3 coordinates
  59974. * @param v defines the x, y, z and w coordinates of the operand
  59975. * @returns the current updated Vector3
  59976. */
  59977. setAll(v: number): Vector4;
  59978. /**
  59979. * Returns a new Vector4 set from the starting index of the given array.
  59980. * @param array the array to pull values from
  59981. * @param offset the offset into the array to start at
  59982. * @returns the new vector
  59983. */
  59984. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59985. /**
  59986. * Updates the given vector "result" from the starting index of the given array.
  59987. * @param array the array to pull values from
  59988. * @param offset the offset into the array to start at
  59989. * @param result the vector to store the result in
  59990. */
  59991. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59992. /**
  59993. * Updates the given vector "result" from the starting index of the given Float32Array.
  59994. * @param array the array to pull values from
  59995. * @param offset the offset into the array to start at
  59996. * @param result the vector to store the result in
  59997. */
  59998. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59999. /**
  60000. * Updates the given vector "result" coordinates from the given floats.
  60001. * @param x float to set from
  60002. * @param y float to set from
  60003. * @param z float to set from
  60004. * @param w float to set from
  60005. * @param result the vector to the floats in
  60006. */
  60007. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60008. /**
  60009. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60010. * @returns the new vector
  60011. */
  60012. static Zero(): Vector4;
  60013. /**
  60014. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60015. * @returns the new vector
  60016. */
  60017. static One(): Vector4;
  60018. /**
  60019. * Returns a new normalized Vector4 from the given one.
  60020. * @param vector the vector to normalize
  60021. * @returns the vector
  60022. */
  60023. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60024. /**
  60025. * Updates the given vector "result" from the normalization of the given one.
  60026. * @param vector the vector to normalize
  60027. * @param result the vector to store the result in
  60028. */
  60029. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60030. /**
  60031. * Returns a vector with the minimum values from the left and right vectors
  60032. * @param left left vector to minimize
  60033. * @param right right vector to minimize
  60034. * @returns a new vector with the minimum of the left and right vector values
  60035. */
  60036. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60037. /**
  60038. * Returns a vector with the maximum values from the left and right vectors
  60039. * @param left left vector to maximize
  60040. * @param right right vector to maximize
  60041. * @returns a new vector with the maximum of the left and right vector values
  60042. */
  60043. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60044. /**
  60045. * Returns the distance (float) between the vectors "value1" and "value2".
  60046. * @param value1 value to calulate the distance between
  60047. * @param value2 value to calulate the distance between
  60048. * @return the distance between the two vectors
  60049. */
  60050. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60051. /**
  60052. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60053. * @param value1 value to calulate the distance between
  60054. * @param value2 value to calulate the distance between
  60055. * @return the distance between the two vectors squared
  60056. */
  60057. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60058. /**
  60059. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60060. * @param value1 value to calulate the center between
  60061. * @param value2 value to calulate the center between
  60062. * @return the center between the two vectors
  60063. */
  60064. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60065. /**
  60066. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60067. * This methods computes transformed normalized direction vectors only.
  60068. * @param vector the vector to transform
  60069. * @param transformation the transformation matrix to apply
  60070. * @returns the new vector
  60071. */
  60072. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60073. /**
  60074. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60075. * This methods computes transformed normalized direction vectors only.
  60076. * @param vector the vector to transform
  60077. * @param transformation the transformation matrix to apply
  60078. * @param result the vector to store the result in
  60079. */
  60080. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60081. /**
  60082. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60083. * This methods computes transformed normalized direction vectors only.
  60084. * @param x value to transform
  60085. * @param y value to transform
  60086. * @param z value to transform
  60087. * @param w value to transform
  60088. * @param transformation the transformation matrix to apply
  60089. * @param result the vector to store the results in
  60090. */
  60091. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60092. /**
  60093. * Creates a new Vector4 from a Vector3
  60094. * @param source defines the source data
  60095. * @param w defines the 4th component (default is 0)
  60096. * @returns a new Vector4
  60097. */
  60098. static FromVector3(source: Vector3, w?: number): Vector4;
  60099. }
  60100. /**
  60101. * Interface for the size containing width and height
  60102. */
  60103. export interface ISize {
  60104. /**
  60105. * Width
  60106. */
  60107. width: number;
  60108. /**
  60109. * Heighht
  60110. */
  60111. height: number;
  60112. }
  60113. /**
  60114. * Size containing widht and height
  60115. */
  60116. export class Size implements ISize {
  60117. /**
  60118. * Width
  60119. */
  60120. width: number;
  60121. /**
  60122. * Height
  60123. */
  60124. height: number;
  60125. /**
  60126. * Creates a Size object from the given width and height (floats).
  60127. * @param width width of the new size
  60128. * @param height height of the new size
  60129. */
  60130. constructor(width: number, height: number);
  60131. /**
  60132. * Returns a string with the Size width and height
  60133. * @returns a string with the Size width and height
  60134. */
  60135. toString(): string;
  60136. /**
  60137. * "Size"
  60138. * @returns the string "Size"
  60139. */
  60140. getClassName(): string;
  60141. /**
  60142. * Returns the Size hash code.
  60143. * @returns a hash code for a unique width and height
  60144. */
  60145. getHashCode(): number;
  60146. /**
  60147. * Updates the current size from the given one.
  60148. * @param src the given size
  60149. */
  60150. copyFrom(src: Size): void;
  60151. /**
  60152. * Updates in place the current Size from the given floats.
  60153. * @param width width of the new size
  60154. * @param height height of the new size
  60155. * @returns the updated Size.
  60156. */
  60157. copyFromFloats(width: number, height: number): Size;
  60158. /**
  60159. * Updates in place the current Size from the given floats.
  60160. * @param width width to set
  60161. * @param height height to set
  60162. * @returns the updated Size.
  60163. */
  60164. set(width: number, height: number): Size;
  60165. /**
  60166. * Multiplies the width and height by numbers
  60167. * @param w factor to multiple the width by
  60168. * @param h factor to multiple the height by
  60169. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60170. */
  60171. multiplyByFloats(w: number, h: number): Size;
  60172. /**
  60173. * Clones the size
  60174. * @returns a new Size copied from the given one.
  60175. */
  60176. clone(): Size;
  60177. /**
  60178. * True if the current Size and the given one width and height are strictly equal.
  60179. * @param other the other size to compare against
  60180. * @returns True if the current Size and the given one width and height are strictly equal.
  60181. */
  60182. equals(other: Size): boolean;
  60183. /**
  60184. * The surface of the Size : width * height (float).
  60185. */
  60186. readonly surface: number;
  60187. /**
  60188. * Create a new size of zero
  60189. * @returns a new Size set to (0.0, 0.0)
  60190. */
  60191. static Zero(): Size;
  60192. /**
  60193. * Sums the width and height of two sizes
  60194. * @param otherSize size to add to this size
  60195. * @returns a new Size set as the addition result of the current Size and the given one.
  60196. */
  60197. add(otherSize: Size): Size;
  60198. /**
  60199. * Subtracts the width and height of two
  60200. * @param otherSize size to subtract to this size
  60201. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60202. */
  60203. subtract(otherSize: Size): Size;
  60204. /**
  60205. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60206. * @param start starting size to lerp between
  60207. * @param end end size to lerp between
  60208. * @param amount amount to lerp between the start and end values
  60209. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60210. */
  60211. static Lerp(start: Size, end: Size, amount: number): Size;
  60212. }
  60213. /**
  60214. * Class used to store quaternion data
  60215. * @see https://en.wikipedia.org/wiki/Quaternion
  60216. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60217. */
  60218. export class Quaternion {
  60219. /** defines the first component (0 by default) */
  60220. x: number;
  60221. /** defines the second component (0 by default) */
  60222. y: number;
  60223. /** defines the third component (0 by default) */
  60224. z: number;
  60225. /** defines the fourth component (1.0 by default) */
  60226. w: number;
  60227. /**
  60228. * Creates a new Quaternion from the given floats
  60229. * @param x defines the first component (0 by default)
  60230. * @param y defines the second component (0 by default)
  60231. * @param z defines the third component (0 by default)
  60232. * @param w defines the fourth component (1.0 by default)
  60233. */
  60234. constructor(
  60235. /** defines the first component (0 by default) */
  60236. x?: number,
  60237. /** defines the second component (0 by default) */
  60238. y?: number,
  60239. /** defines the third component (0 by default) */
  60240. z?: number,
  60241. /** defines the fourth component (1.0 by default) */
  60242. w?: number);
  60243. /**
  60244. * Gets a string representation for the current quaternion
  60245. * @returns a string with the Quaternion coordinates
  60246. */
  60247. toString(): string;
  60248. /**
  60249. * Gets the class name of the quaternion
  60250. * @returns the string "Quaternion"
  60251. */
  60252. getClassName(): string;
  60253. /**
  60254. * Gets a hash code for this quaternion
  60255. * @returns the quaternion hash code
  60256. */
  60257. getHashCode(): number;
  60258. /**
  60259. * Copy the quaternion to an array
  60260. * @returns a new array populated with 4 elements from the quaternion coordinates
  60261. */
  60262. asArray(): number[];
  60263. /**
  60264. * Check if two quaternions are equals
  60265. * @param otherQuaternion defines the second operand
  60266. * @return true if the current quaternion and the given one coordinates are strictly equals
  60267. */
  60268. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60269. /**
  60270. * Clone the current quaternion
  60271. * @returns a new quaternion copied from the current one
  60272. */
  60273. clone(): Quaternion;
  60274. /**
  60275. * Copy a quaternion to the current one
  60276. * @param other defines the other quaternion
  60277. * @returns the updated current quaternion
  60278. */
  60279. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60280. /**
  60281. * Updates the current quaternion with the given float coordinates
  60282. * @param x defines the x coordinate
  60283. * @param y defines the y coordinate
  60284. * @param z defines the z coordinate
  60285. * @param w defines the w coordinate
  60286. * @returns the updated current quaternion
  60287. */
  60288. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60289. /**
  60290. * Updates the current quaternion from the given float coordinates
  60291. * @param x defines the x coordinate
  60292. * @param y defines the y coordinate
  60293. * @param z defines the z coordinate
  60294. * @param w defines the w coordinate
  60295. * @returns the updated current quaternion
  60296. */
  60297. set(x: number, y: number, z: number, w: number): Quaternion;
  60298. /**
  60299. * Adds two quaternions
  60300. * @param other defines the second operand
  60301. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60302. */
  60303. add(other: DeepImmutable<Quaternion>): Quaternion;
  60304. /**
  60305. * Add a quaternion to the current one
  60306. * @param other defines the quaternion to add
  60307. * @returns the current quaternion
  60308. */
  60309. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60310. /**
  60311. * Subtract two quaternions
  60312. * @param other defines the second operand
  60313. * @returns a new quaternion as the subtraction result of the given one from the current one
  60314. */
  60315. subtract(other: Quaternion): Quaternion;
  60316. /**
  60317. * Multiplies the current quaternion by a scale factor
  60318. * @param value defines the scale factor
  60319. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60320. */
  60321. scale(value: number): Quaternion;
  60322. /**
  60323. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60324. * @param scale defines the scale factor
  60325. * @param result defines the Quaternion object where to store the result
  60326. * @returns the unmodified current quaternion
  60327. */
  60328. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60329. /**
  60330. * Multiplies in place the current quaternion by a scale factor
  60331. * @param value defines the scale factor
  60332. * @returns the current modified quaternion
  60333. */
  60334. scaleInPlace(value: number): Quaternion;
  60335. /**
  60336. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60337. * @param scale defines the scale factor
  60338. * @param result defines the Quaternion object where to store the result
  60339. * @returns the unmodified current quaternion
  60340. */
  60341. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60342. /**
  60343. * Multiplies two quaternions
  60344. * @param q1 defines the second operand
  60345. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60346. */
  60347. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60348. /**
  60349. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60350. * @param q1 defines the second operand
  60351. * @param result defines the target quaternion
  60352. * @returns the current quaternion
  60353. */
  60354. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60355. /**
  60356. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60357. * @param q1 defines the second operand
  60358. * @returns the currentupdated quaternion
  60359. */
  60360. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60361. /**
  60362. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60363. * @param ref defines the target quaternion
  60364. * @returns the current quaternion
  60365. */
  60366. conjugateToRef(ref: Quaternion): Quaternion;
  60367. /**
  60368. * Conjugates in place (1-q) the current quaternion
  60369. * @returns the current updated quaternion
  60370. */
  60371. conjugateInPlace(): Quaternion;
  60372. /**
  60373. * Conjugates in place (1-q) the current quaternion
  60374. * @returns a new quaternion
  60375. */
  60376. conjugate(): Quaternion;
  60377. /**
  60378. * Gets length of current quaternion
  60379. * @returns the quaternion length (float)
  60380. */
  60381. length(): number;
  60382. /**
  60383. * Normalize in place the current quaternion
  60384. * @returns the current updated quaternion
  60385. */
  60386. normalize(): Quaternion;
  60387. /**
  60388. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60389. * @param order is a reserved parameter and is ignore for now
  60390. * @returns a new Vector3 containing the Euler angles
  60391. */
  60392. toEulerAngles(order?: string): Vector3;
  60393. /**
  60394. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60395. * @param result defines the vector which will be filled with the Euler angles
  60396. * @param order is a reserved parameter and is ignore for now
  60397. * @returns the current unchanged quaternion
  60398. */
  60399. toEulerAnglesToRef(result: Vector3): Quaternion;
  60400. /**
  60401. * Updates the given rotation matrix with the current quaternion values
  60402. * @param result defines the target matrix
  60403. * @returns the current unchanged quaternion
  60404. */
  60405. toRotationMatrix(result: Matrix): Quaternion;
  60406. /**
  60407. * Updates the current quaternion from the given rotation matrix values
  60408. * @param matrix defines the source matrix
  60409. * @returns the current updated quaternion
  60410. */
  60411. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60412. /**
  60413. * Creates a new quaternion from a rotation matrix
  60414. * @param matrix defines the source matrix
  60415. * @returns a new quaternion created from the given rotation matrix values
  60416. */
  60417. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60418. /**
  60419. * Updates the given quaternion with the given rotation matrix values
  60420. * @param matrix defines the source matrix
  60421. * @param result defines the target quaternion
  60422. */
  60423. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60424. /**
  60425. * Returns the dot product (float) between the quaternions "left" and "right"
  60426. * @param left defines the left operand
  60427. * @param right defines the right operand
  60428. * @returns the dot product
  60429. */
  60430. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60431. /**
  60432. * Checks if the two quaternions are close to each other
  60433. * @param quat0 defines the first quaternion to check
  60434. * @param quat1 defines the second quaternion to check
  60435. * @returns true if the two quaternions are close to each other
  60436. */
  60437. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60438. /**
  60439. * Creates an empty quaternion
  60440. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60441. */
  60442. static Zero(): Quaternion;
  60443. /**
  60444. * Inverse a given quaternion
  60445. * @param q defines the source quaternion
  60446. * @returns a new quaternion as the inverted current quaternion
  60447. */
  60448. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60449. /**
  60450. * Inverse a given quaternion
  60451. * @param q defines the source quaternion
  60452. * @param result the quaternion the result will be stored in
  60453. * @returns the result quaternion
  60454. */
  60455. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60456. /**
  60457. * Creates an identity quaternion
  60458. * @returns the identity quaternion
  60459. */
  60460. static Identity(): Quaternion;
  60461. /**
  60462. * Gets a boolean indicating if the given quaternion is identity
  60463. * @param quaternion defines the quaternion to check
  60464. * @returns true if the quaternion is identity
  60465. */
  60466. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60467. /**
  60468. * Creates a quaternion from a rotation around an axis
  60469. * @param axis defines the axis to use
  60470. * @param angle defines the angle to use
  60471. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60472. */
  60473. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60474. /**
  60475. * Creates a rotation around an axis and stores it into the given quaternion
  60476. * @param axis defines the axis to use
  60477. * @param angle defines the angle to use
  60478. * @param result defines the target quaternion
  60479. * @returns the target quaternion
  60480. */
  60481. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60482. /**
  60483. * Creates a new quaternion from data stored into an array
  60484. * @param array defines the data source
  60485. * @param offset defines the offset in the source array where the data starts
  60486. * @returns a new quaternion
  60487. */
  60488. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60489. /**
  60490. * Create a quaternion from Euler rotation angles
  60491. * @param x Pitch
  60492. * @param y Yaw
  60493. * @param z Roll
  60494. * @returns the new Quaternion
  60495. */
  60496. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60497. /**
  60498. * Updates a quaternion from Euler rotation angles
  60499. * @param x Pitch
  60500. * @param y Yaw
  60501. * @param z Roll
  60502. * @param result the quaternion to store the result
  60503. * @returns the updated quaternion
  60504. */
  60505. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60506. /**
  60507. * Create a quaternion from Euler rotation vector
  60508. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60509. * @returns the new Quaternion
  60510. */
  60511. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60512. /**
  60513. * Updates a quaternion from Euler rotation vector
  60514. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60515. * @param result the quaternion to store the result
  60516. * @returns the updated quaternion
  60517. */
  60518. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60519. /**
  60520. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60521. * @param yaw defines the rotation around Y axis
  60522. * @param pitch defines the rotation around X axis
  60523. * @param roll defines the rotation around Z axis
  60524. * @returns the new quaternion
  60525. */
  60526. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60527. /**
  60528. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60529. * @param yaw defines the rotation around Y axis
  60530. * @param pitch defines the rotation around X axis
  60531. * @param roll defines the rotation around Z axis
  60532. * @param result defines the target quaternion
  60533. */
  60534. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60535. /**
  60536. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60537. * @param alpha defines the rotation around first axis
  60538. * @param beta defines the rotation around second axis
  60539. * @param gamma defines the rotation around third axis
  60540. * @returns the new quaternion
  60541. */
  60542. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60543. /**
  60544. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60545. * @param alpha defines the rotation around first axis
  60546. * @param beta defines the rotation around second axis
  60547. * @param gamma defines the rotation around third axis
  60548. * @param result defines the target quaternion
  60549. */
  60550. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60551. /**
  60552. * 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)
  60553. * @param axis1 defines the first axis
  60554. * @param axis2 defines the second axis
  60555. * @param axis3 defines the third axis
  60556. * @returns the new quaternion
  60557. */
  60558. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60559. /**
  60560. * 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
  60561. * @param axis1 defines the first axis
  60562. * @param axis2 defines the second axis
  60563. * @param axis3 defines the third axis
  60564. * @param ref defines the target quaternion
  60565. */
  60566. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60567. /**
  60568. * Interpolates between two quaternions
  60569. * @param left defines first quaternion
  60570. * @param right defines second quaternion
  60571. * @param amount defines the gradient to use
  60572. * @returns the new interpolated quaternion
  60573. */
  60574. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60575. /**
  60576. * Interpolates between two quaternions and stores it into a target quaternion
  60577. * @param left defines first quaternion
  60578. * @param right defines second quaternion
  60579. * @param amount defines the gradient to use
  60580. * @param result defines the target quaternion
  60581. */
  60582. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60583. /**
  60584. * Interpolate between two quaternions using Hermite interpolation
  60585. * @param value1 defines first quaternion
  60586. * @param tangent1 defines the incoming tangent
  60587. * @param value2 defines second quaternion
  60588. * @param tangent2 defines the outgoing tangent
  60589. * @param amount defines the target quaternion
  60590. * @returns the new interpolated quaternion
  60591. */
  60592. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60593. }
  60594. /**
  60595. * Class used to store matrix data (4x4)
  60596. */
  60597. export class Matrix {
  60598. private static _updateFlagSeed;
  60599. private static _identityReadOnly;
  60600. private _isIdentity;
  60601. private _isIdentityDirty;
  60602. private _isIdentity3x2;
  60603. private _isIdentity3x2Dirty;
  60604. /**
  60605. * Gets the update flag of the matrix which is an unique number for the matrix.
  60606. * It will be incremented every time the matrix data change.
  60607. * You can use it to speed the comparison between two versions of the same matrix.
  60608. */
  60609. updateFlag: number;
  60610. private readonly _m;
  60611. /**
  60612. * Gets the internal data of the matrix
  60613. */
  60614. readonly m: DeepImmutable<Float32Array>;
  60615. /** @hidden */
  60616. _markAsUpdated(): void;
  60617. /** @hidden */
  60618. private _updateIdentityStatus;
  60619. /**
  60620. * Creates an empty matrix (filled with zeros)
  60621. */
  60622. constructor();
  60623. /**
  60624. * Check if the current matrix is identity
  60625. * @returns true is the matrix is the identity matrix
  60626. */
  60627. isIdentity(): boolean;
  60628. /**
  60629. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60630. * @returns true is the matrix is the identity matrix
  60631. */
  60632. isIdentityAs3x2(): boolean;
  60633. /**
  60634. * Gets the determinant of the matrix
  60635. * @returns the matrix determinant
  60636. */
  60637. determinant(): number;
  60638. /**
  60639. * Returns the matrix as a Float32Array
  60640. * @returns the matrix underlying array
  60641. */
  60642. toArray(): DeepImmutable<Float32Array>;
  60643. /**
  60644. * Returns the matrix as a Float32Array
  60645. * @returns the matrix underlying array.
  60646. */
  60647. asArray(): DeepImmutable<Float32Array>;
  60648. /**
  60649. * Inverts the current matrix in place
  60650. * @returns the current inverted matrix
  60651. */
  60652. invert(): Matrix;
  60653. /**
  60654. * Sets all the matrix elements to zero
  60655. * @returns the current matrix
  60656. */
  60657. reset(): Matrix;
  60658. /**
  60659. * Adds the current matrix with a second one
  60660. * @param other defines the matrix to add
  60661. * @returns a new matrix as the addition of the current matrix and the given one
  60662. */
  60663. add(other: DeepImmutable<Matrix>): Matrix;
  60664. /**
  60665. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60666. * @param other defines the matrix to add
  60667. * @param result defines the target matrix
  60668. * @returns the current matrix
  60669. */
  60670. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60671. /**
  60672. * Adds in place the given matrix to the current matrix
  60673. * @param other defines the second operand
  60674. * @returns the current updated matrix
  60675. */
  60676. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60677. /**
  60678. * Sets the given matrix to the current inverted Matrix
  60679. * @param other defines the target matrix
  60680. * @returns the unmodified current matrix
  60681. */
  60682. invertToRef(other: Matrix): Matrix;
  60683. /**
  60684. * add a value at the specified position in the current Matrix
  60685. * @param index the index of the value within the matrix. between 0 and 15.
  60686. * @param value the value to be added
  60687. * @returns the current updated matrix
  60688. */
  60689. addAtIndex(index: number, value: number): Matrix;
  60690. /**
  60691. * mutiply the specified position in the current Matrix by a value
  60692. * @param index the index of the value within the matrix. between 0 and 15.
  60693. * @param value the value to be added
  60694. * @returns the current updated matrix
  60695. */
  60696. multiplyAtIndex(index: number, value: number): Matrix;
  60697. /**
  60698. * Inserts the translation vector (using 3 floats) in the current matrix
  60699. * @param x defines the 1st component of the translation
  60700. * @param y defines the 2nd component of the translation
  60701. * @param z defines the 3rd component of the translation
  60702. * @returns the current updated matrix
  60703. */
  60704. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60705. /**
  60706. * Inserts the translation vector in the current matrix
  60707. * @param vector3 defines the translation to insert
  60708. * @returns the current updated matrix
  60709. */
  60710. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60711. /**
  60712. * Gets the translation value of the current matrix
  60713. * @returns a new Vector3 as the extracted translation from the matrix
  60714. */
  60715. getTranslation(): Vector3;
  60716. /**
  60717. * Fill a Vector3 with the extracted translation from the matrix
  60718. * @param result defines the Vector3 where to store the translation
  60719. * @returns the current matrix
  60720. */
  60721. getTranslationToRef(result: Vector3): Matrix;
  60722. /**
  60723. * Remove rotation and scaling part from the matrix
  60724. * @returns the updated matrix
  60725. */
  60726. removeRotationAndScaling(): Matrix;
  60727. /**
  60728. * Multiply two matrices
  60729. * @param other defines the second operand
  60730. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60731. */
  60732. multiply(other: DeepImmutable<Matrix>): Matrix;
  60733. /**
  60734. * Copy the current matrix from the given one
  60735. * @param other defines the source matrix
  60736. * @returns the current updated matrix
  60737. */
  60738. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60739. /**
  60740. * Populates the given array from the starting index with the current matrix values
  60741. * @param array defines the target array
  60742. * @param offset defines the offset in the target array where to start storing values
  60743. * @returns the current matrix
  60744. */
  60745. copyToArray(array: Float32Array, offset?: number): Matrix;
  60746. /**
  60747. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60748. * @param other defines the second operand
  60749. * @param result defines the matrix where to store the multiplication
  60750. * @returns the current matrix
  60751. */
  60752. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60753. /**
  60754. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60755. * @param other defines the second operand
  60756. * @param result defines the array where to store the multiplication
  60757. * @param offset defines the offset in the target array where to start storing values
  60758. * @returns the current matrix
  60759. */
  60760. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60761. /**
  60762. * Check equality between this matrix and a second one
  60763. * @param value defines the second matrix to compare
  60764. * @returns true is the current matrix and the given one values are strictly equal
  60765. */
  60766. equals(value: DeepImmutable<Matrix>): boolean;
  60767. /**
  60768. * Clone the current matrix
  60769. * @returns a new matrix from the current matrix
  60770. */
  60771. clone(): Matrix;
  60772. /**
  60773. * Returns the name of the current matrix class
  60774. * @returns the string "Matrix"
  60775. */
  60776. getClassName(): string;
  60777. /**
  60778. * Gets the hash code of the current matrix
  60779. * @returns the hash code
  60780. */
  60781. getHashCode(): number;
  60782. /**
  60783. * Decomposes the current Matrix into a translation, rotation and scaling components
  60784. * @param scale defines the scale vector3 given as a reference to update
  60785. * @param rotation defines the rotation quaternion given as a reference to update
  60786. * @param translation defines the translation vector3 given as a reference to update
  60787. * @returns true if operation was successful
  60788. */
  60789. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60790. /**
  60791. * Gets specific row of the matrix
  60792. * @param index defines the number of the row to get
  60793. * @returns the index-th row of the current matrix as a new Vector4
  60794. */
  60795. getRow(index: number): Nullable<Vector4>;
  60796. /**
  60797. * Sets the index-th row of the current matrix to the vector4 values
  60798. * @param index defines the number of the row to set
  60799. * @param row defines the target vector4
  60800. * @returns the updated current matrix
  60801. */
  60802. setRow(index: number, row: Vector4): Matrix;
  60803. /**
  60804. * Compute the transpose of the matrix
  60805. * @returns the new transposed matrix
  60806. */
  60807. transpose(): Matrix;
  60808. /**
  60809. * Compute the transpose of the matrix and store it in a given matrix
  60810. * @param result defines the target matrix
  60811. * @returns the current matrix
  60812. */
  60813. transposeToRef(result: Matrix): Matrix;
  60814. /**
  60815. * Sets the index-th row of the current matrix with the given 4 x float values
  60816. * @param index defines the row index
  60817. * @param x defines the x component to set
  60818. * @param y defines the y component to set
  60819. * @param z defines the z component to set
  60820. * @param w defines the w component to set
  60821. * @returns the updated current matrix
  60822. */
  60823. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60824. /**
  60825. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60826. * @param scale defines the scale factor
  60827. * @returns a new matrix
  60828. */
  60829. scale(scale: number): Matrix;
  60830. /**
  60831. * Scale the current matrix values by a factor to a given result matrix
  60832. * @param scale defines the scale factor
  60833. * @param result defines the matrix to store the result
  60834. * @returns the current matrix
  60835. */
  60836. scaleToRef(scale: number, result: Matrix): Matrix;
  60837. /**
  60838. * Scale the current matrix values by a factor and add the result to a given matrix
  60839. * @param scale defines the scale factor
  60840. * @param result defines the Matrix to store the result
  60841. * @returns the current matrix
  60842. */
  60843. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60844. /**
  60845. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60846. * @param ref matrix to store the result
  60847. */
  60848. toNormalMatrix(ref: Matrix): void;
  60849. /**
  60850. * Gets only rotation part of the current matrix
  60851. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60852. */
  60853. getRotationMatrix(): Matrix;
  60854. /**
  60855. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60856. * @param result defines the target matrix to store data to
  60857. * @returns the current matrix
  60858. */
  60859. getRotationMatrixToRef(result: Matrix): Matrix;
  60860. /**
  60861. * Toggles model matrix from being right handed to left handed in place and vice versa
  60862. */
  60863. toggleModelMatrixHandInPlace(): void;
  60864. /**
  60865. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60866. */
  60867. toggleProjectionMatrixHandInPlace(): void;
  60868. /**
  60869. * Creates a matrix from an array
  60870. * @param array defines the source array
  60871. * @param offset defines an offset in the source array
  60872. * @returns a new Matrix set from the starting index of the given array
  60873. */
  60874. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60875. /**
  60876. * Copy the content of an array into a given matrix
  60877. * @param array defines the source array
  60878. * @param offset defines an offset in the source array
  60879. * @param result defines the target matrix
  60880. */
  60881. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60882. /**
  60883. * Stores an array into a matrix after having multiplied each component by a given factor
  60884. * @param array defines the source array
  60885. * @param offset defines the offset in the source array
  60886. * @param scale defines the scaling factor
  60887. * @param result defines the target matrix
  60888. */
  60889. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60890. /**
  60891. * Gets an identity matrix that must not be updated
  60892. */
  60893. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60894. /**
  60895. * Stores a list of values (16) inside a given matrix
  60896. * @param initialM11 defines 1st value of 1st row
  60897. * @param initialM12 defines 2nd value of 1st row
  60898. * @param initialM13 defines 3rd value of 1st row
  60899. * @param initialM14 defines 4th value of 1st row
  60900. * @param initialM21 defines 1st value of 2nd row
  60901. * @param initialM22 defines 2nd value of 2nd row
  60902. * @param initialM23 defines 3rd value of 2nd row
  60903. * @param initialM24 defines 4th value of 2nd row
  60904. * @param initialM31 defines 1st value of 3rd row
  60905. * @param initialM32 defines 2nd value of 3rd row
  60906. * @param initialM33 defines 3rd value of 3rd row
  60907. * @param initialM34 defines 4th value of 3rd row
  60908. * @param initialM41 defines 1st value of 4th row
  60909. * @param initialM42 defines 2nd value of 4th row
  60910. * @param initialM43 defines 3rd value of 4th row
  60911. * @param initialM44 defines 4th value of 4th row
  60912. * @param result defines the target matrix
  60913. */
  60914. 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;
  60915. /**
  60916. * Creates new matrix from a list of values (16)
  60917. * @param initialM11 defines 1st value of 1st row
  60918. * @param initialM12 defines 2nd value of 1st row
  60919. * @param initialM13 defines 3rd value of 1st row
  60920. * @param initialM14 defines 4th value of 1st row
  60921. * @param initialM21 defines 1st value of 2nd row
  60922. * @param initialM22 defines 2nd value of 2nd row
  60923. * @param initialM23 defines 3rd value of 2nd row
  60924. * @param initialM24 defines 4th value of 2nd row
  60925. * @param initialM31 defines 1st value of 3rd row
  60926. * @param initialM32 defines 2nd value of 3rd row
  60927. * @param initialM33 defines 3rd value of 3rd row
  60928. * @param initialM34 defines 4th value of 3rd row
  60929. * @param initialM41 defines 1st value of 4th row
  60930. * @param initialM42 defines 2nd value of 4th row
  60931. * @param initialM43 defines 3rd value of 4th row
  60932. * @param initialM44 defines 4th value of 4th row
  60933. * @returns the new matrix
  60934. */
  60935. 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;
  60936. /**
  60937. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60938. * @param scale defines the scale vector3
  60939. * @param rotation defines the rotation quaternion
  60940. * @param translation defines the translation vector3
  60941. * @returns a new matrix
  60942. */
  60943. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60944. /**
  60945. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60946. * @param scale defines the scale vector3
  60947. * @param rotation defines the rotation quaternion
  60948. * @param translation defines the translation vector3
  60949. * @param result defines the target matrix
  60950. */
  60951. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60952. /**
  60953. * Creates a new identity matrix
  60954. * @returns a new identity matrix
  60955. */
  60956. static Identity(): Matrix;
  60957. /**
  60958. * Creates a new identity matrix and stores the result in a given matrix
  60959. * @param result defines the target matrix
  60960. */
  60961. static IdentityToRef(result: Matrix): void;
  60962. /**
  60963. * Creates a new zero matrix
  60964. * @returns a new zero matrix
  60965. */
  60966. static Zero(): Matrix;
  60967. /**
  60968. * Creates a new rotation matrix for "angle" radians around the X axis
  60969. * @param angle defines the angle (in radians) to use
  60970. * @return the new matrix
  60971. */
  60972. static RotationX(angle: number): Matrix;
  60973. /**
  60974. * Creates a new matrix as the invert of a given matrix
  60975. * @param source defines the source matrix
  60976. * @returns the new matrix
  60977. */
  60978. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60979. /**
  60980. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60981. * @param angle defines the angle (in radians) to use
  60982. * @param result defines the target matrix
  60983. */
  60984. static RotationXToRef(angle: number, result: Matrix): void;
  60985. /**
  60986. * Creates a new rotation matrix for "angle" radians around the Y axis
  60987. * @param angle defines the angle (in radians) to use
  60988. * @return the new matrix
  60989. */
  60990. static RotationY(angle: number): Matrix;
  60991. /**
  60992. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60993. * @param angle defines the angle (in radians) to use
  60994. * @param result defines the target matrix
  60995. */
  60996. static RotationYToRef(angle: number, result: Matrix): void;
  60997. /**
  60998. * Creates a new rotation matrix for "angle" radians around the Z axis
  60999. * @param angle defines the angle (in radians) to use
  61000. * @return the new matrix
  61001. */
  61002. static RotationZ(angle: number): Matrix;
  61003. /**
  61004. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61005. * @param angle defines the angle (in radians) to use
  61006. * @param result defines the target matrix
  61007. */
  61008. static RotationZToRef(angle: number, result: Matrix): void;
  61009. /**
  61010. * Creates a new rotation matrix for "angle" radians around the given axis
  61011. * @param axis defines the axis to use
  61012. * @param angle defines the angle (in radians) to use
  61013. * @return the new matrix
  61014. */
  61015. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61016. /**
  61017. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61018. * @param axis defines the axis to use
  61019. * @param angle defines the angle (in radians) to use
  61020. * @param result defines the target matrix
  61021. */
  61022. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61023. /**
  61024. * Creates a rotation matrix
  61025. * @param yaw defines the yaw angle in radians (Y axis)
  61026. * @param pitch defines the pitch angle in radians (X axis)
  61027. * @param roll defines the roll angle in radians (X axis)
  61028. * @returns the new rotation matrix
  61029. */
  61030. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61031. /**
  61032. * Creates a rotation matrix and stores it in a given matrix
  61033. * @param yaw defines the yaw angle in radians (Y axis)
  61034. * @param pitch defines the pitch angle in radians (X axis)
  61035. * @param roll defines the roll angle in radians (X axis)
  61036. * @param result defines the target matrix
  61037. */
  61038. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61039. /**
  61040. * Creates a scaling matrix
  61041. * @param x defines the scale factor on X axis
  61042. * @param y defines the scale factor on Y axis
  61043. * @param z defines the scale factor on Z axis
  61044. * @returns the new matrix
  61045. */
  61046. static Scaling(x: number, y: number, z: number): Matrix;
  61047. /**
  61048. * Creates a scaling matrix and stores it in a given matrix
  61049. * @param x defines the scale factor on X axis
  61050. * @param y defines the scale factor on Y axis
  61051. * @param z defines the scale factor on Z axis
  61052. * @param result defines the target matrix
  61053. */
  61054. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61055. /**
  61056. * Creates a translation matrix
  61057. * @param x defines the translation on X axis
  61058. * @param y defines the translation on Y axis
  61059. * @param z defines the translationon Z axis
  61060. * @returns the new matrix
  61061. */
  61062. static Translation(x: number, y: number, z: number): Matrix;
  61063. /**
  61064. * Creates a translation matrix and stores it in a given matrix
  61065. * @param x defines the translation on X axis
  61066. * @param y defines the translation on Y axis
  61067. * @param z defines the translationon Z axis
  61068. * @param result defines the target matrix
  61069. */
  61070. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61071. /**
  61072. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61073. * @param startValue defines the start value
  61074. * @param endValue defines the end value
  61075. * @param gradient defines the gradient factor
  61076. * @returns the new matrix
  61077. */
  61078. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61079. /**
  61080. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61081. * @param startValue defines the start value
  61082. * @param endValue defines the end value
  61083. * @param gradient defines the gradient factor
  61084. * @param result defines the Matrix object where to store data
  61085. */
  61086. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61087. /**
  61088. * Builds a new matrix whose values are computed by:
  61089. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61090. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61091. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61092. * @param startValue defines the first matrix
  61093. * @param endValue defines the second matrix
  61094. * @param gradient defines the gradient between the two matrices
  61095. * @returns the new matrix
  61096. */
  61097. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61098. /**
  61099. * Update a matrix to values which are computed by:
  61100. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61101. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61102. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61103. * @param startValue defines the first matrix
  61104. * @param endValue defines the second matrix
  61105. * @param gradient defines the gradient between the two matrices
  61106. * @param result defines the target matrix
  61107. */
  61108. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61109. /**
  61110. * 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"
  61111. * This function works in left handed mode
  61112. * @param eye defines the final position of the entity
  61113. * @param target defines where the entity should look at
  61114. * @param up defines the up vector for the entity
  61115. * @returns the new matrix
  61116. */
  61117. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61118. /**
  61119. * 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".
  61120. * This function works in left handed mode
  61121. * @param eye defines the final position of the entity
  61122. * @param target defines where the entity should look at
  61123. * @param up defines the up vector for the entity
  61124. * @param result defines the target matrix
  61125. */
  61126. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61127. /**
  61128. * 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"
  61129. * This function works in right handed mode
  61130. * @param eye defines the final position of the entity
  61131. * @param target defines where the entity should look at
  61132. * @param up defines the up vector for the entity
  61133. * @returns the new matrix
  61134. */
  61135. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61136. /**
  61137. * 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".
  61138. * This function works in right handed mode
  61139. * @param eye defines the final position of the entity
  61140. * @param target defines where the entity should look at
  61141. * @param up defines the up vector for the entity
  61142. * @param result defines the target matrix
  61143. */
  61144. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61145. /**
  61146. * Create a left-handed orthographic projection matrix
  61147. * @param width defines the viewport width
  61148. * @param height defines the viewport height
  61149. * @param znear defines the near clip plane
  61150. * @param zfar defines the far clip plane
  61151. * @returns a new matrix as a left-handed orthographic projection matrix
  61152. */
  61153. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61154. /**
  61155. * Store a left-handed orthographic projection to a given matrix
  61156. * @param width defines the viewport width
  61157. * @param height defines the viewport height
  61158. * @param znear defines the near clip plane
  61159. * @param zfar defines the far clip plane
  61160. * @param result defines the target matrix
  61161. */
  61162. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61163. /**
  61164. * Create a left-handed orthographic projection matrix
  61165. * @param left defines the viewport left coordinate
  61166. * @param right defines the viewport right coordinate
  61167. * @param bottom defines the viewport bottom coordinate
  61168. * @param top defines the viewport top coordinate
  61169. * @param znear defines the near clip plane
  61170. * @param zfar defines the far clip plane
  61171. * @returns a new matrix as a left-handed orthographic projection matrix
  61172. */
  61173. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61174. /**
  61175. * Stores a left-handed orthographic projection into a given matrix
  61176. * @param left defines the viewport left coordinate
  61177. * @param right defines the viewport right coordinate
  61178. * @param bottom defines the viewport bottom coordinate
  61179. * @param top defines the viewport top coordinate
  61180. * @param znear defines the near clip plane
  61181. * @param zfar defines the far clip plane
  61182. * @param result defines the target matrix
  61183. */
  61184. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61185. /**
  61186. * Creates a right-handed orthographic projection matrix
  61187. * @param left defines the viewport left coordinate
  61188. * @param right defines the viewport right coordinate
  61189. * @param bottom defines the viewport bottom coordinate
  61190. * @param top defines the viewport top coordinate
  61191. * @param znear defines the near clip plane
  61192. * @param zfar defines the far clip plane
  61193. * @returns a new matrix as a right-handed orthographic projection matrix
  61194. */
  61195. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61196. /**
  61197. * Stores a right-handed orthographic projection into a given matrix
  61198. * @param left defines the viewport left coordinate
  61199. * @param right defines the viewport right coordinate
  61200. * @param bottom defines the viewport bottom coordinate
  61201. * @param top defines the viewport top coordinate
  61202. * @param znear defines the near clip plane
  61203. * @param zfar defines the far clip plane
  61204. * @param result defines the target matrix
  61205. */
  61206. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61207. /**
  61208. * Creates a left-handed perspective projection matrix
  61209. * @param width defines the viewport width
  61210. * @param height defines the viewport height
  61211. * @param znear defines the near clip plane
  61212. * @param zfar defines the far clip plane
  61213. * @returns a new matrix as a left-handed perspective projection matrix
  61214. */
  61215. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61216. /**
  61217. * Creates a left-handed perspective projection matrix
  61218. * @param fov defines the horizontal field of view
  61219. * @param aspect defines the aspect ratio
  61220. * @param znear defines the near clip plane
  61221. * @param zfar defines the far clip plane
  61222. * @returns a new matrix as a left-handed perspective projection matrix
  61223. */
  61224. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61225. /**
  61226. * Stores a left-handed perspective projection into a given matrix
  61227. * @param fov defines the horizontal field of view
  61228. * @param aspect defines the aspect ratio
  61229. * @param znear defines the near clip plane
  61230. * @param zfar defines the far clip plane
  61231. * @param result defines the target matrix
  61232. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61233. */
  61234. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61235. /**
  61236. * Creates a right-handed perspective projection matrix
  61237. * @param fov defines the horizontal field of view
  61238. * @param aspect defines the aspect ratio
  61239. * @param znear defines the near clip plane
  61240. * @param zfar defines the far clip plane
  61241. * @returns a new matrix as a right-handed perspective projection matrix
  61242. */
  61243. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61244. /**
  61245. * Stores a right-handed perspective projection into a given matrix
  61246. * @param fov defines the horizontal field of view
  61247. * @param aspect defines the aspect ratio
  61248. * @param znear defines the near clip plane
  61249. * @param zfar defines the far clip plane
  61250. * @param result defines the target matrix
  61251. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61252. */
  61253. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61254. /**
  61255. * Stores a perspective projection for WebVR info a given matrix
  61256. * @param fov defines the field of view
  61257. * @param znear defines the near clip plane
  61258. * @param zfar defines the far clip plane
  61259. * @param result defines the target matrix
  61260. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61261. */
  61262. static PerspectiveFovWebVRToRef(fov: {
  61263. upDegrees: number;
  61264. downDegrees: number;
  61265. leftDegrees: number;
  61266. rightDegrees: number;
  61267. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61268. /**
  61269. * Computes a complete transformation matrix
  61270. * @param viewport defines the viewport to use
  61271. * @param world defines the world matrix
  61272. * @param view defines the view matrix
  61273. * @param projection defines the projection matrix
  61274. * @param zmin defines the near clip plane
  61275. * @param zmax defines the far clip plane
  61276. * @returns the transformation matrix
  61277. */
  61278. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61279. /**
  61280. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61281. * @param matrix defines the matrix to use
  61282. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61283. */
  61284. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61285. /**
  61286. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61287. * @param matrix defines the matrix to use
  61288. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61289. */
  61290. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61291. /**
  61292. * Compute the transpose of a given matrix
  61293. * @param matrix defines the matrix to transpose
  61294. * @returns the new matrix
  61295. */
  61296. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61297. /**
  61298. * Compute the transpose of a matrix and store it in a target matrix
  61299. * @param matrix defines the matrix to transpose
  61300. * @param result defines the target matrix
  61301. */
  61302. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61303. /**
  61304. * Computes a reflection matrix from a plane
  61305. * @param plane defines the reflection plane
  61306. * @returns a new matrix
  61307. */
  61308. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61309. /**
  61310. * Computes a reflection matrix from a plane
  61311. * @param plane defines the reflection plane
  61312. * @param result defines the target matrix
  61313. */
  61314. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61315. /**
  61316. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61317. * @param xaxis defines the value of the 1st axis
  61318. * @param yaxis defines the value of the 2nd axis
  61319. * @param zaxis defines the value of the 3rd axis
  61320. * @param result defines the target matrix
  61321. */
  61322. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61323. /**
  61324. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61325. * @param quat defines the quaternion to use
  61326. * @param result defines the target matrix
  61327. */
  61328. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61329. }
  61330. /**
  61331. * Represens a plane by the equation ax + by + cz + d = 0
  61332. */
  61333. export class Plane {
  61334. /**
  61335. * Normal of the plane (a,b,c)
  61336. */
  61337. normal: Vector3;
  61338. /**
  61339. * d component of the plane
  61340. */
  61341. d: number;
  61342. /**
  61343. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61344. * @param a a component of the plane
  61345. * @param b b component of the plane
  61346. * @param c c component of the plane
  61347. * @param d d component of the plane
  61348. */
  61349. constructor(a: number, b: number, c: number, d: number);
  61350. /**
  61351. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61352. */
  61353. asArray(): number[];
  61354. /**
  61355. * @returns a new plane copied from the current Plane.
  61356. */
  61357. clone(): Plane;
  61358. /**
  61359. * @returns the string "Plane".
  61360. */
  61361. getClassName(): string;
  61362. /**
  61363. * @returns the Plane hash code.
  61364. */
  61365. getHashCode(): number;
  61366. /**
  61367. * Normalize the current Plane in place.
  61368. * @returns the updated Plane.
  61369. */
  61370. normalize(): Plane;
  61371. /**
  61372. * Applies a transformation the plane and returns the result
  61373. * @param transformation the transformation matrix to be applied to the plane
  61374. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61375. */
  61376. transform(transformation: DeepImmutable<Matrix>): Plane;
  61377. /**
  61378. * Calcualtte the dot product between the point and the plane normal
  61379. * @param point point to calculate the dot product with
  61380. * @returns the dot product (float) of the point coordinates and the plane normal.
  61381. */
  61382. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61383. /**
  61384. * Updates the current Plane from the plane defined by the three given points.
  61385. * @param point1 one of the points used to contruct the plane
  61386. * @param point2 one of the points used to contruct the plane
  61387. * @param point3 one of the points used to contruct the plane
  61388. * @returns the updated Plane.
  61389. */
  61390. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61391. /**
  61392. * Checks if the plane is facing a given direction
  61393. * @param direction the direction to check if the plane is facing
  61394. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61395. * @returns True is the vector "direction" is the same side than the plane normal.
  61396. */
  61397. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61398. /**
  61399. * Calculates the distance to a point
  61400. * @param point point to calculate distance to
  61401. * @returns the signed distance (float) from the given point to the Plane.
  61402. */
  61403. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61404. /**
  61405. * Creates a plane from an array
  61406. * @param array the array to create a plane from
  61407. * @returns a new Plane from the given array.
  61408. */
  61409. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61410. /**
  61411. * Creates a plane from three points
  61412. * @param point1 point used to create the plane
  61413. * @param point2 point used to create the plane
  61414. * @param point3 point used to create the plane
  61415. * @returns a new Plane defined by the three given points.
  61416. */
  61417. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61418. /**
  61419. * Creates a plane from an origin point and a normal
  61420. * @param origin origin of the plane to be constructed
  61421. * @param normal normal of the plane to be constructed
  61422. * @returns a new Plane the normal vector to this plane at the given origin point.
  61423. * Note : the vector "normal" is updated because normalized.
  61424. */
  61425. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61426. /**
  61427. * Calculates the distance from a plane and a point
  61428. * @param origin origin of the plane to be constructed
  61429. * @param normal normal of the plane to be constructed
  61430. * @param point point to calculate distance to
  61431. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61432. */
  61433. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61434. }
  61435. /**
  61436. * Class used to represent a viewport on screen
  61437. */
  61438. export class Viewport {
  61439. /** viewport left coordinate */
  61440. x: number;
  61441. /** viewport top coordinate */
  61442. y: number;
  61443. /**viewport width */
  61444. width: number;
  61445. /** viewport height */
  61446. height: number;
  61447. /**
  61448. * Creates a Viewport object located at (x, y) and sized (width, height)
  61449. * @param x defines viewport left coordinate
  61450. * @param y defines viewport top coordinate
  61451. * @param width defines the viewport width
  61452. * @param height defines the viewport height
  61453. */
  61454. constructor(
  61455. /** viewport left coordinate */
  61456. x: number,
  61457. /** viewport top coordinate */
  61458. y: number,
  61459. /**viewport width */
  61460. width: number,
  61461. /** viewport height */
  61462. height: number);
  61463. /**
  61464. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61465. * @param renderWidth defines the rendering width
  61466. * @param renderHeight defines the rendering height
  61467. * @returns a new Viewport
  61468. */
  61469. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61470. /**
  61471. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61472. * @param renderWidth defines the rendering width
  61473. * @param renderHeight defines the rendering height
  61474. * @param ref defines the target viewport
  61475. * @returns the current viewport
  61476. */
  61477. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61478. /**
  61479. * Returns a new Viewport copied from the current one
  61480. * @returns a new Viewport
  61481. */
  61482. clone(): Viewport;
  61483. }
  61484. /**
  61485. * Reprasents a camera frustum
  61486. */
  61487. export class Frustum {
  61488. /**
  61489. * Gets the planes representing the frustum
  61490. * @param transform matrix to be applied to the returned planes
  61491. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61492. */
  61493. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61494. /**
  61495. * Gets the near frustum plane transformed by the transform matrix
  61496. * @param transform transformation matrix to be applied to the resulting frustum plane
  61497. * @param frustumPlane the resuling frustum plane
  61498. */
  61499. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61500. /**
  61501. * Gets the far frustum plane transformed by the transform matrix
  61502. * @param transform transformation matrix to be applied to the resulting frustum plane
  61503. * @param frustumPlane the resuling frustum plane
  61504. */
  61505. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61506. /**
  61507. * Gets the left frustum plane transformed by the transform matrix
  61508. * @param transform transformation matrix to be applied to the resulting frustum plane
  61509. * @param frustumPlane the resuling frustum plane
  61510. */
  61511. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61512. /**
  61513. * Gets the right frustum plane transformed by the transform matrix
  61514. * @param transform transformation matrix to be applied to the resulting frustum plane
  61515. * @param frustumPlane the resuling frustum plane
  61516. */
  61517. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61518. /**
  61519. * Gets the top frustum plane transformed by the transform matrix
  61520. * @param transform transformation matrix to be applied to the resulting frustum plane
  61521. * @param frustumPlane the resuling frustum plane
  61522. */
  61523. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61524. /**
  61525. * Gets the bottom frustum plane transformed by the transform matrix
  61526. * @param transform transformation matrix to be applied to the resulting frustum plane
  61527. * @param frustumPlane the resuling frustum plane
  61528. */
  61529. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61530. /**
  61531. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61532. * @param transform transformation matrix to be applied to the resulting frustum planes
  61533. * @param frustumPlanes the resuling frustum planes
  61534. */
  61535. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61536. }
  61537. /** Defines supported spaces */
  61538. export enum Space {
  61539. /** Local (object) space */
  61540. LOCAL = 0,
  61541. /** World space */
  61542. WORLD = 1,
  61543. /** Bone space */
  61544. BONE = 2
  61545. }
  61546. /** Defines the 3 main axes */
  61547. export class Axis {
  61548. /** X axis */
  61549. static X: Vector3;
  61550. /** Y axis */
  61551. static Y: Vector3;
  61552. /** Z axis */
  61553. static Z: Vector3;
  61554. }
  61555. /** Class used to represent a Bezier curve */
  61556. export class BezierCurve {
  61557. /**
  61558. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61559. * @param t defines the time
  61560. * @param x1 defines the left coordinate on X axis
  61561. * @param y1 defines the left coordinate on Y axis
  61562. * @param x2 defines the right coordinate on X axis
  61563. * @param y2 defines the right coordinate on Y axis
  61564. * @returns the interpolated value
  61565. */
  61566. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61567. }
  61568. /**
  61569. * Defines potential orientation for back face culling
  61570. */
  61571. export enum Orientation {
  61572. /**
  61573. * Clockwise
  61574. */
  61575. CW = 0,
  61576. /** Counter clockwise */
  61577. CCW = 1
  61578. }
  61579. /**
  61580. * Defines angle representation
  61581. */
  61582. export class Angle {
  61583. private _radians;
  61584. /**
  61585. * Creates an Angle object of "radians" radians (float).
  61586. * @param radians the angle in radians
  61587. */
  61588. constructor(radians: number);
  61589. /**
  61590. * Get value in degrees
  61591. * @returns the Angle value in degrees (float)
  61592. */
  61593. degrees(): number;
  61594. /**
  61595. * Get value in radians
  61596. * @returns the Angle value in radians (float)
  61597. */
  61598. radians(): number;
  61599. /**
  61600. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61601. * @param a defines first vector
  61602. * @param b defines second vector
  61603. * @returns a new Angle
  61604. */
  61605. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61606. /**
  61607. * Gets a new Angle object from the given float in radians
  61608. * @param radians defines the angle value in radians
  61609. * @returns a new Angle
  61610. */
  61611. static FromRadians(radians: number): Angle;
  61612. /**
  61613. * Gets a new Angle object from the given float in degrees
  61614. * @param degrees defines the angle value in degrees
  61615. * @returns a new Angle
  61616. */
  61617. static FromDegrees(degrees: number): Angle;
  61618. }
  61619. /**
  61620. * This represents an arc in a 2d space.
  61621. */
  61622. export class Arc2 {
  61623. /** Defines the start point of the arc */
  61624. startPoint: Vector2;
  61625. /** Defines the mid point of the arc */
  61626. midPoint: Vector2;
  61627. /** Defines the end point of the arc */
  61628. endPoint: Vector2;
  61629. /**
  61630. * Defines the center point of the arc.
  61631. */
  61632. centerPoint: Vector2;
  61633. /**
  61634. * Defines the radius of the arc.
  61635. */
  61636. radius: number;
  61637. /**
  61638. * Defines the angle of the arc (from mid point to end point).
  61639. */
  61640. angle: Angle;
  61641. /**
  61642. * Defines the start angle of the arc (from start point to middle point).
  61643. */
  61644. startAngle: Angle;
  61645. /**
  61646. * Defines the orientation of the arc (clock wise/counter clock wise).
  61647. */
  61648. orientation: Orientation;
  61649. /**
  61650. * Creates an Arc object from the three given points : start, middle and end.
  61651. * @param startPoint Defines the start point of the arc
  61652. * @param midPoint Defines the midlle point of the arc
  61653. * @param endPoint Defines the end point of the arc
  61654. */
  61655. constructor(
  61656. /** Defines the start point of the arc */
  61657. startPoint: Vector2,
  61658. /** Defines the mid point of the arc */
  61659. midPoint: Vector2,
  61660. /** Defines the end point of the arc */
  61661. endPoint: Vector2);
  61662. }
  61663. /**
  61664. * Represents a 2D path made up of multiple 2D points
  61665. */
  61666. export class Path2 {
  61667. private _points;
  61668. private _length;
  61669. /**
  61670. * If the path start and end point are the same
  61671. */
  61672. closed: boolean;
  61673. /**
  61674. * Creates a Path2 object from the starting 2D coordinates x and y.
  61675. * @param x the starting points x value
  61676. * @param y the starting points y value
  61677. */
  61678. constructor(x: number, y: number);
  61679. /**
  61680. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61681. * @param x the added points x value
  61682. * @param y the added points y value
  61683. * @returns the updated Path2.
  61684. */
  61685. addLineTo(x: number, y: number): Path2;
  61686. /**
  61687. * 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.
  61688. * @param midX middle point x value
  61689. * @param midY middle point y value
  61690. * @param endX end point x value
  61691. * @param endY end point y value
  61692. * @param numberOfSegments (default: 36)
  61693. * @returns the updated Path2.
  61694. */
  61695. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61696. /**
  61697. * Closes the Path2.
  61698. * @returns the Path2.
  61699. */
  61700. close(): Path2;
  61701. /**
  61702. * Gets the sum of the distance between each sequential point in the path
  61703. * @returns the Path2 total length (float).
  61704. */
  61705. length(): number;
  61706. /**
  61707. * Gets the points which construct the path
  61708. * @returns the Path2 internal array of points.
  61709. */
  61710. getPoints(): Vector2[];
  61711. /**
  61712. * Retreives the point at the distance aways from the starting point
  61713. * @param normalizedLengthPosition the length along the path to retreive the point from
  61714. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61715. */
  61716. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61717. /**
  61718. * Creates a new path starting from an x and y position
  61719. * @param x starting x value
  61720. * @param y starting y value
  61721. * @returns a new Path2 starting at the coordinates (x, y).
  61722. */
  61723. static StartingAt(x: number, y: number): Path2;
  61724. }
  61725. /**
  61726. * Represents a 3D path made up of multiple 3D points
  61727. */
  61728. export class Path3D {
  61729. /**
  61730. * an array of Vector3, the curve axis of the Path3D
  61731. */
  61732. path: Vector3[];
  61733. private _curve;
  61734. private _distances;
  61735. private _tangents;
  61736. private _normals;
  61737. private _binormals;
  61738. private _raw;
  61739. /**
  61740. * new Path3D(path, normal, raw)
  61741. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61742. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61743. * @param path an array of Vector3, the curve axis of the Path3D
  61744. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61745. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61746. */
  61747. constructor(
  61748. /**
  61749. * an array of Vector3, the curve axis of the Path3D
  61750. */
  61751. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61752. /**
  61753. * Returns the Path3D array of successive Vector3 designing its curve.
  61754. * @returns the Path3D array of successive Vector3 designing its curve.
  61755. */
  61756. getCurve(): Vector3[];
  61757. /**
  61758. * Returns an array populated with tangent vectors on each Path3D curve point.
  61759. * @returns an array populated with tangent vectors on each Path3D curve point.
  61760. */
  61761. getTangents(): Vector3[];
  61762. /**
  61763. * Returns an array populated with normal vectors on each Path3D curve point.
  61764. * @returns an array populated with normal vectors on each Path3D curve point.
  61765. */
  61766. getNormals(): Vector3[];
  61767. /**
  61768. * Returns an array populated with binormal vectors on each Path3D curve point.
  61769. * @returns an array populated with binormal vectors on each Path3D curve point.
  61770. */
  61771. getBinormals(): Vector3[];
  61772. /**
  61773. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61774. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61775. */
  61776. getDistances(): number[];
  61777. /**
  61778. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61779. * @param path path which all values are copied into the curves points
  61780. * @param firstNormal which should be projected onto the curve
  61781. * @returns the same object updated.
  61782. */
  61783. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61784. private _compute;
  61785. private _getFirstNonNullVector;
  61786. private _getLastNonNullVector;
  61787. private _normalVector;
  61788. }
  61789. /**
  61790. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61791. * A Curve3 is designed from a series of successive Vector3.
  61792. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61793. */
  61794. export class Curve3 {
  61795. private _points;
  61796. private _length;
  61797. /**
  61798. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61799. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61800. * @param v1 (Vector3) the control point
  61801. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61802. * @param nbPoints (integer) the wanted number of points in the curve
  61803. * @returns the created Curve3
  61804. */
  61805. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61806. /**
  61807. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61808. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61809. * @param v1 (Vector3) the first control point
  61810. * @param v2 (Vector3) the second control point
  61811. * @param v3 (Vector3) the end point of the Cubic Bezier
  61812. * @param nbPoints (integer) the wanted number of points in the curve
  61813. * @returns the created Curve3
  61814. */
  61815. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61816. /**
  61817. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61818. * @param p1 (Vector3) the origin point of the Hermite Spline
  61819. * @param t1 (Vector3) the tangent vector at the origin point
  61820. * @param p2 (Vector3) the end point of the Hermite Spline
  61821. * @param t2 (Vector3) the tangent vector at the end point
  61822. * @param nbPoints (integer) the wanted number of points in the curve
  61823. * @returns the created Curve3
  61824. */
  61825. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61826. /**
  61827. * Returns a Curve3 object along a CatmullRom Spline curve :
  61828. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61829. * @param nbPoints (integer) the wanted number of points between each curve control points
  61830. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61831. * @returns the created Curve3
  61832. */
  61833. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61834. /**
  61835. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61836. * A Curve3 is designed from a series of successive Vector3.
  61837. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61838. * @param points points which make up the curve
  61839. */
  61840. constructor(points: Vector3[]);
  61841. /**
  61842. * @returns the Curve3 stored array of successive Vector3
  61843. */
  61844. getPoints(): Vector3[];
  61845. /**
  61846. * @returns the computed length (float) of the curve.
  61847. */
  61848. length(): number;
  61849. /**
  61850. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61851. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61852. * curveA and curveB keep unchanged.
  61853. * @param curve the curve to continue from this curve
  61854. * @returns the newly constructed curve
  61855. */
  61856. continue(curve: DeepImmutable<Curve3>): Curve3;
  61857. private _computeLength;
  61858. }
  61859. /**
  61860. * Contains position and normal vectors for a vertex
  61861. */
  61862. export class PositionNormalVertex {
  61863. /** the position of the vertex (defaut: 0,0,0) */
  61864. position: Vector3;
  61865. /** the normal of the vertex (defaut: 0,1,0) */
  61866. normal: Vector3;
  61867. /**
  61868. * Creates a PositionNormalVertex
  61869. * @param position the position of the vertex (defaut: 0,0,0)
  61870. * @param normal the normal of the vertex (defaut: 0,1,0)
  61871. */
  61872. constructor(
  61873. /** the position of the vertex (defaut: 0,0,0) */
  61874. position?: Vector3,
  61875. /** the normal of the vertex (defaut: 0,1,0) */
  61876. normal?: Vector3);
  61877. /**
  61878. * Clones the PositionNormalVertex
  61879. * @returns the cloned PositionNormalVertex
  61880. */
  61881. clone(): PositionNormalVertex;
  61882. }
  61883. /**
  61884. * Contains position, normal and uv vectors for a vertex
  61885. */
  61886. export class PositionNormalTextureVertex {
  61887. /** the position of the vertex (defaut: 0,0,0) */
  61888. position: Vector3;
  61889. /** the normal of the vertex (defaut: 0,1,0) */
  61890. normal: Vector3;
  61891. /** the uv of the vertex (default: 0,0) */
  61892. uv: Vector2;
  61893. /**
  61894. * Creates a PositionNormalTextureVertex
  61895. * @param position the position of the vertex (defaut: 0,0,0)
  61896. * @param normal the normal of the vertex (defaut: 0,1,0)
  61897. * @param uv the uv of the vertex (default: 0,0)
  61898. */
  61899. constructor(
  61900. /** the position of the vertex (defaut: 0,0,0) */
  61901. position?: Vector3,
  61902. /** the normal of the vertex (defaut: 0,1,0) */
  61903. normal?: Vector3,
  61904. /** the uv of the vertex (default: 0,0) */
  61905. uv?: Vector2);
  61906. /**
  61907. * Clones the PositionNormalTextureVertex
  61908. * @returns the cloned PositionNormalTextureVertex
  61909. */
  61910. clone(): PositionNormalTextureVertex;
  61911. }
  61912. /**
  61913. * @hidden
  61914. */
  61915. export class Tmp {
  61916. static Color3: Color3[];
  61917. static Color4: Color4[];
  61918. static Vector2: Vector2[];
  61919. static Vector3: Vector3[];
  61920. static Vector4: Vector4[];
  61921. static Quaternion: Quaternion[];
  61922. static Matrix: Matrix[];
  61923. }
  61924. }
  61925. declare module BABYLON {
  61926. /**
  61927. * Class used to enable access to offline support
  61928. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61929. */
  61930. export interface IOfflineProvider {
  61931. /**
  61932. * Gets a boolean indicating if scene must be saved in the database
  61933. */
  61934. enableSceneOffline: boolean;
  61935. /**
  61936. * Gets a boolean indicating if textures must be saved in the database
  61937. */
  61938. enableTexturesOffline: boolean;
  61939. /**
  61940. * Open the offline support and make it available
  61941. * @param successCallback defines the callback to call on success
  61942. * @param errorCallback defines the callback to call on error
  61943. */
  61944. open(successCallback: () => void, errorCallback: () => void): void;
  61945. /**
  61946. * Loads an image from the offline support
  61947. * @param url defines the url to load from
  61948. * @param image defines the target DOM image
  61949. */
  61950. loadImage(url: string, image: HTMLImageElement): void;
  61951. /**
  61952. * Loads a file from offline support
  61953. * @param url defines the URL to load from
  61954. * @param sceneLoaded defines a callback to call on success
  61955. * @param progressCallBack defines a callback to call when progress changed
  61956. * @param errorCallback defines a callback to call on error
  61957. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61958. */
  61959. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61960. }
  61961. }
  61962. declare module BABYLON {
  61963. /**
  61964. * A class serves as a medium between the observable and its observers
  61965. */
  61966. export class EventState {
  61967. /**
  61968. * Create a new EventState
  61969. * @param mask defines the mask associated with this state
  61970. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61971. * @param target defines the original target of the state
  61972. * @param currentTarget defines the current target of the state
  61973. */
  61974. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61975. /**
  61976. * Initialize the current event state
  61977. * @param mask defines the mask associated with this state
  61978. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61979. * @param target defines the original target of the state
  61980. * @param currentTarget defines the current target of the state
  61981. * @returns the current event state
  61982. */
  61983. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61984. /**
  61985. * An Observer can set this property to true to prevent subsequent observers of being notified
  61986. */
  61987. skipNextObservers: boolean;
  61988. /**
  61989. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61990. */
  61991. mask: number;
  61992. /**
  61993. * The object that originally notified the event
  61994. */
  61995. target?: any;
  61996. /**
  61997. * The current object in the bubbling phase
  61998. */
  61999. currentTarget?: any;
  62000. /**
  62001. * This will be populated with the return value of the last function that was executed.
  62002. * If it is the first function in the callback chain it will be the event data.
  62003. */
  62004. lastReturnValue?: any;
  62005. }
  62006. /**
  62007. * Represent an Observer registered to a given Observable object.
  62008. */
  62009. export class Observer<T> {
  62010. /**
  62011. * Defines the callback to call when the observer is notified
  62012. */
  62013. callback: (eventData: T, eventState: EventState) => void;
  62014. /**
  62015. * Defines the mask of the observer (used to filter notifications)
  62016. */
  62017. mask: number;
  62018. /**
  62019. * Defines the current scope used to restore the JS context
  62020. */
  62021. scope: any;
  62022. /** @hidden */
  62023. _willBeUnregistered: boolean;
  62024. /**
  62025. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62026. */
  62027. unregisterOnNextCall: boolean;
  62028. /**
  62029. * Creates a new observer
  62030. * @param callback defines the callback to call when the observer is notified
  62031. * @param mask defines the mask of the observer (used to filter notifications)
  62032. * @param scope defines the current scope used to restore the JS context
  62033. */
  62034. constructor(
  62035. /**
  62036. * Defines the callback to call when the observer is notified
  62037. */
  62038. callback: (eventData: T, eventState: EventState) => void,
  62039. /**
  62040. * Defines the mask of the observer (used to filter notifications)
  62041. */
  62042. mask: number,
  62043. /**
  62044. * Defines the current scope used to restore the JS context
  62045. */
  62046. scope?: any);
  62047. }
  62048. /**
  62049. * Represent a list of observers registered to multiple Observables object.
  62050. */
  62051. export class MultiObserver<T> {
  62052. private _observers;
  62053. private _observables;
  62054. /**
  62055. * Release associated resources
  62056. */
  62057. dispose(): void;
  62058. /**
  62059. * Raise a callback when one of the observable will notify
  62060. * @param observables defines a list of observables to watch
  62061. * @param callback defines the callback to call on notification
  62062. * @param mask defines the mask used to filter notifications
  62063. * @param scope defines the current scope used to restore the JS context
  62064. * @returns the new MultiObserver
  62065. */
  62066. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62067. }
  62068. /**
  62069. * The Observable class is a simple implementation of the Observable pattern.
  62070. *
  62071. * 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.
  62072. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62073. * 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).
  62074. * 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.
  62075. */
  62076. export class Observable<T> {
  62077. private _observers;
  62078. private _eventState;
  62079. private _onObserverAdded;
  62080. /**
  62081. * Creates a new observable
  62082. * @param onObserverAdded defines a callback to call when a new observer is added
  62083. */
  62084. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62085. /**
  62086. * Create a new Observer with the specified callback
  62087. * @param callback the callback that will be executed for that Observer
  62088. * @param mask the mask used to filter observers
  62089. * @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.
  62090. * @param scope optional scope for the callback to be called from
  62091. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62092. * @returns the new observer created for the callback
  62093. */
  62094. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62095. /**
  62096. * Create a new Observer with the specified callback and unregisters after the next notification
  62097. * @param callback the callback that will be executed for that Observer
  62098. * @returns the new observer created for the callback
  62099. */
  62100. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62101. /**
  62102. * Remove an Observer from the Observable object
  62103. * @param observer the instance of the Observer to remove
  62104. * @returns false if it doesn't belong to this Observable
  62105. */
  62106. remove(observer: Nullable<Observer<T>>): boolean;
  62107. /**
  62108. * Remove a callback from the Observable object
  62109. * @param callback the callback to remove
  62110. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62111. * @returns false if it doesn't belong to this Observable
  62112. */
  62113. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62114. private _deferUnregister;
  62115. private _remove;
  62116. /**
  62117. * Notify all Observers by calling their respective callback with the given data
  62118. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62119. * @param eventData defines the data to send to all observers
  62120. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62121. * @param target defines the original target of the state
  62122. * @param currentTarget defines the current target of the state
  62123. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62124. */
  62125. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62126. /**
  62127. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62128. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62129. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62130. * and it is crucial that all callbacks will be executed.
  62131. * The order of the callbacks is kept, callbacks are not executed parallel.
  62132. *
  62133. * @param eventData The data to be sent to each callback
  62134. * @param mask is used to filter observers defaults to -1
  62135. * @param target defines the callback target (see EventState)
  62136. * @param currentTarget defines he current object in the bubbling phase
  62137. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62138. */
  62139. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62140. /**
  62141. * Notify a specific observer
  62142. * @param observer defines the observer to notify
  62143. * @param eventData defines the data to be sent to each callback
  62144. * @param mask is used to filter observers defaults to -1
  62145. */
  62146. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62147. /**
  62148. * Gets a boolean indicating if the observable has at least one observer
  62149. * @returns true is the Observable has at least one Observer registered
  62150. */
  62151. hasObservers(): boolean;
  62152. /**
  62153. * Clear the list of observers
  62154. */
  62155. clear(): void;
  62156. /**
  62157. * Clone the current observable
  62158. * @returns a new observable
  62159. */
  62160. clone(): Observable<T>;
  62161. /**
  62162. * Does this observable handles observer registered with a given mask
  62163. * @param mask defines the mask to be tested
  62164. * @return whether or not one observer registered with the given mask is handeled
  62165. **/
  62166. hasSpecificMask(mask?: number): boolean;
  62167. }
  62168. }
  62169. declare module BABYLON {
  62170. /**
  62171. * Class used to help managing file picking and drag'n'drop
  62172. * File Storage
  62173. */
  62174. export class FilesInputStore {
  62175. /**
  62176. * List of files ready to be loaded
  62177. */
  62178. static FilesToLoad: {
  62179. [key: string]: File;
  62180. };
  62181. }
  62182. }
  62183. declare module BABYLON {
  62184. /** Defines the cross module used constants to avoid circular dependncies */
  62185. export class Constants {
  62186. /** Defines that alpha blending is disabled */
  62187. static readonly ALPHA_DISABLE: number;
  62188. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62189. static readonly ALPHA_ADD: number;
  62190. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62191. static readonly ALPHA_COMBINE: number;
  62192. /** Defines that alpha blending to DEST - SRC * DEST */
  62193. static readonly ALPHA_SUBTRACT: number;
  62194. /** Defines that alpha blending to SRC * DEST */
  62195. static readonly ALPHA_MULTIPLY: number;
  62196. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62197. static readonly ALPHA_MAXIMIZED: number;
  62198. /** Defines that alpha blending to SRC + DEST */
  62199. static readonly ALPHA_ONEONE: number;
  62200. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62201. static readonly ALPHA_PREMULTIPLIED: number;
  62202. /**
  62203. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62204. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62205. */
  62206. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62207. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62208. static readonly ALPHA_INTERPOLATE: number;
  62209. /**
  62210. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62211. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62212. */
  62213. static readonly ALPHA_SCREENMODE: number;
  62214. /** Defines that the ressource is not delayed*/
  62215. static readonly DELAYLOADSTATE_NONE: number;
  62216. /** Defines that the ressource was successfully delay loaded */
  62217. static readonly DELAYLOADSTATE_LOADED: number;
  62218. /** Defines that the ressource is currently delay loading */
  62219. static readonly DELAYLOADSTATE_LOADING: number;
  62220. /** Defines that the ressource is delayed and has not started loading */
  62221. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62222. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62223. static readonly NEVER: number;
  62224. /** 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 */
  62225. static readonly ALWAYS: number;
  62226. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62227. static readonly LESS: number;
  62228. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62229. static readonly EQUAL: number;
  62230. /** 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 */
  62231. static readonly LEQUAL: number;
  62232. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62233. static readonly GREATER: number;
  62234. /** 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 */
  62235. static readonly GEQUAL: number;
  62236. /** 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 */
  62237. static readonly NOTEQUAL: number;
  62238. /** Passed to stencilOperation to specify that stencil value must be kept */
  62239. static readonly KEEP: number;
  62240. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62241. static readonly REPLACE: number;
  62242. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62243. static readonly INCR: number;
  62244. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62245. static readonly DECR: number;
  62246. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62247. static readonly INVERT: number;
  62248. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62249. static readonly INCR_WRAP: number;
  62250. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62251. static readonly DECR_WRAP: number;
  62252. /** Texture is not repeating outside of 0..1 UVs */
  62253. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62254. /** Texture is repeating outside of 0..1 UVs */
  62255. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62256. /** Texture is repeating and mirrored */
  62257. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62258. /** ALPHA */
  62259. static readonly TEXTUREFORMAT_ALPHA: number;
  62260. /** LUMINANCE */
  62261. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62262. /** LUMINANCE_ALPHA */
  62263. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62264. /** RGB */
  62265. static readonly TEXTUREFORMAT_RGB: number;
  62266. /** RGBA */
  62267. static readonly TEXTUREFORMAT_RGBA: number;
  62268. /** RED */
  62269. static readonly TEXTUREFORMAT_RED: number;
  62270. /** RED (2nd reference) */
  62271. static readonly TEXTUREFORMAT_R: number;
  62272. /** RG */
  62273. static readonly TEXTUREFORMAT_RG: number;
  62274. /** RED_INTEGER */
  62275. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62276. /** RED_INTEGER (2nd reference) */
  62277. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62278. /** RG_INTEGER */
  62279. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62280. /** RGB_INTEGER */
  62281. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62282. /** RGBA_INTEGER */
  62283. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62284. /** UNSIGNED_BYTE */
  62285. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62286. /** UNSIGNED_BYTE (2nd reference) */
  62287. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62288. /** FLOAT */
  62289. static readonly TEXTURETYPE_FLOAT: number;
  62290. /** HALF_FLOAT */
  62291. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62292. /** BYTE */
  62293. static readonly TEXTURETYPE_BYTE: number;
  62294. /** SHORT */
  62295. static readonly TEXTURETYPE_SHORT: number;
  62296. /** UNSIGNED_SHORT */
  62297. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62298. /** INT */
  62299. static readonly TEXTURETYPE_INT: number;
  62300. /** UNSIGNED_INT */
  62301. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62302. /** UNSIGNED_SHORT_4_4_4_4 */
  62303. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62304. /** UNSIGNED_SHORT_5_5_5_1 */
  62305. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62306. /** UNSIGNED_SHORT_5_6_5 */
  62307. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62308. /** UNSIGNED_INT_2_10_10_10_REV */
  62309. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62310. /** UNSIGNED_INT_24_8 */
  62311. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62312. /** UNSIGNED_INT_10F_11F_11F_REV */
  62313. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62314. /** UNSIGNED_INT_5_9_9_9_REV */
  62315. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62316. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62317. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62318. /** nearest is mag = nearest and min = nearest and mip = linear */
  62319. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62320. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62321. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62322. /** Trilinear is mag = linear and min = linear and mip = linear */
  62323. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62324. /** nearest is mag = nearest and min = nearest and mip = linear */
  62325. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62326. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62327. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62328. /** Trilinear is mag = linear and min = linear and mip = linear */
  62329. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62330. /** mag = nearest and min = nearest and mip = nearest */
  62331. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62332. /** mag = nearest and min = linear and mip = nearest */
  62333. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62334. /** mag = nearest and min = linear and mip = linear */
  62335. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62336. /** mag = nearest and min = linear and mip = none */
  62337. static readonly TEXTURE_NEAREST_LINEAR: number;
  62338. /** mag = nearest and min = nearest and mip = none */
  62339. static readonly TEXTURE_NEAREST_NEAREST: number;
  62340. /** mag = linear and min = nearest and mip = nearest */
  62341. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62342. /** mag = linear and min = nearest and mip = linear */
  62343. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62344. /** mag = linear and min = linear and mip = none */
  62345. static readonly TEXTURE_LINEAR_LINEAR: number;
  62346. /** mag = linear and min = nearest and mip = none */
  62347. static readonly TEXTURE_LINEAR_NEAREST: number;
  62348. /** Explicit coordinates mode */
  62349. static readonly TEXTURE_EXPLICIT_MODE: number;
  62350. /** Spherical coordinates mode */
  62351. static readonly TEXTURE_SPHERICAL_MODE: number;
  62352. /** Planar coordinates mode */
  62353. static readonly TEXTURE_PLANAR_MODE: number;
  62354. /** Cubic coordinates mode */
  62355. static readonly TEXTURE_CUBIC_MODE: number;
  62356. /** Projection coordinates mode */
  62357. static readonly TEXTURE_PROJECTION_MODE: number;
  62358. /** Skybox coordinates mode */
  62359. static readonly TEXTURE_SKYBOX_MODE: number;
  62360. /** Inverse Cubic coordinates mode */
  62361. static readonly TEXTURE_INVCUBIC_MODE: number;
  62362. /** Equirectangular coordinates mode */
  62363. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62364. /** Equirectangular Fixed coordinates mode */
  62365. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62366. /** Equirectangular Fixed Mirrored coordinates mode */
  62367. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62368. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62369. static readonly SCALEMODE_FLOOR: number;
  62370. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62371. static readonly SCALEMODE_NEAREST: number;
  62372. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62373. static readonly SCALEMODE_CEILING: number;
  62374. /**
  62375. * The dirty texture flag value
  62376. */
  62377. static readonly MATERIAL_TextureDirtyFlag: number;
  62378. /**
  62379. * The dirty light flag value
  62380. */
  62381. static readonly MATERIAL_LightDirtyFlag: number;
  62382. /**
  62383. * The dirty fresnel flag value
  62384. */
  62385. static readonly MATERIAL_FresnelDirtyFlag: number;
  62386. /**
  62387. * The dirty attribute flag value
  62388. */
  62389. static readonly MATERIAL_AttributesDirtyFlag: number;
  62390. /**
  62391. * The dirty misc flag value
  62392. */
  62393. static readonly MATERIAL_MiscDirtyFlag: number;
  62394. /**
  62395. * The all dirty flag value
  62396. */
  62397. static readonly MATERIAL_AllDirtyFlag: number;
  62398. /**
  62399. * Returns the triangle fill mode
  62400. */
  62401. static readonly MATERIAL_TriangleFillMode: number;
  62402. /**
  62403. * Returns the wireframe mode
  62404. */
  62405. static readonly MATERIAL_WireFrameFillMode: number;
  62406. /**
  62407. * Returns the point fill mode
  62408. */
  62409. static readonly MATERIAL_PointFillMode: number;
  62410. /**
  62411. * Returns the point list draw mode
  62412. */
  62413. static readonly MATERIAL_PointListDrawMode: number;
  62414. /**
  62415. * Returns the line list draw mode
  62416. */
  62417. static readonly MATERIAL_LineListDrawMode: number;
  62418. /**
  62419. * Returns the line loop draw mode
  62420. */
  62421. static readonly MATERIAL_LineLoopDrawMode: number;
  62422. /**
  62423. * Returns the line strip draw mode
  62424. */
  62425. static readonly MATERIAL_LineStripDrawMode: number;
  62426. /**
  62427. * Returns the triangle strip draw mode
  62428. */
  62429. static readonly MATERIAL_TriangleStripDrawMode: number;
  62430. /**
  62431. * Returns the triangle fan draw mode
  62432. */
  62433. static readonly MATERIAL_TriangleFanDrawMode: number;
  62434. /**
  62435. * Stores the clock-wise side orientation
  62436. */
  62437. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62438. /**
  62439. * Stores the counter clock-wise side orientation
  62440. */
  62441. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62442. /**
  62443. * Nothing
  62444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62445. */
  62446. static readonly ACTION_NothingTrigger: number;
  62447. /**
  62448. * On pick
  62449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62450. */
  62451. static readonly ACTION_OnPickTrigger: number;
  62452. /**
  62453. * On left pick
  62454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62455. */
  62456. static readonly ACTION_OnLeftPickTrigger: number;
  62457. /**
  62458. * On right pick
  62459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62460. */
  62461. static readonly ACTION_OnRightPickTrigger: number;
  62462. /**
  62463. * On center pick
  62464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62465. */
  62466. static readonly ACTION_OnCenterPickTrigger: number;
  62467. /**
  62468. * On pick down
  62469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62470. */
  62471. static readonly ACTION_OnPickDownTrigger: number;
  62472. /**
  62473. * On double pick
  62474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62475. */
  62476. static readonly ACTION_OnDoublePickTrigger: number;
  62477. /**
  62478. * On pick up
  62479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62480. */
  62481. static readonly ACTION_OnPickUpTrigger: number;
  62482. /**
  62483. * On pick out.
  62484. * This trigger will only be raised if you also declared a OnPickDown
  62485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62486. */
  62487. static readonly ACTION_OnPickOutTrigger: number;
  62488. /**
  62489. * On long press
  62490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62491. */
  62492. static readonly ACTION_OnLongPressTrigger: number;
  62493. /**
  62494. * On pointer over
  62495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62496. */
  62497. static readonly ACTION_OnPointerOverTrigger: number;
  62498. /**
  62499. * On pointer out
  62500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62501. */
  62502. static readonly ACTION_OnPointerOutTrigger: number;
  62503. /**
  62504. * On every frame
  62505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62506. */
  62507. static readonly ACTION_OnEveryFrameTrigger: number;
  62508. /**
  62509. * On intersection enter
  62510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62511. */
  62512. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62513. /**
  62514. * On intersection exit
  62515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62516. */
  62517. static readonly ACTION_OnIntersectionExitTrigger: number;
  62518. /**
  62519. * On key down
  62520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62521. */
  62522. static readonly ACTION_OnKeyDownTrigger: number;
  62523. /**
  62524. * On key up
  62525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62526. */
  62527. static readonly ACTION_OnKeyUpTrigger: number;
  62528. /**
  62529. * Billboard mode will only apply to Y axis
  62530. */
  62531. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62532. /**
  62533. * Billboard mode will apply to all axes
  62534. */
  62535. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62536. /**
  62537. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62538. */
  62539. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62540. /**
  62541. * Gets or sets base Assets URL
  62542. */
  62543. static readonly PARTICLES_BaseAssetsUrl: string;
  62544. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62545. * Test order :
  62546. * Is the bounding sphere outside the frustum ?
  62547. * If not, are the bounding box vertices outside the frustum ?
  62548. * It not, then the cullable object is in the frustum.
  62549. */
  62550. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62551. /** Culling strategy : Bounding Sphere Only.
  62552. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62553. * It's also less accurate than the standard because some not visible objects can still be selected.
  62554. * Test : is the bounding sphere outside the frustum ?
  62555. * If not, then the cullable object is in the frustum.
  62556. */
  62557. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62558. /** Culling strategy : Optimistic Inclusion.
  62559. * This in an inclusion test first, then the standard exclusion test.
  62560. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62561. * 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.
  62562. * Anyway, it's as accurate as the standard strategy.
  62563. * Test :
  62564. * Is the cullable object bounding sphere center in the frustum ?
  62565. * If not, apply the default culling strategy.
  62566. */
  62567. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62568. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62569. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62570. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62571. * 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.
  62572. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62573. * Test :
  62574. * Is the cullable object bounding sphere center in the frustum ?
  62575. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62576. */
  62577. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62578. /**
  62579. * No logging while loading
  62580. */
  62581. static readonly SCENELOADER_NO_LOGGING: number;
  62582. /**
  62583. * Minimal logging while loading
  62584. */
  62585. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62586. /**
  62587. * Summary logging while loading
  62588. */
  62589. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62590. /**
  62591. * Detailled logging while loading
  62592. */
  62593. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62594. }
  62595. }
  62596. declare module BABYLON {
  62597. /**
  62598. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62599. * Babylon.js
  62600. */
  62601. export class DomManagement {
  62602. /**
  62603. * Checks if the window object exists
  62604. * @returns true if the window object exists
  62605. */
  62606. static IsWindowObjectExist(): boolean;
  62607. /**
  62608. * Extracts text content from a DOM element hierarchy
  62609. * @param element defines the root element
  62610. * @returns a string
  62611. */
  62612. static GetDOMTextContent(element: HTMLElement): string;
  62613. }
  62614. }
  62615. declare module BABYLON {
  62616. /**
  62617. * Logger used througouht the application to allow configuration of
  62618. * the log level required for the messages.
  62619. */
  62620. export class Logger {
  62621. /**
  62622. * No log
  62623. */
  62624. static readonly NoneLogLevel: number;
  62625. /**
  62626. * Only message logs
  62627. */
  62628. static readonly MessageLogLevel: number;
  62629. /**
  62630. * Only warning logs
  62631. */
  62632. static readonly WarningLogLevel: number;
  62633. /**
  62634. * Only error logs
  62635. */
  62636. static readonly ErrorLogLevel: number;
  62637. /**
  62638. * All logs
  62639. */
  62640. static readonly AllLogLevel: number;
  62641. private static _LogCache;
  62642. /**
  62643. * Gets a value indicating the number of loading errors
  62644. * @ignorenaming
  62645. */
  62646. static errorsCount: number;
  62647. /**
  62648. * Callback called when a new log is added
  62649. */
  62650. static OnNewCacheEntry: (entry: string) => void;
  62651. private static _AddLogEntry;
  62652. private static _FormatMessage;
  62653. private static _LogDisabled;
  62654. private static _LogEnabled;
  62655. private static _WarnDisabled;
  62656. private static _WarnEnabled;
  62657. private static _ErrorDisabled;
  62658. private static _ErrorEnabled;
  62659. /**
  62660. * Log a message to the console
  62661. */
  62662. static Log: (message: string) => void;
  62663. /**
  62664. * Write a warning message to the console
  62665. */
  62666. static Warn: (message: string) => void;
  62667. /**
  62668. * Write an error message to the console
  62669. */
  62670. static Error: (message: string) => void;
  62671. /**
  62672. * Gets current log cache (list of logs)
  62673. */
  62674. static readonly LogCache: string;
  62675. /**
  62676. * Clears the log cache
  62677. */
  62678. static ClearLogCache(): void;
  62679. /**
  62680. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62681. */
  62682. static LogLevels: number;
  62683. }
  62684. }
  62685. declare module BABYLON {
  62686. /** @hidden */
  62687. export class _TypeStore {
  62688. /** @hidden */
  62689. static RegisteredTypes: {
  62690. [key: string]: Object;
  62691. };
  62692. /** @hidden */
  62693. static GetClass(fqdn: string): any;
  62694. }
  62695. }
  62696. declare module BABYLON {
  62697. /**
  62698. * Class containing a set of static utilities functions for deep copy.
  62699. */
  62700. export class DeepCopier {
  62701. /**
  62702. * Tries to copy an object by duplicating every property
  62703. * @param source defines the source object
  62704. * @param destination defines the target object
  62705. * @param doNotCopyList defines a list of properties to avoid
  62706. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62707. */
  62708. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62709. }
  62710. }
  62711. declare module BABYLON {
  62712. /**
  62713. * Class containing a set of static utilities functions for precision date
  62714. */
  62715. export class PrecisionDate {
  62716. /**
  62717. * Gets either window.performance.now() if supported or Date.now() else
  62718. */
  62719. static readonly Now: number;
  62720. }
  62721. }
  62722. declare module BABYLON {
  62723. /** @hidden */
  62724. export class _DevTools {
  62725. static WarnImport(name: string): string;
  62726. }
  62727. }
  62728. declare module BABYLON {
  62729. /**
  62730. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  62731. */
  62732. export class WebRequest {
  62733. private _xhr;
  62734. /**
  62735. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  62736. * i.e. when loading files, where the server/service expects an Authorization header
  62737. */
  62738. static CustomRequestHeaders: {
  62739. [key: string]: string;
  62740. };
  62741. /**
  62742. * Add callback functions in this array to update all the requests before they get sent to the network
  62743. */
  62744. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  62745. private _injectCustomRequestHeaders;
  62746. /**
  62747. * Gets or sets a function to be called when loading progress changes
  62748. */
  62749. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  62750. /**
  62751. * Returns client's state
  62752. */
  62753. readonly readyState: number;
  62754. /**
  62755. * Returns client's status
  62756. */
  62757. readonly status: number;
  62758. /**
  62759. * Returns client's status as a text
  62760. */
  62761. readonly statusText: string;
  62762. /**
  62763. * Returns client's response
  62764. */
  62765. readonly response: any;
  62766. /**
  62767. * Returns client's response url
  62768. */
  62769. readonly responseURL: string;
  62770. /**
  62771. * Returns client's response as text
  62772. */
  62773. readonly responseText: string;
  62774. /**
  62775. * Gets or sets the expected response type
  62776. */
  62777. responseType: XMLHttpRequestResponseType;
  62778. /** @hidden */
  62779. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  62780. /** @hidden */
  62781. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  62782. /**
  62783. * Cancels any network activity
  62784. */
  62785. abort(): void;
  62786. /**
  62787. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  62788. * @param body defines an optional request body
  62789. */
  62790. send(body?: Document | BodyInit | null): void;
  62791. /**
  62792. * Sets the request method, request URL
  62793. * @param method defines the method to use (GET, POST, etc..)
  62794. * @param url defines the url to connect with
  62795. */
  62796. open(method: string, url: string): void;
  62797. }
  62798. }
  62799. declare module BABYLON {
  62800. /**
  62801. * Class used to evalaute queries containing `and` and `or` operators
  62802. */
  62803. export class AndOrNotEvaluator {
  62804. /**
  62805. * Evaluate a query
  62806. * @param query defines the query to evaluate
  62807. * @param evaluateCallback defines the callback used to filter result
  62808. * @returns true if the query matches
  62809. */
  62810. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62811. private static _HandleParenthesisContent;
  62812. private static _SimplifyNegation;
  62813. }
  62814. }
  62815. declare module BABYLON {
  62816. /**
  62817. * Class used to store custom tags
  62818. */
  62819. export class Tags {
  62820. /**
  62821. * Adds support for tags on the given object
  62822. * @param obj defines the object to use
  62823. */
  62824. static EnableFor(obj: any): void;
  62825. /**
  62826. * Removes tags support
  62827. * @param obj defines the object to use
  62828. */
  62829. static DisableFor(obj: any): void;
  62830. /**
  62831. * Gets a boolean indicating if the given object has tags
  62832. * @param obj defines the object to use
  62833. * @returns a boolean
  62834. */
  62835. static HasTags(obj: any): boolean;
  62836. /**
  62837. * Gets the tags available on a given object
  62838. * @param obj defines the object to use
  62839. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62840. * @returns the tags
  62841. */
  62842. static GetTags(obj: any, asString?: boolean): any;
  62843. /**
  62844. * Adds tags to an object
  62845. * @param obj defines the object to use
  62846. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62847. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62848. */
  62849. static AddTagsTo(obj: any, tagsString: string): void;
  62850. /**
  62851. * @hidden
  62852. */
  62853. static _AddTagTo(obj: any, tag: string): void;
  62854. /**
  62855. * Removes specific tags from a specific object
  62856. * @param obj defines the object to use
  62857. * @param tagsString defines the tags to remove
  62858. */
  62859. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62860. /**
  62861. * @hidden
  62862. */
  62863. static _RemoveTagFrom(obj: any, tag: string): void;
  62864. /**
  62865. * Defines if tags hosted on an object match a given query
  62866. * @param obj defines the object to use
  62867. * @param tagsQuery defines the tag query
  62868. * @returns a boolean
  62869. */
  62870. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62871. }
  62872. }
  62873. declare module BABYLON {
  62874. /**
  62875. * Manages the defines for the Material
  62876. */
  62877. export class MaterialDefines {
  62878. private _keys;
  62879. private _isDirty;
  62880. /** @hidden */
  62881. _renderId: number;
  62882. /** @hidden */
  62883. _areLightsDirty: boolean;
  62884. /** @hidden */
  62885. _areAttributesDirty: boolean;
  62886. /** @hidden */
  62887. _areTexturesDirty: boolean;
  62888. /** @hidden */
  62889. _areFresnelDirty: boolean;
  62890. /** @hidden */
  62891. _areMiscDirty: boolean;
  62892. /** @hidden */
  62893. _areImageProcessingDirty: boolean;
  62894. /** @hidden */
  62895. _normals: boolean;
  62896. /** @hidden */
  62897. _uvs: boolean;
  62898. /** @hidden */
  62899. _needNormals: boolean;
  62900. /** @hidden */
  62901. _needUVs: boolean;
  62902. /**
  62903. * Specifies if the material needs to be re-calculated
  62904. */
  62905. readonly isDirty: boolean;
  62906. /**
  62907. * Marks the material to indicate that it has been re-calculated
  62908. */
  62909. markAsProcessed(): void;
  62910. /**
  62911. * Marks the material to indicate that it needs to be re-calculated
  62912. */
  62913. markAsUnprocessed(): void;
  62914. /**
  62915. * Marks the material to indicate all of its defines need to be re-calculated
  62916. */
  62917. markAllAsDirty(): void;
  62918. /**
  62919. * Marks the material to indicate that image processing needs to be re-calculated
  62920. */
  62921. markAsImageProcessingDirty(): void;
  62922. /**
  62923. * Marks the material to indicate the lights need to be re-calculated
  62924. */
  62925. markAsLightDirty(): void;
  62926. /**
  62927. * Marks the attribute state as changed
  62928. */
  62929. markAsAttributesDirty(): void;
  62930. /**
  62931. * Marks the texture state as changed
  62932. */
  62933. markAsTexturesDirty(): void;
  62934. /**
  62935. * Marks the fresnel state as changed
  62936. */
  62937. markAsFresnelDirty(): void;
  62938. /**
  62939. * Marks the misc state as changed
  62940. */
  62941. markAsMiscDirty(): void;
  62942. /**
  62943. * Rebuilds the material defines
  62944. */
  62945. rebuild(): void;
  62946. /**
  62947. * Specifies if two material defines are equal
  62948. * @param other - A material define instance to compare to
  62949. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62950. */
  62951. isEqual(other: MaterialDefines): boolean;
  62952. /**
  62953. * Clones this instance's defines to another instance
  62954. * @param other - material defines to clone values to
  62955. */
  62956. cloneTo(other: MaterialDefines): void;
  62957. /**
  62958. * Resets the material define values
  62959. */
  62960. reset(): void;
  62961. /**
  62962. * Converts the material define values to a string
  62963. * @returns - String of material define information
  62964. */
  62965. toString(): string;
  62966. }
  62967. }
  62968. declare module BABYLON {
  62969. /**
  62970. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62971. */
  62972. export class PerformanceMonitor {
  62973. private _enabled;
  62974. private _rollingFrameTime;
  62975. private _lastFrameTimeMs;
  62976. /**
  62977. * constructor
  62978. * @param frameSampleSize The number of samples required to saturate the sliding window
  62979. */
  62980. constructor(frameSampleSize?: number);
  62981. /**
  62982. * Samples current frame
  62983. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62984. */
  62985. sampleFrame(timeMs?: number): void;
  62986. /**
  62987. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62988. */
  62989. readonly averageFrameTime: number;
  62990. /**
  62991. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62992. */
  62993. readonly averageFrameTimeVariance: number;
  62994. /**
  62995. * Returns the frame time of the most recent frame
  62996. */
  62997. readonly instantaneousFrameTime: number;
  62998. /**
  62999. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63000. */
  63001. readonly averageFPS: number;
  63002. /**
  63003. * Returns the average framerate in frames per second using the most recent frame time
  63004. */
  63005. readonly instantaneousFPS: number;
  63006. /**
  63007. * Returns true if enough samples have been taken to completely fill the sliding window
  63008. */
  63009. readonly isSaturated: boolean;
  63010. /**
  63011. * Enables contributions to the sliding window sample set
  63012. */
  63013. enable(): void;
  63014. /**
  63015. * Disables contributions to the sliding window sample set
  63016. * Samples will not be interpolated over the disabled period
  63017. */
  63018. disable(): void;
  63019. /**
  63020. * Returns true if sampling is enabled
  63021. */
  63022. readonly isEnabled: boolean;
  63023. /**
  63024. * Resets performance monitor
  63025. */
  63026. reset(): void;
  63027. }
  63028. /**
  63029. * RollingAverage
  63030. *
  63031. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63032. */
  63033. export class RollingAverage {
  63034. /**
  63035. * Current average
  63036. */
  63037. average: number;
  63038. /**
  63039. * Current variance
  63040. */
  63041. variance: number;
  63042. protected _samples: Array<number>;
  63043. protected _sampleCount: number;
  63044. protected _pos: number;
  63045. protected _m2: number;
  63046. /**
  63047. * constructor
  63048. * @param length The number of samples required to saturate the sliding window
  63049. */
  63050. constructor(length: number);
  63051. /**
  63052. * Adds a sample to the sample set
  63053. * @param v The sample value
  63054. */
  63055. add(v: number): void;
  63056. /**
  63057. * Returns previously added values or null if outside of history or outside the sliding window domain
  63058. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63059. * @return Value previously recorded with add() or null if outside of range
  63060. */
  63061. history(i: number): number;
  63062. /**
  63063. * Returns true if enough samples have been taken to completely fill the sliding window
  63064. * @return true if sample-set saturated
  63065. */
  63066. isSaturated(): boolean;
  63067. /**
  63068. * Resets the rolling average (equivalent to 0 samples taken so far)
  63069. */
  63070. reset(): void;
  63071. /**
  63072. * Wraps a value around the sample range boundaries
  63073. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63074. * @return Wrapped position in sample range
  63075. */
  63076. protected _wrapPosition(i: number): number;
  63077. }
  63078. }
  63079. declare module BABYLON {
  63080. /**
  63081. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63082. * The underlying implementation relies on an associative array to ensure the best performances.
  63083. * The value can be anything including 'null' but except 'undefined'
  63084. */
  63085. export class StringDictionary<T> {
  63086. /**
  63087. * This will clear this dictionary and copy the content from the 'source' one.
  63088. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63089. * @param source the dictionary to take the content from and copy to this dictionary
  63090. */
  63091. copyFrom(source: StringDictionary<T>): void;
  63092. /**
  63093. * Get a value based from its key
  63094. * @param key the given key to get the matching value from
  63095. * @return the value if found, otherwise undefined is returned
  63096. */
  63097. get(key: string): T | undefined;
  63098. /**
  63099. * Get a value from its key or add it if it doesn't exist.
  63100. * This method will ensure you that a given key/data will be present in the dictionary.
  63101. * @param key the given key to get the matching value from
  63102. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63103. * The factory will only be invoked if there's no data for the given key.
  63104. * @return the value corresponding to the key.
  63105. */
  63106. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63107. /**
  63108. * Get a value from its key if present in the dictionary otherwise add it
  63109. * @param key the key to get the value from
  63110. * @param val if there's no such key/value pair in the dictionary add it with this value
  63111. * @return the value corresponding to the key
  63112. */
  63113. getOrAdd(key: string, val: T): T;
  63114. /**
  63115. * Check if there's a given key in the dictionary
  63116. * @param key the key to check for
  63117. * @return true if the key is present, false otherwise
  63118. */
  63119. contains(key: string): boolean;
  63120. /**
  63121. * Add a new key and its corresponding value
  63122. * @param key the key to add
  63123. * @param value the value corresponding to the key
  63124. * @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
  63125. */
  63126. add(key: string, value: T): boolean;
  63127. /**
  63128. * Update a specific value associated to a key
  63129. * @param key defines the key to use
  63130. * @param value defines the value to store
  63131. * @returns true if the value was updated (or false if the key was not found)
  63132. */
  63133. set(key: string, value: T): boolean;
  63134. /**
  63135. * Get the element of the given key and remove it from the dictionary
  63136. * @param key defines the key to search
  63137. * @returns the value associated with the key or null if not found
  63138. */
  63139. getAndRemove(key: string): Nullable<T>;
  63140. /**
  63141. * Remove a key/value from the dictionary.
  63142. * @param key the key to remove
  63143. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63144. */
  63145. remove(key: string): boolean;
  63146. /**
  63147. * Clear the whole content of the dictionary
  63148. */
  63149. clear(): void;
  63150. /**
  63151. * Gets the current count
  63152. */
  63153. readonly count: number;
  63154. /**
  63155. * Execute a callback on each key/val of the dictionary.
  63156. * Note that you can remove any element in this dictionary in the callback implementation
  63157. * @param callback the callback to execute on a given key/value pair
  63158. */
  63159. forEach(callback: (key: string, val: T) => void): void;
  63160. /**
  63161. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63162. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63163. * Note that you can remove any element in this dictionary in the callback implementation
  63164. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63165. * @returns the first item
  63166. */
  63167. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63168. private _count;
  63169. private _data;
  63170. }
  63171. }
  63172. declare module BABYLON {
  63173. /**
  63174. * Helper class that provides a small promise polyfill
  63175. */
  63176. export class PromisePolyfill {
  63177. /**
  63178. * Static function used to check if the polyfill is required
  63179. * If this is the case then the function will inject the polyfill to window.Promise
  63180. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63181. */
  63182. static Apply(force?: boolean): void;
  63183. }
  63184. }
  63185. declare module BABYLON {
  63186. /**
  63187. * Class used to store data that will be store in GPU memory
  63188. */
  63189. export class Buffer {
  63190. private _engine;
  63191. private _buffer;
  63192. /** @hidden */
  63193. _data: Nullable<DataArray>;
  63194. private _updatable;
  63195. private _instanced;
  63196. /**
  63197. * Gets the byte stride.
  63198. */
  63199. readonly byteStride: number;
  63200. /**
  63201. * Constructor
  63202. * @param engine the engine
  63203. * @param data the data to use for this buffer
  63204. * @param updatable whether the data is updatable
  63205. * @param stride the stride (optional)
  63206. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63207. * @param instanced whether the buffer is instanced (optional)
  63208. * @param useBytes set to true if the stride in in bytes (optional)
  63209. */
  63210. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63211. /**
  63212. * Create a new VertexBuffer based on the current buffer
  63213. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63214. * @param offset defines offset in the buffer (0 by default)
  63215. * @param size defines the size in floats of attributes (position is 3 for instance)
  63216. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63217. * @param instanced defines if the vertex buffer contains indexed data
  63218. * @param useBytes defines if the offset and stride are in bytes
  63219. * @returns the new vertex buffer
  63220. */
  63221. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63222. /**
  63223. * Gets a boolean indicating if the Buffer is updatable?
  63224. * @returns true if the buffer is updatable
  63225. */
  63226. isUpdatable(): boolean;
  63227. /**
  63228. * Gets current buffer's data
  63229. * @returns a DataArray or null
  63230. */
  63231. getData(): Nullable<DataArray>;
  63232. /**
  63233. * Gets underlying native buffer
  63234. * @returns underlying native buffer
  63235. */
  63236. getBuffer(): Nullable<WebGLBuffer>;
  63237. /**
  63238. * Gets the stride in float32 units (i.e. byte stride / 4).
  63239. * May not be an integer if the byte stride is not divisible by 4.
  63240. * DEPRECATED. Use byteStride instead.
  63241. * @returns the stride in float32 units
  63242. */
  63243. getStrideSize(): number;
  63244. /**
  63245. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63246. * @param data defines the data to store
  63247. */
  63248. create(data?: Nullable<DataArray>): void;
  63249. /** @hidden */
  63250. _rebuild(): void;
  63251. /**
  63252. * Update current buffer data
  63253. * @param data defines the data to store
  63254. */
  63255. update(data: DataArray): void;
  63256. /**
  63257. * Updates the data directly.
  63258. * @param data the new data
  63259. * @param offset the new offset
  63260. * @param vertexCount the vertex count (optional)
  63261. * @param useBytes set to true if the offset is in bytes
  63262. */
  63263. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63264. /**
  63265. * Release all resources
  63266. */
  63267. dispose(): void;
  63268. }
  63269. /**
  63270. * Specialized buffer used to store vertex data
  63271. */
  63272. export class VertexBuffer {
  63273. /** @hidden */
  63274. _buffer: Buffer;
  63275. private _kind;
  63276. private _size;
  63277. private _ownsBuffer;
  63278. private _instanced;
  63279. private _instanceDivisor;
  63280. /**
  63281. * The byte type.
  63282. */
  63283. static readonly BYTE: number;
  63284. /**
  63285. * The unsigned byte type.
  63286. */
  63287. static readonly UNSIGNED_BYTE: number;
  63288. /**
  63289. * The short type.
  63290. */
  63291. static readonly SHORT: number;
  63292. /**
  63293. * The unsigned short type.
  63294. */
  63295. static readonly UNSIGNED_SHORT: number;
  63296. /**
  63297. * The integer type.
  63298. */
  63299. static readonly INT: number;
  63300. /**
  63301. * The unsigned integer type.
  63302. */
  63303. static readonly UNSIGNED_INT: number;
  63304. /**
  63305. * The float type.
  63306. */
  63307. static readonly FLOAT: number;
  63308. /**
  63309. * Gets or sets the instance divisor when in instanced mode
  63310. */
  63311. instanceDivisor: number;
  63312. /**
  63313. * Gets the byte stride.
  63314. */
  63315. readonly byteStride: number;
  63316. /**
  63317. * Gets the byte offset.
  63318. */
  63319. readonly byteOffset: number;
  63320. /**
  63321. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63322. */
  63323. readonly normalized: boolean;
  63324. /**
  63325. * Gets the data type of each component in the array.
  63326. */
  63327. readonly type: number;
  63328. /**
  63329. * Constructor
  63330. * @param engine the engine
  63331. * @param data the data to use for this vertex buffer
  63332. * @param kind the vertex buffer kind
  63333. * @param updatable whether the data is updatable
  63334. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63335. * @param stride the stride (optional)
  63336. * @param instanced whether the buffer is instanced (optional)
  63337. * @param offset the offset of the data (optional)
  63338. * @param size the number of components (optional)
  63339. * @param type the type of the component (optional)
  63340. * @param normalized whether the data contains normalized data (optional)
  63341. * @param useBytes set to true if stride and offset are in bytes (optional)
  63342. */
  63343. 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);
  63344. /** @hidden */
  63345. _rebuild(): void;
  63346. /**
  63347. * Returns the kind of the VertexBuffer (string)
  63348. * @returns a string
  63349. */
  63350. getKind(): string;
  63351. /**
  63352. * Gets a boolean indicating if the VertexBuffer is updatable?
  63353. * @returns true if the buffer is updatable
  63354. */
  63355. isUpdatable(): boolean;
  63356. /**
  63357. * Gets current buffer's data
  63358. * @returns a DataArray or null
  63359. */
  63360. getData(): Nullable<DataArray>;
  63361. /**
  63362. * Gets underlying native buffer
  63363. * @returns underlying native buffer
  63364. */
  63365. getBuffer(): Nullable<WebGLBuffer>;
  63366. /**
  63367. * Gets the stride in float32 units (i.e. byte stride / 4).
  63368. * May not be an integer if the byte stride is not divisible by 4.
  63369. * DEPRECATED. Use byteStride instead.
  63370. * @returns the stride in float32 units
  63371. */
  63372. getStrideSize(): number;
  63373. /**
  63374. * Returns the offset as a multiple of the type byte length.
  63375. * DEPRECATED. Use byteOffset instead.
  63376. * @returns the offset in bytes
  63377. */
  63378. getOffset(): number;
  63379. /**
  63380. * Returns the number of components per vertex attribute (integer)
  63381. * @returns the size in float
  63382. */
  63383. getSize(): number;
  63384. /**
  63385. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63386. * @returns true if this buffer is instanced
  63387. */
  63388. getIsInstanced(): boolean;
  63389. /**
  63390. * Returns the instancing divisor, zero for non-instanced (integer).
  63391. * @returns a number
  63392. */
  63393. getInstanceDivisor(): number;
  63394. /**
  63395. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63396. * @param data defines the data to store
  63397. */
  63398. create(data?: DataArray): void;
  63399. /**
  63400. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63401. * This function will create a new buffer if the current one is not updatable
  63402. * @param data defines the data to store
  63403. */
  63404. update(data: DataArray): void;
  63405. /**
  63406. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63407. * Returns the directly updated WebGLBuffer.
  63408. * @param data the new data
  63409. * @param offset the new offset
  63410. * @param useBytes set to true if the offset is in bytes
  63411. */
  63412. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63413. /**
  63414. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63415. */
  63416. dispose(): void;
  63417. /**
  63418. * Enumerates each value of this vertex buffer as numbers.
  63419. * @param count the number of values to enumerate
  63420. * @param callback the callback function called for each value
  63421. */
  63422. forEach(count: number, callback: (value: number, index: number) => void): void;
  63423. /**
  63424. * Positions
  63425. */
  63426. static readonly PositionKind: string;
  63427. /**
  63428. * Normals
  63429. */
  63430. static readonly NormalKind: string;
  63431. /**
  63432. * Tangents
  63433. */
  63434. static readonly TangentKind: string;
  63435. /**
  63436. * Texture coordinates
  63437. */
  63438. static readonly UVKind: string;
  63439. /**
  63440. * Texture coordinates 2
  63441. */
  63442. static readonly UV2Kind: string;
  63443. /**
  63444. * Texture coordinates 3
  63445. */
  63446. static readonly UV3Kind: string;
  63447. /**
  63448. * Texture coordinates 4
  63449. */
  63450. static readonly UV4Kind: string;
  63451. /**
  63452. * Texture coordinates 5
  63453. */
  63454. static readonly UV5Kind: string;
  63455. /**
  63456. * Texture coordinates 6
  63457. */
  63458. static readonly UV6Kind: string;
  63459. /**
  63460. * Colors
  63461. */
  63462. static readonly ColorKind: string;
  63463. /**
  63464. * Matrix indices (for bones)
  63465. */
  63466. static readonly MatricesIndicesKind: string;
  63467. /**
  63468. * Matrix weights (for bones)
  63469. */
  63470. static readonly MatricesWeightsKind: string;
  63471. /**
  63472. * Additional matrix indices (for bones)
  63473. */
  63474. static readonly MatricesIndicesExtraKind: string;
  63475. /**
  63476. * Additional matrix weights (for bones)
  63477. */
  63478. static readonly MatricesWeightsExtraKind: string;
  63479. /**
  63480. * Deduces the stride given a kind.
  63481. * @param kind The kind string to deduce
  63482. * @returns The deduced stride
  63483. */
  63484. static DeduceStride(kind: string): number;
  63485. /**
  63486. * Gets the byte length of the given type.
  63487. * @param type the type
  63488. * @returns the number of bytes
  63489. */
  63490. static GetTypeByteLength(type: number): number;
  63491. /**
  63492. * Enumerates each value of the given parameters as numbers.
  63493. * @param data the data to enumerate
  63494. * @param byteOffset the byte offset of the data
  63495. * @param byteStride the byte stride of the data
  63496. * @param componentCount the number of components per element
  63497. * @param componentType the type of the component
  63498. * @param count the total number of components
  63499. * @param normalized whether the data is normalized
  63500. * @param callback the callback function called for each value
  63501. */
  63502. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63503. private static _GetFloatValue;
  63504. }
  63505. }
  63506. declare module BABYLON {
  63507. /**
  63508. * Class representing spherical polynomial coefficients to the 3rd degree
  63509. */
  63510. export class SphericalPolynomial {
  63511. /**
  63512. * The x coefficients of the spherical polynomial
  63513. */
  63514. x: Vector3;
  63515. /**
  63516. * The y coefficients of the spherical polynomial
  63517. */
  63518. y: Vector3;
  63519. /**
  63520. * The z coefficients of the spherical polynomial
  63521. */
  63522. z: Vector3;
  63523. /**
  63524. * The xx coefficients of the spherical polynomial
  63525. */
  63526. xx: Vector3;
  63527. /**
  63528. * The yy coefficients of the spherical polynomial
  63529. */
  63530. yy: Vector3;
  63531. /**
  63532. * The zz coefficients of the spherical polynomial
  63533. */
  63534. zz: Vector3;
  63535. /**
  63536. * The xy coefficients of the spherical polynomial
  63537. */
  63538. xy: Vector3;
  63539. /**
  63540. * The yz coefficients of the spherical polynomial
  63541. */
  63542. yz: Vector3;
  63543. /**
  63544. * The zx coefficients of the spherical polynomial
  63545. */
  63546. zx: Vector3;
  63547. /**
  63548. * Adds an ambient color to the spherical polynomial
  63549. * @param color the color to add
  63550. */
  63551. addAmbient(color: Color3): void;
  63552. /**
  63553. * Scales the spherical polynomial by the given amount
  63554. * @param scale the amount to scale
  63555. */
  63556. scale(scale: number): void;
  63557. /**
  63558. * Gets the spherical polynomial from harmonics
  63559. * @param harmonics the spherical harmonics
  63560. * @returns the spherical polynomial
  63561. */
  63562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63563. /**
  63564. * Constructs a spherical polynomial from an array.
  63565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63566. * @returns the spherical polynomial
  63567. */
  63568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63569. }
  63570. /**
  63571. * Class representing spherical harmonics coefficients to the 3rd degree
  63572. */
  63573. export class SphericalHarmonics {
  63574. /**
  63575. * The l0,0 coefficients of the spherical harmonics
  63576. */
  63577. l00: Vector3;
  63578. /**
  63579. * The l1,-1 coefficients of the spherical harmonics
  63580. */
  63581. l1_1: Vector3;
  63582. /**
  63583. * The l1,0 coefficients of the spherical harmonics
  63584. */
  63585. l10: Vector3;
  63586. /**
  63587. * The l1,1 coefficients of the spherical harmonics
  63588. */
  63589. l11: Vector3;
  63590. /**
  63591. * The l2,-2 coefficients of the spherical harmonics
  63592. */
  63593. l2_2: Vector3;
  63594. /**
  63595. * The l2,-1 coefficients of the spherical harmonics
  63596. */
  63597. l2_1: Vector3;
  63598. /**
  63599. * The l2,0 coefficients of the spherical harmonics
  63600. */
  63601. l20: Vector3;
  63602. /**
  63603. * The l2,1 coefficients of the spherical harmonics
  63604. */
  63605. l21: Vector3;
  63606. /**
  63607. * The l2,2 coefficients of the spherical harmonics
  63608. */
  63609. lL22: Vector3;
  63610. /**
  63611. * Adds a light to the spherical harmonics
  63612. * @param direction the direction of the light
  63613. * @param color the color of the light
  63614. * @param deltaSolidAngle the delta solid angle of the light
  63615. */
  63616. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63617. /**
  63618. * Scales the spherical harmonics by the given amount
  63619. * @param scale the amount to scale
  63620. */
  63621. scale(scale: number): void;
  63622. /**
  63623. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63624. *
  63625. * ```
  63626. * E_lm = A_l * L_lm
  63627. * ```
  63628. *
  63629. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63630. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63631. * the scaling factors are given in equation 9.
  63632. */
  63633. convertIncidentRadianceToIrradiance(): void;
  63634. /**
  63635. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63636. *
  63637. * ```
  63638. * L = (1/pi) * E * rho
  63639. * ```
  63640. *
  63641. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63642. */
  63643. convertIrradianceToLambertianRadiance(): void;
  63644. /**
  63645. * Gets the spherical harmonics from polynomial
  63646. * @param polynomial the spherical polynomial
  63647. * @returns the spherical harmonics
  63648. */
  63649. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63650. /**
  63651. * Constructs a spherical harmonics from an array.
  63652. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63653. * @returns the spherical harmonics
  63654. */
  63655. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63656. }
  63657. }
  63658. declare module BABYLON {
  63659. /**
  63660. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63661. */
  63662. export interface CubeMapInfo {
  63663. /**
  63664. * The pixel array for the front face.
  63665. * This is stored in format, left to right, up to down format.
  63666. */
  63667. front: Nullable<ArrayBufferView>;
  63668. /**
  63669. * The pixel array for the back face.
  63670. * This is stored in format, left to right, up to down format.
  63671. */
  63672. back: Nullable<ArrayBufferView>;
  63673. /**
  63674. * The pixel array for the left face.
  63675. * This is stored in format, left to right, up to down format.
  63676. */
  63677. left: Nullable<ArrayBufferView>;
  63678. /**
  63679. * The pixel array for the right face.
  63680. * This is stored in format, left to right, up to down format.
  63681. */
  63682. right: Nullable<ArrayBufferView>;
  63683. /**
  63684. * The pixel array for the up face.
  63685. * This is stored in format, left to right, up to down format.
  63686. */
  63687. up: Nullable<ArrayBufferView>;
  63688. /**
  63689. * The pixel array for the down face.
  63690. * This is stored in format, left to right, up to down format.
  63691. */
  63692. down: Nullable<ArrayBufferView>;
  63693. /**
  63694. * The size of the cubemap stored.
  63695. *
  63696. * Each faces will be size * size pixels.
  63697. */
  63698. size: number;
  63699. /**
  63700. * The format of the texture.
  63701. *
  63702. * RGBA, RGB.
  63703. */
  63704. format: number;
  63705. /**
  63706. * The type of the texture data.
  63707. *
  63708. * UNSIGNED_INT, FLOAT.
  63709. */
  63710. type: number;
  63711. /**
  63712. * Specifies whether the texture is in gamma space.
  63713. */
  63714. gammaSpace: boolean;
  63715. }
  63716. /**
  63717. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63718. */
  63719. export class PanoramaToCubeMapTools {
  63720. private static FACE_FRONT;
  63721. private static FACE_BACK;
  63722. private static FACE_RIGHT;
  63723. private static FACE_LEFT;
  63724. private static FACE_DOWN;
  63725. private static FACE_UP;
  63726. /**
  63727. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63728. *
  63729. * @param float32Array The source data.
  63730. * @param inputWidth The width of the input panorama.
  63731. * @param inputHeight The height of the input panorama.
  63732. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63733. * @return The cubemap data
  63734. */
  63735. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63736. private static CreateCubemapTexture;
  63737. private static CalcProjectionSpherical;
  63738. }
  63739. }
  63740. declare module BABYLON {
  63741. /**
  63742. * Helper class dealing with the extraction of spherical polynomial dataArray
  63743. * from a cube map.
  63744. */
  63745. export class CubeMapToSphericalPolynomialTools {
  63746. private static FileFaces;
  63747. /**
  63748. * Converts a texture to the according Spherical Polynomial data.
  63749. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63750. *
  63751. * @param texture The texture to extract the information from.
  63752. * @return The Spherical Polynomial data.
  63753. */
  63754. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63755. /**
  63756. * Converts a cubemap to the according Spherical Polynomial data.
  63757. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63758. *
  63759. * @param cubeInfo The Cube map to extract the information from.
  63760. * @return The Spherical Polynomial data.
  63761. */
  63762. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63763. }
  63764. }
  63765. declare module BABYLON {
  63766. /**
  63767. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63768. * during the life time of the application.
  63769. */
  63770. export class EngineStore {
  63771. /** Gets the list of created engines */
  63772. static Instances: Engine[];
  63773. /**
  63774. * Gets the latest created engine
  63775. */
  63776. static readonly LastCreatedEngine: Nullable<Engine>;
  63777. /**
  63778. * Gets the latest created scene
  63779. */
  63780. static readonly LastCreatedScene: Nullable<Scene>;
  63781. }
  63782. }
  63783. declare module BABYLON {
  63784. /**
  63785. * Define options used to create a render target texture
  63786. */
  63787. export class RenderTargetCreationOptions {
  63788. /**
  63789. * Specifies is mipmaps must be generated
  63790. */
  63791. generateMipMaps?: boolean;
  63792. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63793. generateDepthBuffer?: boolean;
  63794. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63795. generateStencilBuffer?: boolean;
  63796. /** Defines texture type (int by default) */
  63797. type?: number;
  63798. /** Defines sampling mode (trilinear by default) */
  63799. samplingMode?: number;
  63800. /** Defines format (RGBA by default) */
  63801. format?: number;
  63802. }
  63803. }
  63804. declare module BABYLON {
  63805. /**
  63806. * @hidden
  63807. **/
  63808. export class _AlphaState {
  63809. private _isAlphaBlendDirty;
  63810. private _isBlendFunctionParametersDirty;
  63811. private _isBlendEquationParametersDirty;
  63812. private _isBlendConstantsDirty;
  63813. private _alphaBlend;
  63814. private _blendFunctionParameters;
  63815. private _blendEquationParameters;
  63816. private _blendConstants;
  63817. /**
  63818. * Initializes the state.
  63819. */
  63820. constructor();
  63821. readonly isDirty: boolean;
  63822. alphaBlend: boolean;
  63823. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63824. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63825. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63826. reset(): void;
  63827. apply(gl: WebGLRenderingContext): void;
  63828. }
  63829. }
  63830. declare module BABYLON {
  63831. /**
  63832. * @hidden
  63833. **/
  63834. export class _DepthCullingState {
  63835. private _isDepthTestDirty;
  63836. private _isDepthMaskDirty;
  63837. private _isDepthFuncDirty;
  63838. private _isCullFaceDirty;
  63839. private _isCullDirty;
  63840. private _isZOffsetDirty;
  63841. private _isFrontFaceDirty;
  63842. private _depthTest;
  63843. private _depthMask;
  63844. private _depthFunc;
  63845. private _cull;
  63846. private _cullFace;
  63847. private _zOffset;
  63848. private _frontFace;
  63849. /**
  63850. * Initializes the state.
  63851. */
  63852. constructor();
  63853. readonly isDirty: boolean;
  63854. zOffset: number;
  63855. cullFace: Nullable<number>;
  63856. cull: Nullable<boolean>;
  63857. depthFunc: Nullable<number>;
  63858. depthMask: boolean;
  63859. depthTest: boolean;
  63860. frontFace: Nullable<number>;
  63861. reset(): void;
  63862. apply(gl: WebGLRenderingContext): void;
  63863. }
  63864. }
  63865. declare module BABYLON {
  63866. /**
  63867. * @hidden
  63868. **/
  63869. export class _StencilState {
  63870. /** 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 */
  63871. static readonly ALWAYS: number;
  63872. /** Passed to stencilOperation to specify that stencil value must be kept */
  63873. static readonly KEEP: number;
  63874. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63875. static readonly REPLACE: number;
  63876. private _isStencilTestDirty;
  63877. private _isStencilMaskDirty;
  63878. private _isStencilFuncDirty;
  63879. private _isStencilOpDirty;
  63880. private _stencilTest;
  63881. private _stencilMask;
  63882. private _stencilFunc;
  63883. private _stencilFuncRef;
  63884. private _stencilFuncMask;
  63885. private _stencilOpStencilFail;
  63886. private _stencilOpDepthFail;
  63887. private _stencilOpStencilDepthPass;
  63888. readonly isDirty: boolean;
  63889. stencilFunc: number;
  63890. stencilFuncRef: number;
  63891. stencilFuncMask: number;
  63892. stencilOpStencilFail: number;
  63893. stencilOpDepthFail: number;
  63894. stencilOpStencilDepthPass: number;
  63895. stencilMask: number;
  63896. stencilTest: boolean;
  63897. constructor();
  63898. reset(): void;
  63899. apply(gl: WebGLRenderingContext): void;
  63900. }
  63901. }
  63902. declare module BABYLON {
  63903. /**
  63904. * @hidden
  63905. **/
  63906. export class _TimeToken {
  63907. _startTimeQuery: Nullable<WebGLQuery>;
  63908. _endTimeQuery: Nullable<WebGLQuery>;
  63909. _timeElapsedQuery: Nullable<WebGLQuery>;
  63910. _timeElapsedQueryEnded: boolean;
  63911. }
  63912. }
  63913. declare module BABYLON {
  63914. /**
  63915. * Internal interface used to track InternalTexture already bound to the GL context
  63916. */
  63917. export interface IInternalTextureTracker {
  63918. /**
  63919. * Gets or set the previous tracker in the list
  63920. */
  63921. previous: Nullable<IInternalTextureTracker>;
  63922. /**
  63923. * Gets or set the next tracker in the list
  63924. */
  63925. next: Nullable<IInternalTextureTracker>;
  63926. }
  63927. /**
  63928. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63929. */
  63930. export class DummyInternalTextureTracker {
  63931. /**
  63932. * Gets or set the previous tracker in the list
  63933. */
  63934. previous: Nullable<IInternalTextureTracker>;
  63935. /**
  63936. * Gets or set the next tracker in the list
  63937. */
  63938. next: Nullable<IInternalTextureTracker>;
  63939. }
  63940. }
  63941. declare module BABYLON {
  63942. /**
  63943. * Class used to store data associated with WebGL texture data for the engine
  63944. * This class should not be used directly
  63945. */
  63946. export class InternalTexture implements IInternalTextureTracker {
  63947. /** hidden */
  63948. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63949. /**
  63950. * The source of the texture data is unknown
  63951. */
  63952. static DATASOURCE_UNKNOWN: number;
  63953. /**
  63954. * Texture data comes from an URL
  63955. */
  63956. static DATASOURCE_URL: number;
  63957. /**
  63958. * Texture data is only used for temporary storage
  63959. */
  63960. static DATASOURCE_TEMP: number;
  63961. /**
  63962. * Texture data comes from raw data (ArrayBuffer)
  63963. */
  63964. static DATASOURCE_RAW: number;
  63965. /**
  63966. * Texture content is dynamic (video or dynamic texture)
  63967. */
  63968. static DATASOURCE_DYNAMIC: number;
  63969. /**
  63970. * Texture content is generated by rendering to it
  63971. */
  63972. static DATASOURCE_RENDERTARGET: number;
  63973. /**
  63974. * Texture content is part of a multi render target process
  63975. */
  63976. static DATASOURCE_MULTIRENDERTARGET: number;
  63977. /**
  63978. * Texture data comes from a cube data file
  63979. */
  63980. static DATASOURCE_CUBE: number;
  63981. /**
  63982. * Texture data comes from a raw cube data
  63983. */
  63984. static DATASOURCE_CUBERAW: number;
  63985. /**
  63986. * Texture data come from a prefiltered cube data file
  63987. */
  63988. static DATASOURCE_CUBEPREFILTERED: number;
  63989. /**
  63990. * Texture content is raw 3D data
  63991. */
  63992. static DATASOURCE_RAW3D: number;
  63993. /**
  63994. * Texture content is a depth texture
  63995. */
  63996. static DATASOURCE_DEPTHTEXTURE: number;
  63997. /**
  63998. * Texture data comes from a raw cube data encoded with RGBD
  63999. */
  64000. static DATASOURCE_CUBERAW_RGBD: number;
  64001. /**
  64002. * Defines if the texture is ready
  64003. */
  64004. isReady: boolean;
  64005. /**
  64006. * Defines if the texture is a cube texture
  64007. */
  64008. isCube: boolean;
  64009. /**
  64010. * Defines if the texture contains 3D data
  64011. */
  64012. is3D: boolean;
  64013. /**
  64014. * Gets the URL used to load this texture
  64015. */
  64016. url: string;
  64017. /**
  64018. * Gets the sampling mode of the texture
  64019. */
  64020. samplingMode: number;
  64021. /**
  64022. * Gets a boolean indicating if the texture needs mipmaps generation
  64023. */
  64024. generateMipMaps: boolean;
  64025. /**
  64026. * Gets the number of samples used by the texture (WebGL2+ only)
  64027. */
  64028. samples: number;
  64029. /**
  64030. * Gets the type of the texture (int, float...)
  64031. */
  64032. type: number;
  64033. /**
  64034. * Gets the format of the texture (RGB, RGBA...)
  64035. */
  64036. format: number;
  64037. /**
  64038. * Observable called when the texture is loaded
  64039. */
  64040. onLoadedObservable: Observable<InternalTexture>;
  64041. /**
  64042. * Gets the width of the texture
  64043. */
  64044. width: number;
  64045. /**
  64046. * Gets the height of the texture
  64047. */
  64048. height: number;
  64049. /**
  64050. * Gets the depth of the texture
  64051. */
  64052. depth: number;
  64053. /**
  64054. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64055. */
  64056. baseWidth: number;
  64057. /**
  64058. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64059. */
  64060. baseHeight: number;
  64061. /**
  64062. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64063. */
  64064. baseDepth: number;
  64065. /**
  64066. * Gets a boolean indicating if the texture is inverted on Y axis
  64067. */
  64068. invertY: boolean;
  64069. /**
  64070. * Gets or set the previous tracker in the list
  64071. */
  64072. previous: Nullable<IInternalTextureTracker>;
  64073. /**
  64074. * Gets or set the next tracker in the list
  64075. */
  64076. next: Nullable<IInternalTextureTracker>;
  64077. /** @hidden */
  64078. _invertVScale: boolean;
  64079. /** @hidden */
  64080. _initialSlot: number;
  64081. /** @hidden */
  64082. _designatedSlot: number;
  64083. /** @hidden */
  64084. _dataSource: number;
  64085. /** @hidden */
  64086. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64087. /** @hidden */
  64088. _bufferView: Nullable<ArrayBufferView>;
  64089. /** @hidden */
  64090. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64091. /** @hidden */
  64092. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64093. /** @hidden */
  64094. _size: number;
  64095. /** @hidden */
  64096. _extension: string;
  64097. /** @hidden */
  64098. _files: Nullable<string[]>;
  64099. /** @hidden */
  64100. _workingCanvas: HTMLCanvasElement;
  64101. /** @hidden */
  64102. _workingContext: CanvasRenderingContext2D;
  64103. /** @hidden */
  64104. _framebuffer: Nullable<WebGLFramebuffer>;
  64105. /** @hidden */
  64106. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64107. /** @hidden */
  64108. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64109. /** @hidden */
  64110. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64111. /** @hidden */
  64112. _attachments: Nullable<number[]>;
  64113. /** @hidden */
  64114. _cachedCoordinatesMode: Nullable<number>;
  64115. /** @hidden */
  64116. _cachedWrapU: Nullable<number>;
  64117. /** @hidden */
  64118. _cachedWrapV: Nullable<number>;
  64119. /** @hidden */
  64120. _cachedWrapR: Nullable<number>;
  64121. /** @hidden */
  64122. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64123. /** @hidden */
  64124. _isDisabled: boolean;
  64125. /** @hidden */
  64126. _compression: Nullable<string>;
  64127. /** @hidden */
  64128. _generateStencilBuffer: boolean;
  64129. /** @hidden */
  64130. _generateDepthBuffer: boolean;
  64131. /** @hidden */
  64132. _comparisonFunction: number;
  64133. /** @hidden */
  64134. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64135. /** @hidden */
  64136. _lodGenerationScale: number;
  64137. /** @hidden */
  64138. _lodGenerationOffset: number;
  64139. /** @hidden */
  64140. _lodTextureHigh: BaseTexture;
  64141. /** @hidden */
  64142. _lodTextureMid: BaseTexture;
  64143. /** @hidden */
  64144. _lodTextureLow: BaseTexture;
  64145. /** @hidden */
  64146. _isRGBD: boolean;
  64147. /** @hidden */
  64148. _webGLTexture: Nullable<WebGLTexture>;
  64149. /** @hidden */
  64150. _references: number;
  64151. private _engine;
  64152. /**
  64153. * Gets the Engine the texture belongs to.
  64154. * @returns The babylon engine
  64155. */
  64156. getEngine(): Engine;
  64157. /**
  64158. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64159. */
  64160. readonly dataSource: number;
  64161. /**
  64162. * Creates a new InternalTexture
  64163. * @param engine defines the engine to use
  64164. * @param dataSource defines the type of data that will be used
  64165. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64166. */
  64167. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64168. /**
  64169. * Increments the number of references (ie. the number of Texture that point to it)
  64170. */
  64171. incrementReferences(): void;
  64172. /**
  64173. * Change the size of the texture (not the size of the content)
  64174. * @param width defines the new width
  64175. * @param height defines the new height
  64176. * @param depth defines the new depth (1 by default)
  64177. */
  64178. updateSize(width: int, height: int, depth?: int): void;
  64179. /** @hidden */
  64180. _rebuild(): void;
  64181. /** @hidden */
  64182. _swapAndDie(target: InternalTexture): void;
  64183. /**
  64184. * Dispose the current allocated resources
  64185. */
  64186. dispose(): void;
  64187. }
  64188. }
  64189. declare module BABYLON {
  64190. /**
  64191. * This represents the main contract an easing function should follow.
  64192. * Easing functions are used throughout the animation system.
  64193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64194. */
  64195. export interface IEasingFunction {
  64196. /**
  64197. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64198. * of the easing function.
  64199. * The link below provides some of the most common examples of easing functions.
  64200. * @see https://easings.net/
  64201. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64202. * @returns the corresponding value on the curve defined by the easing function
  64203. */
  64204. ease(gradient: number): number;
  64205. }
  64206. /**
  64207. * Base class used for every default easing function.
  64208. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64209. */
  64210. export class EasingFunction implements IEasingFunction {
  64211. /**
  64212. * Interpolation follows the mathematical formula associated with the easing function.
  64213. */
  64214. static readonly EASINGMODE_EASEIN: number;
  64215. /**
  64216. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64217. */
  64218. static readonly EASINGMODE_EASEOUT: number;
  64219. /**
  64220. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64221. */
  64222. static readonly EASINGMODE_EASEINOUT: number;
  64223. private _easingMode;
  64224. /**
  64225. * Sets the easing mode of the current function.
  64226. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64227. */
  64228. setEasingMode(easingMode: number): void;
  64229. /**
  64230. * Gets the current easing mode.
  64231. * @returns the easing mode
  64232. */
  64233. getEasingMode(): number;
  64234. /**
  64235. * @hidden
  64236. */
  64237. easeInCore(gradient: number): number;
  64238. /**
  64239. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64240. * of the easing function.
  64241. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64242. * @returns the corresponding value on the curve defined by the easing function
  64243. */
  64244. ease(gradient: number): number;
  64245. }
  64246. /**
  64247. * Easing function with a circle shape (see link below).
  64248. * @see https://easings.net/#easeInCirc
  64249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64250. */
  64251. export class CircleEase extends EasingFunction implements IEasingFunction {
  64252. /** @hidden */
  64253. easeInCore(gradient: number): number;
  64254. }
  64255. /**
  64256. * Easing function with a ease back shape (see link below).
  64257. * @see https://easings.net/#easeInBack
  64258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64259. */
  64260. export class BackEase extends EasingFunction implements IEasingFunction {
  64261. /** Defines the amplitude of the function */
  64262. amplitude: number;
  64263. /**
  64264. * Instantiates a back ease easing
  64265. * @see https://easings.net/#easeInBack
  64266. * @param amplitude Defines the amplitude of the function
  64267. */
  64268. constructor(
  64269. /** Defines the amplitude of the function */
  64270. amplitude?: number);
  64271. /** @hidden */
  64272. easeInCore(gradient: number): number;
  64273. }
  64274. /**
  64275. * Easing function with a bouncing shape (see link below).
  64276. * @see https://easings.net/#easeInBounce
  64277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64278. */
  64279. export class BounceEase extends EasingFunction implements IEasingFunction {
  64280. /** Defines the number of bounces */
  64281. bounces: number;
  64282. /** Defines the amplitude of the bounce */
  64283. bounciness: number;
  64284. /**
  64285. * Instantiates a bounce easing
  64286. * @see https://easings.net/#easeInBounce
  64287. * @param bounces Defines the number of bounces
  64288. * @param bounciness Defines the amplitude of the bounce
  64289. */
  64290. constructor(
  64291. /** Defines the number of bounces */
  64292. bounces?: number,
  64293. /** Defines the amplitude of the bounce */
  64294. bounciness?: number);
  64295. /** @hidden */
  64296. easeInCore(gradient: number): number;
  64297. }
  64298. /**
  64299. * Easing function with a power of 3 shape (see link below).
  64300. * @see https://easings.net/#easeInCubic
  64301. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64302. */
  64303. export class CubicEase extends EasingFunction implements IEasingFunction {
  64304. /** @hidden */
  64305. easeInCore(gradient: number): number;
  64306. }
  64307. /**
  64308. * Easing function with an elastic shape (see link below).
  64309. * @see https://easings.net/#easeInElastic
  64310. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64311. */
  64312. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64313. /** Defines the number of oscillations*/
  64314. oscillations: number;
  64315. /** Defines the amplitude of the oscillations*/
  64316. springiness: number;
  64317. /**
  64318. * Instantiates an elastic easing function
  64319. * @see https://easings.net/#easeInElastic
  64320. * @param oscillations Defines the number of oscillations
  64321. * @param springiness Defines the amplitude of the oscillations
  64322. */
  64323. constructor(
  64324. /** Defines the number of oscillations*/
  64325. oscillations?: number,
  64326. /** Defines the amplitude of the oscillations*/
  64327. springiness?: number);
  64328. /** @hidden */
  64329. easeInCore(gradient: number): number;
  64330. }
  64331. /**
  64332. * Easing function with an exponential shape (see link below).
  64333. * @see https://easings.net/#easeInExpo
  64334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64335. */
  64336. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64337. /** Defines the exponent of the function */
  64338. exponent: number;
  64339. /**
  64340. * Instantiates an exponential easing function
  64341. * @see https://easings.net/#easeInExpo
  64342. * @param exponent Defines the exponent of the function
  64343. */
  64344. constructor(
  64345. /** Defines the exponent of the function */
  64346. exponent?: number);
  64347. /** @hidden */
  64348. easeInCore(gradient: number): number;
  64349. }
  64350. /**
  64351. * Easing function with a power shape (see link below).
  64352. * @see https://easings.net/#easeInQuad
  64353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64354. */
  64355. export class PowerEase extends EasingFunction implements IEasingFunction {
  64356. /** Defines the power of the function */
  64357. power: number;
  64358. /**
  64359. * Instantiates an power base easing function
  64360. * @see https://easings.net/#easeInQuad
  64361. * @param power Defines the power of the function
  64362. */
  64363. constructor(
  64364. /** Defines the power of the function */
  64365. power?: number);
  64366. /** @hidden */
  64367. easeInCore(gradient: number): number;
  64368. }
  64369. /**
  64370. * Easing function with a power of 2 shape (see link below).
  64371. * @see https://easings.net/#easeInQuad
  64372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64373. */
  64374. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64375. /** @hidden */
  64376. easeInCore(gradient: number): number;
  64377. }
  64378. /**
  64379. * Easing function with a power of 4 shape (see link below).
  64380. * @see https://easings.net/#easeInQuart
  64381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64382. */
  64383. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64384. /** @hidden */
  64385. easeInCore(gradient: number): number;
  64386. }
  64387. /**
  64388. * Easing function with a power of 5 shape (see link below).
  64389. * @see https://easings.net/#easeInQuint
  64390. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64391. */
  64392. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64393. /** @hidden */
  64394. easeInCore(gradient: number): number;
  64395. }
  64396. /**
  64397. * Easing function with a sin shape (see link below).
  64398. * @see https://easings.net/#easeInSine
  64399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64400. */
  64401. export class SineEase extends EasingFunction implements IEasingFunction {
  64402. /** @hidden */
  64403. easeInCore(gradient: number): number;
  64404. }
  64405. /**
  64406. * Easing function with a bezier shape (see link below).
  64407. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64409. */
  64410. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64411. /** Defines the x component of the start tangent in the bezier curve */
  64412. x1: number;
  64413. /** Defines the y component of the start tangent in the bezier curve */
  64414. y1: number;
  64415. /** Defines the x component of the end tangent in the bezier curve */
  64416. x2: number;
  64417. /** Defines the y component of the end tangent in the bezier curve */
  64418. y2: number;
  64419. /**
  64420. * Instantiates a bezier function
  64421. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64422. * @param x1 Defines the x component of the start tangent in the bezier curve
  64423. * @param y1 Defines the y component of the start tangent in the bezier curve
  64424. * @param x2 Defines the x component of the end tangent in the bezier curve
  64425. * @param y2 Defines the y component of the end tangent in the bezier curve
  64426. */
  64427. constructor(
  64428. /** Defines the x component of the start tangent in the bezier curve */
  64429. x1?: number,
  64430. /** Defines the y component of the start tangent in the bezier curve */
  64431. y1?: number,
  64432. /** Defines the x component of the end tangent in the bezier curve */
  64433. x2?: number,
  64434. /** Defines the y component of the end tangent in the bezier curve */
  64435. y2?: number);
  64436. /** @hidden */
  64437. easeInCore(gradient: number): number;
  64438. }
  64439. }
  64440. declare module BABYLON {
  64441. /**
  64442. * Defines an interface which represents an animation key frame
  64443. */
  64444. export interface IAnimationKey {
  64445. /**
  64446. * Frame of the key frame
  64447. */
  64448. frame: number;
  64449. /**
  64450. * Value at the specifies key frame
  64451. */
  64452. value: any;
  64453. /**
  64454. * The input tangent for the cubic hermite spline
  64455. */
  64456. inTangent?: any;
  64457. /**
  64458. * The output tangent for the cubic hermite spline
  64459. */
  64460. outTangent?: any;
  64461. /**
  64462. * The animation interpolation type
  64463. */
  64464. interpolation?: AnimationKeyInterpolation;
  64465. }
  64466. /**
  64467. * Enum for the animation key frame interpolation type
  64468. */
  64469. export enum AnimationKeyInterpolation {
  64470. /**
  64471. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64472. */
  64473. STEP = 1
  64474. }
  64475. }
  64476. declare module BABYLON {
  64477. /**
  64478. * Represents the range of an animation
  64479. */
  64480. export class AnimationRange {
  64481. /**The name of the animation range**/
  64482. name: string;
  64483. /**The starting frame of the animation */
  64484. from: number;
  64485. /**The ending frame of the animation*/
  64486. to: number;
  64487. /**
  64488. * Initializes the range of an animation
  64489. * @param name The name of the animation range
  64490. * @param from The starting frame of the animation
  64491. * @param to The ending frame of the animation
  64492. */
  64493. constructor(
  64494. /**The name of the animation range**/
  64495. name: string,
  64496. /**The starting frame of the animation */
  64497. from: number,
  64498. /**The ending frame of the animation*/
  64499. to: number);
  64500. /**
  64501. * Makes a copy of the animation range
  64502. * @returns A copy of the animation range
  64503. */
  64504. clone(): AnimationRange;
  64505. }
  64506. }
  64507. declare module BABYLON {
  64508. /**
  64509. * Composed of a frame, and an action function
  64510. */
  64511. export class AnimationEvent {
  64512. /** The frame for which the event is triggered **/
  64513. frame: number;
  64514. /** The event to perform when triggered **/
  64515. action: (currentFrame: number) => void;
  64516. /** Specifies if the event should be triggered only once**/
  64517. onlyOnce?: boolean | undefined;
  64518. /**
  64519. * Specifies if the animation event is done
  64520. */
  64521. isDone: boolean;
  64522. /**
  64523. * Initializes the animation event
  64524. * @param frame The frame for which the event is triggered
  64525. * @param action The event to perform when triggered
  64526. * @param onlyOnce Specifies if the event should be triggered only once
  64527. */
  64528. constructor(
  64529. /** The frame for which the event is triggered **/
  64530. frame: number,
  64531. /** The event to perform when triggered **/
  64532. action: (currentFrame: number) => void,
  64533. /** Specifies if the event should be triggered only once**/
  64534. onlyOnce?: boolean | undefined);
  64535. /** @hidden */
  64536. _clone(): AnimationEvent;
  64537. }
  64538. }
  64539. declare module BABYLON {
  64540. /**
  64541. * Interface used to define a behavior
  64542. */
  64543. export interface Behavior<T> {
  64544. /** gets or sets behavior's name */
  64545. name: string;
  64546. /**
  64547. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64548. */
  64549. init(): void;
  64550. /**
  64551. * Called when the behavior is attached to a target
  64552. * @param target defines the target where the behavior is attached to
  64553. */
  64554. attach(target: T): void;
  64555. /**
  64556. * Called when the behavior is detached from its target
  64557. */
  64558. detach(): void;
  64559. }
  64560. /**
  64561. * Interface implemented by classes supporting behaviors
  64562. */
  64563. export interface IBehaviorAware<T> {
  64564. /**
  64565. * Attach a behavior
  64566. * @param behavior defines the behavior to attach
  64567. * @returns the current host
  64568. */
  64569. addBehavior(behavior: Behavior<T>): T;
  64570. /**
  64571. * Remove a behavior from the current object
  64572. * @param behavior defines the behavior to detach
  64573. * @returns the current host
  64574. */
  64575. removeBehavior(behavior: Behavior<T>): T;
  64576. /**
  64577. * Gets a behavior using its name to search
  64578. * @param name defines the name to search
  64579. * @returns the behavior or null if not found
  64580. */
  64581. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64582. }
  64583. }
  64584. declare module BABYLON {
  64585. /**
  64586. * @hidden
  64587. */
  64588. export class IntersectionInfo {
  64589. bu: Nullable<number>;
  64590. bv: Nullable<number>;
  64591. distance: number;
  64592. faceId: number;
  64593. subMeshId: number;
  64594. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64595. }
  64596. }
  64597. declare module BABYLON {
  64598. /**
  64599. * Class used to store bounding sphere information
  64600. */
  64601. export class BoundingSphere {
  64602. /**
  64603. * Gets the center of the bounding sphere in local space
  64604. */
  64605. readonly center: Vector3;
  64606. /**
  64607. * Radius of the bounding sphere in local space
  64608. */
  64609. radius: number;
  64610. /**
  64611. * Gets the center of the bounding sphere in world space
  64612. */
  64613. readonly centerWorld: Vector3;
  64614. /**
  64615. * Radius of the bounding sphere in world space
  64616. */
  64617. radiusWorld: number;
  64618. /**
  64619. * Gets the minimum vector in local space
  64620. */
  64621. readonly minimum: Vector3;
  64622. /**
  64623. * Gets the maximum vector in local space
  64624. */
  64625. readonly maximum: Vector3;
  64626. private _worldMatrix;
  64627. private static readonly TmpVector3;
  64628. /**
  64629. * Creates a new bounding sphere
  64630. * @param min defines the minimum vector (in local space)
  64631. * @param max defines the maximum vector (in local space)
  64632. * @param worldMatrix defines the new world matrix
  64633. */
  64634. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64635. /**
  64636. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64637. * @param min defines the new minimum vector (in local space)
  64638. * @param max defines the new maximum vector (in local space)
  64639. * @param worldMatrix defines the new world matrix
  64640. */
  64641. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64642. /**
  64643. * Scale the current bounding sphere by applying a scale factor
  64644. * @param factor defines the scale factor to apply
  64645. * @returns the current bounding box
  64646. */
  64647. scale(factor: number): BoundingSphere;
  64648. /**
  64649. * Gets the world matrix of the bounding box
  64650. * @returns a matrix
  64651. */
  64652. getWorldMatrix(): DeepImmutable<Matrix>;
  64653. /** @hidden */
  64654. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64655. /**
  64656. * Tests if the bounding sphere is intersecting the frustum planes
  64657. * @param frustumPlanes defines the frustum planes to test
  64658. * @returns true if there is an intersection
  64659. */
  64660. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64661. /**
  64662. * Tests if the bounding sphere center is in between the frustum planes.
  64663. * Used for optimistic fast inclusion.
  64664. * @param frustumPlanes defines the frustum planes to test
  64665. * @returns true if the sphere center is in between the frustum planes
  64666. */
  64667. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64668. /**
  64669. * Tests if a point is inside the bounding sphere
  64670. * @param point defines the point to test
  64671. * @returns true if the point is inside the bounding sphere
  64672. */
  64673. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64674. /**
  64675. * Checks if two sphere intersct
  64676. * @param sphere0 sphere 0
  64677. * @param sphere1 sphere 1
  64678. * @returns true if the speres intersect
  64679. */
  64680. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64681. }
  64682. }
  64683. declare module BABYLON {
  64684. /**
  64685. * Class used to store bounding box information
  64686. */
  64687. export class BoundingBox implements ICullable {
  64688. /**
  64689. * Gets the 8 vectors representing the bounding box in local space
  64690. */
  64691. readonly vectors: Vector3[];
  64692. /**
  64693. * Gets the center of the bounding box in local space
  64694. */
  64695. readonly center: Vector3;
  64696. /**
  64697. * Gets the center of the bounding box in world space
  64698. */
  64699. readonly centerWorld: Vector3;
  64700. /**
  64701. * Gets the extend size in local space
  64702. */
  64703. readonly extendSize: Vector3;
  64704. /**
  64705. * Gets the extend size in world space
  64706. */
  64707. readonly extendSizeWorld: Vector3;
  64708. /**
  64709. * Gets the OBB (object bounding box) directions
  64710. */
  64711. readonly directions: Vector3[];
  64712. /**
  64713. * Gets the 8 vectors representing the bounding box in world space
  64714. */
  64715. readonly vectorsWorld: Vector3[];
  64716. /**
  64717. * Gets the minimum vector in world space
  64718. */
  64719. readonly minimumWorld: Vector3;
  64720. /**
  64721. * Gets the maximum vector in world space
  64722. */
  64723. readonly maximumWorld: Vector3;
  64724. /**
  64725. * Gets the minimum vector in local space
  64726. */
  64727. readonly minimum: Vector3;
  64728. /**
  64729. * Gets the maximum vector in local space
  64730. */
  64731. readonly maximum: Vector3;
  64732. private _worldMatrix;
  64733. private static readonly TmpVector3;
  64734. /**
  64735. * @hidden
  64736. */
  64737. _tag: number;
  64738. /**
  64739. * Creates a new bounding box
  64740. * @param min defines the minimum vector (in local space)
  64741. * @param max defines the maximum vector (in local space)
  64742. * @param worldMatrix defines the new world matrix
  64743. */
  64744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64745. /**
  64746. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64747. * @param min defines the new minimum vector (in local space)
  64748. * @param max defines the new maximum vector (in local space)
  64749. * @param worldMatrix defines the new world matrix
  64750. */
  64751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64752. /**
  64753. * Scale the current bounding box by applying a scale factor
  64754. * @param factor defines the scale factor to apply
  64755. * @returns the current bounding box
  64756. */
  64757. scale(factor: number): BoundingBox;
  64758. /**
  64759. * Gets the world matrix of the bounding box
  64760. * @returns a matrix
  64761. */
  64762. getWorldMatrix(): DeepImmutable<Matrix>;
  64763. /** @hidden */
  64764. _update(world: DeepImmutable<Matrix>): void;
  64765. /**
  64766. * Tests if the bounding box is intersecting the frustum planes
  64767. * @param frustumPlanes defines the frustum planes to test
  64768. * @returns true if there is an intersection
  64769. */
  64770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64771. /**
  64772. * Tests if the bounding box is entirely inside the frustum planes
  64773. * @param frustumPlanes defines the frustum planes to test
  64774. * @returns true if there is an inclusion
  64775. */
  64776. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64777. /**
  64778. * Tests if a point is inside the bounding box
  64779. * @param point defines the point to test
  64780. * @returns true if the point is inside the bounding box
  64781. */
  64782. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64783. /**
  64784. * Tests if the bounding box intersects with a bounding sphere
  64785. * @param sphere defines the sphere to test
  64786. * @returns true if there is an intersection
  64787. */
  64788. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64789. /**
  64790. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64791. * @param min defines the min vector to use
  64792. * @param max defines the max vector to use
  64793. * @returns true if there is an intersection
  64794. */
  64795. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64796. /**
  64797. * Tests if two bounding boxes are intersections
  64798. * @param box0 defines the first box to test
  64799. * @param box1 defines the second box to test
  64800. * @returns true if there is an intersection
  64801. */
  64802. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64803. /**
  64804. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64805. * @param minPoint defines the minimum vector of the bounding box
  64806. * @param maxPoint defines the maximum vector of the bounding box
  64807. * @param sphereCenter defines the sphere center
  64808. * @param sphereRadius defines the sphere radius
  64809. * @returns true if there is an intersection
  64810. */
  64811. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64812. /**
  64813. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64814. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64815. * @param frustumPlanes defines the frustum planes to test
  64816. * @return true if there is an inclusion
  64817. */
  64818. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64819. /**
  64820. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64821. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64822. * @param frustumPlanes defines the frustum planes to test
  64823. * @return true if there is an intersection
  64824. */
  64825. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64826. }
  64827. }
  64828. declare module BABYLON {
  64829. /** @hidden */
  64830. export class Collider {
  64831. /** Define if a collision was found */
  64832. collisionFound: boolean;
  64833. /**
  64834. * Define last intersection point in local space
  64835. */
  64836. intersectionPoint: Vector3;
  64837. /**
  64838. * Define last collided mesh
  64839. */
  64840. collidedMesh: Nullable<AbstractMesh>;
  64841. private _collisionPoint;
  64842. private _planeIntersectionPoint;
  64843. private _tempVector;
  64844. private _tempVector2;
  64845. private _tempVector3;
  64846. private _tempVector4;
  64847. private _edge;
  64848. private _baseToVertex;
  64849. private _destinationPoint;
  64850. private _slidePlaneNormal;
  64851. private _displacementVector;
  64852. /** @hidden */
  64853. _radius: Vector3;
  64854. /** @hidden */
  64855. _retry: number;
  64856. private _velocity;
  64857. private _basePoint;
  64858. private _epsilon;
  64859. /** @hidden */
  64860. _velocityWorldLength: number;
  64861. /** @hidden */
  64862. _basePointWorld: Vector3;
  64863. private _velocityWorld;
  64864. private _normalizedVelocity;
  64865. /** @hidden */
  64866. _initialVelocity: Vector3;
  64867. /** @hidden */
  64868. _initialPosition: Vector3;
  64869. private _nearestDistance;
  64870. private _collisionMask;
  64871. collisionMask: number;
  64872. /**
  64873. * Gets the plane normal used to compute the sliding response (in local space)
  64874. */
  64875. readonly slidePlaneNormal: Vector3;
  64876. /** @hidden */
  64877. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64878. /** @hidden */
  64879. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64880. /** @hidden */
  64881. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64882. /** @hidden */
  64883. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64884. /** @hidden */
  64885. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64886. /** @hidden */
  64887. _getResponse(pos: Vector3, vel: Vector3): void;
  64888. }
  64889. }
  64890. declare module BABYLON {
  64891. /**
  64892. * Interface for cullable objects
  64893. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64894. */
  64895. export interface ICullable {
  64896. /**
  64897. * Checks if the object or part of the object is in the frustum
  64898. * @param frustumPlanes Camera near/planes
  64899. * @returns true if the object is in frustum otherwise false
  64900. */
  64901. isInFrustum(frustumPlanes: Plane[]): boolean;
  64902. /**
  64903. * Checks if a cullable object (mesh...) is in the camera frustum
  64904. * Unlike isInFrustum this cheks the full bounding box
  64905. * @param frustumPlanes Camera near/planes
  64906. * @returns true if the object is in frustum otherwise false
  64907. */
  64908. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64909. }
  64910. /**
  64911. * Info for a bounding data of a mesh
  64912. */
  64913. export class BoundingInfo implements ICullable {
  64914. /**
  64915. * Bounding box for the mesh
  64916. */
  64917. readonly boundingBox: BoundingBox;
  64918. /**
  64919. * Bounding sphere for the mesh
  64920. */
  64921. readonly boundingSphere: BoundingSphere;
  64922. private _isLocked;
  64923. private static readonly TmpVector3;
  64924. /**
  64925. * Constructs bounding info
  64926. * @param minimum min vector of the bounding box/sphere
  64927. * @param maximum max vector of the bounding box/sphere
  64928. * @param worldMatrix defines the new world matrix
  64929. */
  64930. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64931. /**
  64932. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64933. * @param min defines the new minimum vector (in local space)
  64934. * @param max defines the new maximum vector (in local space)
  64935. * @param worldMatrix defines the new world matrix
  64936. */
  64937. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64938. /**
  64939. * min vector of the bounding box/sphere
  64940. */
  64941. readonly minimum: Vector3;
  64942. /**
  64943. * max vector of the bounding box/sphere
  64944. */
  64945. readonly maximum: Vector3;
  64946. /**
  64947. * If the info is locked and won't be updated to avoid perf overhead
  64948. */
  64949. isLocked: boolean;
  64950. /**
  64951. * Updates the bounding sphere and box
  64952. * @param world world matrix to be used to update
  64953. */
  64954. update(world: DeepImmutable<Matrix>): void;
  64955. /**
  64956. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64957. * @param center New center of the bounding info
  64958. * @param extend New extend of the bounding info
  64959. * @returns the current bounding info
  64960. */
  64961. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64962. /**
  64963. * Scale the current bounding info by applying a scale factor
  64964. * @param factor defines the scale factor to apply
  64965. * @returns the current bounding info
  64966. */
  64967. scale(factor: number): BoundingInfo;
  64968. /**
  64969. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64970. * @param frustumPlanes defines the frustum to test
  64971. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64972. * @returns true if the bounding info is in the frustum planes
  64973. */
  64974. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64975. /**
  64976. * Gets the world distance between the min and max points of the bounding box
  64977. */
  64978. readonly diagonalLength: number;
  64979. /**
  64980. * Checks if a cullable object (mesh...) is in the camera frustum
  64981. * Unlike isInFrustum this cheks the full bounding box
  64982. * @param frustumPlanes Camera near/planes
  64983. * @returns true if the object is in frustum otherwise false
  64984. */
  64985. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64986. /** @hidden */
  64987. _checkCollision(collider: Collider): boolean;
  64988. /**
  64989. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64990. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64991. * @param point the point to check intersection with
  64992. * @returns if the point intersects
  64993. */
  64994. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64995. /**
  64996. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64997. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64998. * @param boundingInfo the bounding info to check intersection with
  64999. * @param precise if the intersection should be done using OBB
  65000. * @returns if the bounding info intersects
  65001. */
  65002. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65003. }
  65004. }
  65005. declare module BABYLON {
  65006. /**
  65007. * Defines an array and its length.
  65008. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65009. */
  65010. export interface ISmartArrayLike<T> {
  65011. /**
  65012. * The data of the array.
  65013. */
  65014. data: Array<T>;
  65015. /**
  65016. * The active length of the array.
  65017. */
  65018. length: number;
  65019. }
  65020. /**
  65021. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65022. */
  65023. export class SmartArray<T> implements ISmartArrayLike<T> {
  65024. /**
  65025. * The full set of data from the array.
  65026. */
  65027. data: Array<T>;
  65028. /**
  65029. * The active length of the array.
  65030. */
  65031. length: number;
  65032. protected _id: number;
  65033. /**
  65034. * Instantiates a Smart Array.
  65035. * @param capacity defines the default capacity of the array.
  65036. */
  65037. constructor(capacity: number);
  65038. /**
  65039. * Pushes a value at the end of the active data.
  65040. * @param value defines the object to push in the array.
  65041. */
  65042. push(value: T): void;
  65043. /**
  65044. * Iterates over the active data and apply the lambda to them.
  65045. * @param func defines the action to apply on each value.
  65046. */
  65047. forEach(func: (content: T) => void): void;
  65048. /**
  65049. * Sorts the full sets of data.
  65050. * @param compareFn defines the comparison function to apply.
  65051. */
  65052. sort(compareFn: (a: T, b: T) => number): void;
  65053. /**
  65054. * Resets the active data to an empty array.
  65055. */
  65056. reset(): void;
  65057. /**
  65058. * Releases all the data from the array as well as the array.
  65059. */
  65060. dispose(): void;
  65061. /**
  65062. * Concats the active data with a given array.
  65063. * @param array defines the data to concatenate with.
  65064. */
  65065. concat(array: any): void;
  65066. /**
  65067. * Returns the position of a value in the active data.
  65068. * @param value defines the value to find the index for
  65069. * @returns the index if found in the active data otherwise -1
  65070. */
  65071. indexOf(value: T): number;
  65072. /**
  65073. * Returns whether an element is part of the active data.
  65074. * @param value defines the value to look for
  65075. * @returns true if found in the active data otherwise false
  65076. */
  65077. contains(value: T): boolean;
  65078. private static _GlobalId;
  65079. }
  65080. /**
  65081. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65082. * The data in this array can only be present once
  65083. */
  65084. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65085. private _duplicateId;
  65086. /**
  65087. * Pushes a value at the end of the active data.
  65088. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65089. * @param value defines the object to push in the array.
  65090. */
  65091. push(value: T): void;
  65092. /**
  65093. * Pushes a value at the end of the active data.
  65094. * If the data is already present, it won t be added again
  65095. * @param value defines the object to push in the array.
  65096. * @returns true if added false if it was already present
  65097. */
  65098. pushNoDuplicate(value: T): boolean;
  65099. /**
  65100. * Resets the active data to an empty array.
  65101. */
  65102. reset(): void;
  65103. /**
  65104. * Concats the active data with a given array.
  65105. * This ensures no dupplicate will be present in the result.
  65106. * @param array defines the data to concatenate with.
  65107. */
  65108. concatWithNoDuplicate(array: any): void;
  65109. }
  65110. }
  65111. declare module BABYLON {
  65112. /**
  65113. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65114. * separate meshes. This can be use to improve performances.
  65115. * @see http://doc.babylonjs.com/how_to/multi_materials
  65116. */
  65117. export class MultiMaterial extends Material {
  65118. private _subMaterials;
  65119. /**
  65120. * Gets or Sets the list of Materials used within the multi material.
  65121. * They need to be ordered according to the submeshes order in the associated mesh
  65122. */
  65123. subMaterials: Nullable<Material>[];
  65124. /**
  65125. * Function used to align with Node.getChildren()
  65126. * @returns the list of Materials used within the multi material
  65127. */
  65128. getChildren(): Nullable<Material>[];
  65129. /**
  65130. * Instantiates a new Multi Material
  65131. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65132. * separate meshes. This can be use to improve performances.
  65133. * @see http://doc.babylonjs.com/how_to/multi_materials
  65134. * @param name Define the name in the scene
  65135. * @param scene Define the scene the material belongs to
  65136. */
  65137. constructor(name: string, scene: Scene);
  65138. private _hookArray;
  65139. /**
  65140. * Get one of the submaterial by its index in the submaterials array
  65141. * @param index The index to look the sub material at
  65142. * @returns The Material if the index has been defined
  65143. */
  65144. getSubMaterial(index: number): Nullable<Material>;
  65145. /**
  65146. * Get the list of active textures for the whole sub materials list.
  65147. * @returns All the textures that will be used during the rendering
  65148. */
  65149. getActiveTextures(): BaseTexture[];
  65150. /**
  65151. * Gets the current class name of the material e.g. "MultiMaterial"
  65152. * Mainly use in serialization.
  65153. * @returns the class name
  65154. */
  65155. getClassName(): string;
  65156. /**
  65157. * Checks if the material is ready to render the requested sub mesh
  65158. * @param mesh Define the mesh the submesh belongs to
  65159. * @param subMesh Define the sub mesh to look readyness for
  65160. * @param useInstances Define whether or not the material is used with instances
  65161. * @returns true if ready, otherwise false
  65162. */
  65163. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65164. /**
  65165. * Clones the current material and its related sub materials
  65166. * @param name Define the name of the newly cloned material
  65167. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65168. * @returns the cloned material
  65169. */
  65170. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65171. /**
  65172. * Serializes the materials into a JSON representation.
  65173. * @returns the JSON representation
  65174. */
  65175. serialize(): any;
  65176. /**
  65177. * Dispose the material and release its associated resources
  65178. * @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)
  65179. * @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)
  65180. * @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)
  65181. */
  65182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65183. /**
  65184. * Creates a MultiMaterial from parsed MultiMaterial data.
  65185. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65186. * @param scene defines the hosting scene
  65187. * @returns a new MultiMaterial
  65188. */
  65189. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65190. }
  65191. }
  65192. declare module BABYLON {
  65193. /**
  65194. * Class used to represent data loading progression
  65195. */
  65196. export class SceneLoaderFlags {
  65197. private static _ForceFullSceneLoadingForIncremental;
  65198. private static _ShowLoadingScreen;
  65199. private static _CleanBoneMatrixWeights;
  65200. private static _loggingLevel;
  65201. /**
  65202. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65203. */
  65204. static ForceFullSceneLoadingForIncremental: boolean;
  65205. /**
  65206. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65207. */
  65208. static ShowLoadingScreen: boolean;
  65209. /**
  65210. * Defines the current logging level (while loading the scene)
  65211. * @ignorenaming
  65212. */
  65213. static loggingLevel: number;
  65214. /**
  65215. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65216. */
  65217. static CleanBoneMatrixWeights: boolean;
  65218. }
  65219. }
  65220. declare module BABYLON {
  65221. /**
  65222. * 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.
  65223. * @see https://doc.babylonjs.com/how_to/transformnode
  65224. */
  65225. export class TransformNode extends Node {
  65226. /**
  65227. * Object will not rotate to face the camera
  65228. */
  65229. static BILLBOARDMODE_NONE: number;
  65230. /**
  65231. * Object will rotate to face the camera but only on the x axis
  65232. */
  65233. static BILLBOARDMODE_X: number;
  65234. /**
  65235. * Object will rotate to face the camera but only on the y axis
  65236. */
  65237. static BILLBOARDMODE_Y: number;
  65238. /**
  65239. * Object will rotate to face the camera but only on the z axis
  65240. */
  65241. static BILLBOARDMODE_Z: number;
  65242. /**
  65243. * Object will rotate to face the camera
  65244. */
  65245. static BILLBOARDMODE_ALL: number;
  65246. private _forward;
  65247. private _forwardInverted;
  65248. private _up;
  65249. private _right;
  65250. private _rightInverted;
  65251. private _position;
  65252. private _rotation;
  65253. private _rotationQuaternion;
  65254. protected _scaling: Vector3;
  65255. protected _isDirty: boolean;
  65256. private _transformToBoneReferal;
  65257. /**
  65258. * Set the billboard mode. Default is 0.
  65259. *
  65260. * | Value | Type | Description |
  65261. * | --- | --- | --- |
  65262. * | 0 | BILLBOARDMODE_NONE | |
  65263. * | 1 | BILLBOARDMODE_X | |
  65264. * | 2 | BILLBOARDMODE_Y | |
  65265. * | 4 | BILLBOARDMODE_Z | |
  65266. * | 7 | BILLBOARDMODE_ALL | |
  65267. *
  65268. */
  65269. billboardMode: number;
  65270. /**
  65271. * 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
  65272. */
  65273. scalingDeterminant: number;
  65274. /**
  65275. * Sets the distance of the object to max, often used by skybox
  65276. */
  65277. infiniteDistance: boolean;
  65278. /**
  65279. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65280. * By default the system will update normals to compensate
  65281. */
  65282. ignoreNonUniformScaling: boolean;
  65283. /** @hidden */
  65284. _poseMatrix: Matrix;
  65285. /** @hidden */
  65286. _localMatrix: Matrix;
  65287. private _absolutePosition;
  65288. private _pivotMatrix;
  65289. private _pivotMatrixInverse;
  65290. protected _postMultiplyPivotMatrix: boolean;
  65291. private _tempMatrix;
  65292. private _tempMatrix2;
  65293. protected _isWorldMatrixFrozen: boolean;
  65294. /** @hidden */
  65295. _indexInSceneTransformNodesArray: number;
  65296. /**
  65297. * An event triggered after the world matrix is updated
  65298. */
  65299. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65300. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65301. /**
  65302. * Gets a string identifying the name of the class
  65303. * @returns "TransformNode" string
  65304. */
  65305. getClassName(): string;
  65306. /**
  65307. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65308. */
  65309. position: Vector3;
  65310. /**
  65311. * 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)).
  65312. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65313. */
  65314. rotation: Vector3;
  65315. /**
  65316. * 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)).
  65317. */
  65318. scaling: Vector3;
  65319. /**
  65320. * 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).
  65321. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65322. */
  65323. rotationQuaternion: Nullable<Quaternion>;
  65324. /**
  65325. * The forward direction of that transform in world space.
  65326. */
  65327. readonly forward: Vector3;
  65328. /**
  65329. * The up direction of that transform in world space.
  65330. */
  65331. readonly up: Vector3;
  65332. /**
  65333. * The right direction of that transform in world space.
  65334. */
  65335. readonly right: Vector3;
  65336. /**
  65337. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65338. * @param matrix the matrix to copy the pose from
  65339. * @returns this TransformNode.
  65340. */
  65341. updatePoseMatrix(matrix: Matrix): TransformNode;
  65342. /**
  65343. * Returns the mesh Pose matrix.
  65344. * @returns the pose matrix
  65345. */
  65346. getPoseMatrix(): Matrix;
  65347. /** @hidden */
  65348. _isSynchronized(): boolean;
  65349. /** @hidden */
  65350. _initCache(): void;
  65351. /**
  65352. * Flag the transform node as dirty (Forcing it to update everything)
  65353. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65354. * @returns this transform node
  65355. */
  65356. markAsDirty(property: string): TransformNode;
  65357. /**
  65358. * Returns the current mesh absolute position.
  65359. * Returns a Vector3.
  65360. */
  65361. readonly absolutePosition: Vector3;
  65362. /**
  65363. * Sets a new matrix to apply before all other transformation
  65364. * @param matrix defines the transform matrix
  65365. * @returns the current TransformNode
  65366. */
  65367. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65368. /**
  65369. * Sets a new pivot matrix to the current node
  65370. * @param matrix defines the new pivot matrix to use
  65371. * @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
  65372. * @returns the current TransformNode
  65373. */
  65374. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65375. /**
  65376. * Returns the mesh pivot matrix.
  65377. * Default : Identity.
  65378. * @returns the matrix
  65379. */
  65380. getPivotMatrix(): Matrix;
  65381. /**
  65382. * Prevents the World matrix to be computed any longer.
  65383. * @returns the TransformNode.
  65384. */
  65385. freezeWorldMatrix(): TransformNode;
  65386. /**
  65387. * Allows back the World matrix computation.
  65388. * @returns the TransformNode.
  65389. */
  65390. unfreezeWorldMatrix(): this;
  65391. /**
  65392. * True if the World matrix has been frozen.
  65393. */
  65394. readonly isWorldMatrixFrozen: boolean;
  65395. /**
  65396. * Retuns the mesh absolute position in the World.
  65397. * @returns a Vector3.
  65398. */
  65399. getAbsolutePosition(): Vector3;
  65400. /**
  65401. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65402. * @param absolutePosition the absolute position to set
  65403. * @returns the TransformNode.
  65404. */
  65405. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65406. /**
  65407. * Sets the mesh position in its local space.
  65408. * @param vector3 the position to set in localspace
  65409. * @returns the TransformNode.
  65410. */
  65411. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65412. /**
  65413. * Returns the mesh position in the local space from the current World matrix values.
  65414. * @returns a new Vector3.
  65415. */
  65416. getPositionExpressedInLocalSpace(): Vector3;
  65417. /**
  65418. * Translates the mesh along the passed Vector3 in its local space.
  65419. * @param vector3 the distance to translate in localspace
  65420. * @returns the TransformNode.
  65421. */
  65422. locallyTranslate(vector3: Vector3): TransformNode;
  65423. private static _lookAtVectorCache;
  65424. /**
  65425. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65426. * @param targetPoint the position (must be in same space as current mesh) to look at
  65427. * @param yawCor optional yaw (y-axis) correction in radians
  65428. * @param pitchCor optional pitch (x-axis) correction in radians
  65429. * @param rollCor optional roll (z-axis) correction in radians
  65430. * @param space the choosen space of the target
  65431. * @returns the TransformNode.
  65432. */
  65433. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65434. /**
  65435. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65436. * This Vector3 is expressed in the World space.
  65437. * @param localAxis axis to rotate
  65438. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65439. */
  65440. getDirection(localAxis: Vector3): Vector3;
  65441. /**
  65442. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65443. * localAxis is expressed in the mesh local space.
  65444. * result is computed in the Wordl space from the mesh World matrix.
  65445. * @param localAxis axis to rotate
  65446. * @param result the resulting transformnode
  65447. * @returns this TransformNode.
  65448. */
  65449. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65450. /**
  65451. * Sets this transform node rotation to the given local axis.
  65452. * @param localAxis the axis in local space
  65453. * @param yawCor optional yaw (y-axis) correction in radians
  65454. * @param pitchCor optional pitch (x-axis) correction in radians
  65455. * @param rollCor optional roll (z-axis) correction in radians
  65456. * @returns this TransformNode
  65457. */
  65458. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65459. /**
  65460. * Sets a new pivot point to the current node
  65461. * @param point defines the new pivot point to use
  65462. * @param space defines if the point is in world or local space (local by default)
  65463. * @returns the current TransformNode
  65464. */
  65465. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65466. /**
  65467. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65468. * @returns the pivot point
  65469. */
  65470. getPivotPoint(): Vector3;
  65471. /**
  65472. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65473. * @param result the vector3 to store the result
  65474. * @returns this TransformNode.
  65475. */
  65476. getPivotPointToRef(result: Vector3): TransformNode;
  65477. /**
  65478. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65479. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65480. */
  65481. getAbsolutePivotPoint(): Vector3;
  65482. /**
  65483. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65484. * @param result vector3 to store the result
  65485. * @returns this TransformNode.
  65486. */
  65487. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65488. /**
  65489. * Defines the passed node as the parent of the current node.
  65490. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65491. * @param node the node ot set as the parent
  65492. * @returns this TransformNode.
  65493. */
  65494. setParent(node: Nullable<Node>): TransformNode;
  65495. private _nonUniformScaling;
  65496. /**
  65497. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65498. */
  65499. readonly nonUniformScaling: boolean;
  65500. /** @hidden */
  65501. _updateNonUniformScalingState(value: boolean): boolean;
  65502. /**
  65503. * Attach the current TransformNode to another TransformNode associated with a bone
  65504. * @param bone Bone affecting the TransformNode
  65505. * @param affectedTransformNode TransformNode associated with the bone
  65506. * @returns this object
  65507. */
  65508. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65509. /**
  65510. * Detach the transform node if its associated with a bone
  65511. * @returns this object
  65512. */
  65513. detachFromBone(): TransformNode;
  65514. private static _rotationAxisCache;
  65515. /**
  65516. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65517. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65518. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65519. * The passed axis is also normalized.
  65520. * @param axis the axis to rotate around
  65521. * @param amount the amount to rotate in radians
  65522. * @param space Space to rotate in (Default: local)
  65523. * @returns the TransformNode.
  65524. */
  65525. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65526. /**
  65527. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65528. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65529. * The passed axis is also normalized. .
  65530. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65531. * @param point the point to rotate around
  65532. * @param axis the axis to rotate around
  65533. * @param amount the amount to rotate in radians
  65534. * @returns the TransformNode
  65535. */
  65536. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65537. /**
  65538. * Translates the mesh along the axis vector for the passed distance in the given space.
  65539. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65540. * @param axis the axis to translate in
  65541. * @param distance the distance to translate
  65542. * @param space Space to rotate in (Default: local)
  65543. * @returns the TransformNode.
  65544. */
  65545. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65546. /**
  65547. * Adds a rotation step to the mesh current rotation.
  65548. * x, y, z are Euler angles expressed in radians.
  65549. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65550. * This means this rotation is made in the mesh local space only.
  65551. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65552. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65553. * ```javascript
  65554. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65555. * ```
  65556. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65557. * 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.
  65558. * @param x Rotation to add
  65559. * @param y Rotation to add
  65560. * @param z Rotation to add
  65561. * @returns the TransformNode.
  65562. */
  65563. addRotation(x: number, y: number, z: number): TransformNode;
  65564. /**
  65565. * Computes the world matrix of the node
  65566. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65567. * @returns the world matrix
  65568. */
  65569. computeWorldMatrix(force?: boolean): Matrix;
  65570. protected _afterComputeWorldMatrix(): void;
  65571. /**
  65572. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65573. * @param func callback function to add
  65574. *
  65575. * @returns the TransformNode.
  65576. */
  65577. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65578. /**
  65579. * Removes a registered callback function.
  65580. * @param func callback function to remove
  65581. * @returns the TransformNode.
  65582. */
  65583. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65584. /**
  65585. * Gets the position of the current mesh in camera space
  65586. * @param camera defines the camera to use
  65587. * @returns a position
  65588. */
  65589. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65590. /**
  65591. * Returns the distance from the mesh to the active camera
  65592. * @param camera defines the camera to use
  65593. * @returns the distance
  65594. */
  65595. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65596. /**
  65597. * Clone the current transform node
  65598. * @param name Name of the new clone
  65599. * @param newParent New parent for the clone
  65600. * @param doNotCloneChildren Do not clone children hierarchy
  65601. * @returns the new transform node
  65602. */
  65603. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65604. /**
  65605. * Serializes the objects information.
  65606. * @param currentSerializationObject defines the object to serialize in
  65607. * @returns the serialized object
  65608. */
  65609. serialize(currentSerializationObject?: any): any;
  65610. /**
  65611. * Returns a new TransformNode object parsed from the source provided.
  65612. * @param parsedTransformNode is the source.
  65613. * @param scene the scne the object belongs to
  65614. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65615. * @returns a new TransformNode object parsed from the source provided.
  65616. */
  65617. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65618. /**
  65619. * Get all child-transformNodes of this node
  65620. * @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
  65621. * @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
  65622. * @returns an array of TransformNode
  65623. */
  65624. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65625. /**
  65626. * Releases resources associated with this transform node.
  65627. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65628. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65629. */
  65630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65631. }
  65632. }
  65633. declare module BABYLON {
  65634. /**
  65635. * Class used to override all child animations of a given target
  65636. */
  65637. export class AnimationPropertiesOverride {
  65638. /**
  65639. * Gets or sets a value indicating if animation blending must be used
  65640. */
  65641. enableBlending: boolean;
  65642. /**
  65643. * Gets or sets the blending speed to use when enableBlending is true
  65644. */
  65645. blendingSpeed: number;
  65646. /**
  65647. * Gets or sets the default loop mode to use
  65648. */
  65649. loopMode: number;
  65650. }
  65651. }
  65652. declare module BABYLON {
  65653. /**
  65654. * Class used to store bone information
  65655. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65656. */
  65657. export class Bone extends Node {
  65658. /**
  65659. * defines the bone name
  65660. */
  65661. name: string;
  65662. private static _tmpVecs;
  65663. private static _tmpQuat;
  65664. private static _tmpMats;
  65665. /**
  65666. * Gets the list of child bones
  65667. */
  65668. children: Bone[];
  65669. /** Gets the animations associated with this bone */
  65670. animations: Animation[];
  65671. /**
  65672. * Gets or sets bone length
  65673. */
  65674. length: number;
  65675. /**
  65676. * @hidden Internal only
  65677. * Set this value to map this bone to a different index in the transform matrices
  65678. * Set this value to -1 to exclude the bone from the transform matrices
  65679. */
  65680. _index: Nullable<number>;
  65681. private _skeleton;
  65682. private _localMatrix;
  65683. private _restPose;
  65684. private _baseMatrix;
  65685. private _absoluteTransform;
  65686. private _invertedAbsoluteTransform;
  65687. private _parent;
  65688. private _scalingDeterminant;
  65689. private _worldTransform;
  65690. private _localScaling;
  65691. private _localRotation;
  65692. private _localPosition;
  65693. private _needToDecompose;
  65694. private _needToCompose;
  65695. /** @hidden */
  65696. _linkedTransformNode: Nullable<TransformNode>;
  65697. /** @hidden */
  65698. /** @hidden */
  65699. _matrix: Matrix;
  65700. /**
  65701. * Create a new bone
  65702. * @param name defines the bone name
  65703. * @param skeleton defines the parent skeleton
  65704. * @param parentBone defines the parent (can be null if the bone is the root)
  65705. * @param localMatrix defines the local matrix
  65706. * @param restPose defines the rest pose matrix
  65707. * @param baseMatrix defines the base matrix
  65708. * @param index defines index of the bone in the hiearchy
  65709. */
  65710. constructor(
  65711. /**
  65712. * defines the bone name
  65713. */
  65714. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65715. /**
  65716. * Gets the current object class name.
  65717. * @return the class name
  65718. */
  65719. getClassName(): string;
  65720. /**
  65721. * Gets the parent skeleton
  65722. * @returns a skeleton
  65723. */
  65724. getSkeleton(): Skeleton;
  65725. /**
  65726. * Gets parent bone
  65727. * @returns a bone or null if the bone is the root of the bone hierarchy
  65728. */
  65729. getParent(): Nullable<Bone>;
  65730. /**
  65731. * Returns an array containing the root bones
  65732. * @returns an array containing the root bones
  65733. */
  65734. getChildren(): Array<Bone>;
  65735. /**
  65736. * Sets the parent bone
  65737. * @param parent defines the parent (can be null if the bone is the root)
  65738. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65739. */
  65740. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65741. /**
  65742. * Gets the local matrix
  65743. * @returns a matrix
  65744. */
  65745. getLocalMatrix(): Matrix;
  65746. /**
  65747. * Gets the base matrix (initial matrix which remains unchanged)
  65748. * @returns a matrix
  65749. */
  65750. getBaseMatrix(): Matrix;
  65751. /**
  65752. * Gets the rest pose matrix
  65753. * @returns a matrix
  65754. */
  65755. getRestPose(): Matrix;
  65756. /**
  65757. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65758. */
  65759. getWorldMatrix(): Matrix;
  65760. /**
  65761. * Sets the local matrix to rest pose matrix
  65762. */
  65763. returnToRest(): void;
  65764. /**
  65765. * Gets the inverse of the absolute transform matrix.
  65766. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65767. * @returns a matrix
  65768. */
  65769. getInvertedAbsoluteTransform(): Matrix;
  65770. /**
  65771. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65772. * @returns a matrix
  65773. */
  65774. getAbsoluteTransform(): Matrix;
  65775. /**
  65776. * Links with the given transform node.
  65777. * The local matrix of this bone is copied from the transform node every frame.
  65778. * @param transformNode defines the transform node to link to
  65779. */
  65780. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65781. /** Gets or sets current position (in local space) */
  65782. position: Vector3;
  65783. /** Gets or sets current rotation (in local space) */
  65784. rotation: Vector3;
  65785. /** Gets or sets current rotation quaternion (in local space) */
  65786. rotationQuaternion: Quaternion;
  65787. /** Gets or sets current scaling (in local space) */
  65788. scaling: Vector3;
  65789. /**
  65790. * Gets the animation properties override
  65791. */
  65792. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65793. private _decompose;
  65794. private _compose;
  65795. /**
  65796. * Update the base and local matrices
  65797. * @param matrix defines the new base or local matrix
  65798. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65799. * @param updateLocalMatrix defines if the local matrix should be updated
  65800. */
  65801. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65802. /** @hidden */
  65803. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65804. /**
  65805. * Flag the bone as dirty (Forcing it to update everything)
  65806. */
  65807. markAsDirty(): void;
  65808. private _markAsDirtyAndCompose;
  65809. private _markAsDirtyAndDecompose;
  65810. /**
  65811. * Translate the bone in local or world space
  65812. * @param vec The amount to translate the bone
  65813. * @param space The space that the translation is in
  65814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65815. */
  65816. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65817. /**
  65818. * Set the postion of the bone in local or world space
  65819. * @param position The position to set the bone
  65820. * @param space The space that the position is in
  65821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65822. */
  65823. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65824. /**
  65825. * Set the absolute position of the bone (world space)
  65826. * @param position The position to set the bone
  65827. * @param mesh The mesh that this bone is attached to
  65828. */
  65829. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65830. /**
  65831. * Scale the bone on the x, y and z axes (in local space)
  65832. * @param x The amount to scale the bone on the x axis
  65833. * @param y The amount to scale the bone on the y axis
  65834. * @param z The amount to scale the bone on the z axis
  65835. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65836. */
  65837. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65838. /**
  65839. * Set the bone scaling in local space
  65840. * @param scale defines the scaling vector
  65841. */
  65842. setScale(scale: Vector3): void;
  65843. /**
  65844. * Gets the current scaling in local space
  65845. * @returns the current scaling vector
  65846. */
  65847. getScale(): Vector3;
  65848. /**
  65849. * Gets the current scaling in local space and stores it in a target vector
  65850. * @param result defines the target vector
  65851. */
  65852. getScaleToRef(result: Vector3): void;
  65853. /**
  65854. * Set the yaw, pitch, and roll of the bone in local or world space
  65855. * @param yaw The rotation of the bone on the y axis
  65856. * @param pitch The rotation of the bone on the x axis
  65857. * @param roll The rotation of the bone on the z axis
  65858. * @param space The space that the axes of rotation are in
  65859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65860. */
  65861. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65862. /**
  65863. * Add a rotation to the bone on an axis in local or world space
  65864. * @param axis The axis to rotate the bone on
  65865. * @param amount The amount to rotate the bone
  65866. * @param space The space that the axis is in
  65867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65868. */
  65869. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65870. /**
  65871. * Set the rotation of the bone to a particular axis angle in local or world space
  65872. * @param axis The axis to rotate the bone on
  65873. * @param angle The angle that the bone should be rotated to
  65874. * @param space The space that the axis is in
  65875. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65876. */
  65877. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65878. /**
  65879. * Set the euler rotation of the bone in local of world space
  65880. * @param rotation The euler rotation that the bone should be set to
  65881. * @param space The space that the rotation is in
  65882. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65883. */
  65884. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65885. /**
  65886. * Set the quaternion rotation of the bone in local of world space
  65887. * @param quat The quaternion rotation that the bone should be set to
  65888. * @param space The space that the rotation is in
  65889. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65890. */
  65891. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65892. /**
  65893. * Set the rotation matrix of the bone in local of world space
  65894. * @param rotMat The rotation matrix that the bone should be set to
  65895. * @param space The space that the rotation is in
  65896. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65897. */
  65898. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65899. private _rotateWithMatrix;
  65900. private _getNegativeRotationToRef;
  65901. /**
  65902. * Get the position of the bone in local or world space
  65903. * @param space The space that the returned position is in
  65904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65905. * @returns The position of the bone
  65906. */
  65907. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65908. /**
  65909. * Copy the position of the bone to a vector3 in local or world space
  65910. * @param space The space that the returned position is in
  65911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65912. * @param result The vector3 to copy the position to
  65913. */
  65914. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65915. /**
  65916. * Get the absolute position of the bone (world space)
  65917. * @param mesh The mesh that this bone is attached to
  65918. * @returns The absolute position of the bone
  65919. */
  65920. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65921. /**
  65922. * Copy the absolute position of the bone (world space) to the result param
  65923. * @param mesh The mesh that this bone is attached to
  65924. * @param result The vector3 to copy the absolute position to
  65925. */
  65926. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65927. /**
  65928. * Compute the absolute transforms of this bone and its children
  65929. */
  65930. computeAbsoluteTransforms(): void;
  65931. /**
  65932. * Get the world direction from an axis that is in the local space of the bone
  65933. * @param localAxis The local direction that is used to compute the world direction
  65934. * @param mesh The mesh that this bone is attached to
  65935. * @returns The world direction
  65936. */
  65937. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65938. /**
  65939. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65940. * @param localAxis The local direction that is used to compute the world direction
  65941. * @param mesh The mesh that this bone is attached to
  65942. * @param result The vector3 that the world direction will be copied to
  65943. */
  65944. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65945. /**
  65946. * Get the euler rotation of the bone in local or world space
  65947. * @param space The space that the rotation should be in
  65948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65949. * @returns The euler rotation
  65950. */
  65951. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65952. /**
  65953. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65954. * @param space The space that the rotation should be in
  65955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65956. * @param result The vector3 that the rotation should be copied to
  65957. */
  65958. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65959. /**
  65960. * Get the quaternion rotation of the bone in either local or world space
  65961. * @param space The space that the rotation should be in
  65962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65963. * @returns The quaternion rotation
  65964. */
  65965. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65966. /**
  65967. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65968. * @param space The space that the rotation should be in
  65969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65970. * @param result The quaternion that the rotation should be copied to
  65971. */
  65972. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65973. /**
  65974. * Get the rotation matrix of the bone in local or world space
  65975. * @param space The space that the rotation should be in
  65976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65977. * @returns The rotation matrix
  65978. */
  65979. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65980. /**
  65981. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65982. * @param space The space that the rotation should be in
  65983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65984. * @param result The quaternion that the rotation should be copied to
  65985. */
  65986. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65987. /**
  65988. * Get the world position of a point that is in the local space of the bone
  65989. * @param position The local position
  65990. * @param mesh The mesh that this bone is attached to
  65991. * @returns The world position
  65992. */
  65993. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65994. /**
  65995. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65996. * @param position The local position
  65997. * @param mesh The mesh that this bone is attached to
  65998. * @param result The vector3 that the world position should be copied to
  65999. */
  66000. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66001. /**
  66002. * Get the local position of a point that is in world space
  66003. * @param position The world position
  66004. * @param mesh The mesh that this bone is attached to
  66005. * @returns The local position
  66006. */
  66007. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66008. /**
  66009. * Get the local position of a point that is in world space and copy it to the result param
  66010. * @param position The world position
  66011. * @param mesh The mesh that this bone is attached to
  66012. * @param result The vector3 that the local position should be copied to
  66013. */
  66014. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66015. }
  66016. }
  66017. declare module BABYLON {
  66018. /**
  66019. * Class for creating a cube texture
  66020. */
  66021. export class CubeTexture extends BaseTexture {
  66022. private _delayedOnLoad;
  66023. /**
  66024. * The url of the texture
  66025. */
  66026. url: string;
  66027. /**
  66028. * Gets or sets the center of the bounding box associated with the cube texture.
  66029. * It must define where the camera used to render the texture was set
  66030. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66031. */
  66032. boundingBoxPosition: Vector3;
  66033. private _boundingBoxSize;
  66034. /**
  66035. * Gets or sets the size of the bounding box associated with the cube texture
  66036. * When defined, the cubemap will switch to local mode
  66037. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66038. * @example https://www.babylonjs-playground.com/#RNASML
  66039. */
  66040. /**
  66041. * Returns the bounding box size
  66042. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66043. */
  66044. boundingBoxSize: Vector3;
  66045. protected _rotationY: number;
  66046. /**
  66047. * Sets texture matrix rotation angle around Y axis in radians.
  66048. */
  66049. /**
  66050. * Gets texture matrix rotation angle around Y axis radians.
  66051. */
  66052. rotationY: number;
  66053. /**
  66054. * Are mip maps generated for this texture or not.
  66055. */
  66056. readonly noMipmap: boolean;
  66057. private _noMipmap;
  66058. private _files;
  66059. private _extensions;
  66060. private _textureMatrix;
  66061. private _format;
  66062. private _createPolynomials;
  66063. /** @hidden */
  66064. _prefiltered: boolean;
  66065. /**
  66066. * Creates a cube texture from an array of image urls
  66067. * @param files defines an array of image urls
  66068. * @param scene defines the hosting scene
  66069. * @param noMipmap specifies if mip maps are not used
  66070. * @returns a cube texture
  66071. */
  66072. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66073. /**
  66074. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66075. * @param url defines the url of the prefiltered texture
  66076. * @param scene defines the scene the texture is attached to
  66077. * @param forcedExtension defines the extension of the file if different from the url
  66078. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66079. * @return the prefiltered texture
  66080. */
  66081. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66082. /**
  66083. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66084. * as prefiltered data.
  66085. * @param rootUrl defines the url of the texture or the root name of the six images
  66086. * @param scene defines the scene the texture is attached to
  66087. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66088. * @param noMipmap defines if mipmaps should be created or not
  66089. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66090. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66091. * @param onError defines a callback triggered in case of error during load
  66092. * @param format defines the internal format to use for the texture once loaded
  66093. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66094. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66095. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66096. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66097. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66098. * @return the cube texture
  66099. */
  66100. 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);
  66101. /**
  66102. * Get the current class name of the texture useful for serialization or dynamic coding.
  66103. * @returns "CubeTexture"
  66104. */
  66105. getClassName(): string;
  66106. /**
  66107. * Update the url (and optional buffer) of this texture if url was null during construction.
  66108. * @param url the url of the texture
  66109. * @param forcedExtension defines the extension to use
  66110. * @param onLoad callback called when the texture is loaded (defaults to null)
  66111. */
  66112. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66113. /**
  66114. * Delays loading of the cube texture
  66115. * @param forcedExtension defines the extension to use
  66116. */
  66117. delayLoad(forcedExtension?: string): void;
  66118. /**
  66119. * Returns the reflection texture matrix
  66120. * @returns the reflection texture matrix
  66121. */
  66122. getReflectionTextureMatrix(): Matrix;
  66123. /**
  66124. * Sets the reflection texture matrix
  66125. * @param value Reflection texture matrix
  66126. */
  66127. setReflectionTextureMatrix(value: Matrix): void;
  66128. /**
  66129. * Parses text to create a cube texture
  66130. * @param parsedTexture define the serialized text to read from
  66131. * @param scene defines the hosting scene
  66132. * @param rootUrl defines the root url of the cube texture
  66133. * @returns a cube texture
  66134. */
  66135. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66136. /**
  66137. * Makes a clone, or deep copy, of the cube texture
  66138. * @returns a new cube texture
  66139. */
  66140. clone(): CubeTexture;
  66141. }
  66142. }
  66143. declare module BABYLON {
  66144. /** @hidden */
  66145. export var postprocessVertexShader: {
  66146. name: string;
  66147. shader: string;
  66148. };
  66149. }
  66150. declare module BABYLON {
  66151. /**
  66152. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66153. * This is the base of the follow, arc rotate cameras and Free camera
  66154. * @see http://doc.babylonjs.com/features/cameras
  66155. */
  66156. export class TargetCamera extends Camera {
  66157. private static _RigCamTransformMatrix;
  66158. private static _TargetTransformMatrix;
  66159. private static _TargetFocalPoint;
  66160. /**
  66161. * Define the current direction the camera is moving to
  66162. */
  66163. cameraDirection: Vector3;
  66164. /**
  66165. * Define the current rotation the camera is rotating to
  66166. */
  66167. cameraRotation: Vector2;
  66168. /**
  66169. * When set, the up vector of the camera will be updated by the rotation of the camera
  66170. */
  66171. updateUpVectorFromRotation: boolean;
  66172. private _tmpQuaternion;
  66173. /**
  66174. * Define the current rotation of the camera
  66175. */
  66176. rotation: Vector3;
  66177. /**
  66178. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66179. */
  66180. rotationQuaternion: Quaternion;
  66181. /**
  66182. * Define the current speed of the camera
  66183. */
  66184. speed: number;
  66185. /**
  66186. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66187. * around all axis.
  66188. */
  66189. noRotationConstraint: boolean;
  66190. /**
  66191. * Define the current target of the camera as an object or a position.
  66192. */
  66193. lockedTarget: any;
  66194. /** @hidden */
  66195. _currentTarget: Vector3;
  66196. /** @hidden */
  66197. _initialFocalDistance: number;
  66198. /** @hidden */
  66199. _viewMatrix: Matrix;
  66200. /** @hidden */
  66201. _camMatrix: Matrix;
  66202. /** @hidden */
  66203. _cameraTransformMatrix: Matrix;
  66204. /** @hidden */
  66205. _cameraRotationMatrix: Matrix;
  66206. /** @hidden */
  66207. _referencePoint: Vector3;
  66208. /** @hidden */
  66209. _transformedReferencePoint: Vector3;
  66210. protected _globalCurrentTarget: Vector3;
  66211. protected _globalCurrentUpVector: Vector3;
  66212. /** @hidden */
  66213. _reset: () => void;
  66214. private _defaultUp;
  66215. /**
  66216. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66217. * This is the base of the follow, arc rotate cameras and Free camera
  66218. * @see http://doc.babylonjs.com/features/cameras
  66219. * @param name Defines the name of the camera in the scene
  66220. * @param position Defines the start position of the camera in the scene
  66221. * @param scene Defines the scene the camera belongs to
  66222. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66223. */
  66224. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66225. /**
  66226. * Gets the position in front of the camera at a given distance.
  66227. * @param distance The distance from the camera we want the position to be
  66228. * @returns the position
  66229. */
  66230. getFrontPosition(distance: number): Vector3;
  66231. /** @hidden */
  66232. _getLockedTargetPosition(): Nullable<Vector3>;
  66233. private _storedPosition;
  66234. private _storedRotation;
  66235. private _storedRotationQuaternion;
  66236. /**
  66237. * Store current camera state of the camera (fov, position, rotation, etc..)
  66238. * @returns the camera
  66239. */
  66240. storeState(): Camera;
  66241. /**
  66242. * Restored camera state. You must call storeState() first
  66243. * @returns whether it was successful or not
  66244. * @hidden
  66245. */
  66246. _restoreStateValues(): boolean;
  66247. /** @hidden */
  66248. _initCache(): void;
  66249. /** @hidden */
  66250. _updateCache(ignoreParentClass?: boolean): void;
  66251. /** @hidden */
  66252. _isSynchronizedViewMatrix(): boolean;
  66253. /** @hidden */
  66254. _computeLocalCameraSpeed(): number;
  66255. /**
  66256. * Defines the target the camera should look at.
  66257. * This will automatically adapt alpha beta and radius to fit within the new target.
  66258. * @param target Defines the new target as a Vector or a mesh
  66259. */
  66260. setTarget(target: Vector3): void;
  66261. /**
  66262. * Return the current target position of the camera. This value is expressed in local space.
  66263. * @returns the target position
  66264. */
  66265. getTarget(): Vector3;
  66266. /** @hidden */
  66267. _decideIfNeedsToMove(): boolean;
  66268. /** @hidden */
  66269. _updatePosition(): void;
  66270. /** @hidden */
  66271. _checkInputs(): void;
  66272. protected _updateCameraRotationMatrix(): void;
  66273. /**
  66274. * 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)
  66275. * @returns the current camera
  66276. */
  66277. private _rotateUpVectorWithCameraRotationMatrix;
  66278. private _cachedRotationZ;
  66279. private _cachedQuaternionRotationZ;
  66280. /** @hidden */
  66281. _getViewMatrix(): Matrix;
  66282. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66283. /**
  66284. * @hidden
  66285. */
  66286. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66287. /**
  66288. * @hidden
  66289. */
  66290. _updateRigCameras(): void;
  66291. private _getRigCamPositionAndTarget;
  66292. /**
  66293. * Gets the current object class name.
  66294. * @return the class name
  66295. */
  66296. getClassName(): string;
  66297. }
  66298. }
  66299. declare module BABYLON {
  66300. /**
  66301. * @ignore
  66302. * This is a list of all the different input types that are available in the application.
  66303. * Fo instance: ArcRotateCameraGamepadInput...
  66304. */
  66305. export var CameraInputTypes: {};
  66306. /**
  66307. * This is the contract to implement in order to create a new input class.
  66308. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66309. */
  66310. export interface ICameraInput<TCamera extends Camera> {
  66311. /**
  66312. * Defines the camera the input is attached to.
  66313. */
  66314. camera: Nullable<TCamera>;
  66315. /**
  66316. * Gets the class name of the current intput.
  66317. * @returns the class name
  66318. */
  66319. getClassName(): string;
  66320. /**
  66321. * Get the friendly name associated with the input class.
  66322. * @returns the input friendly name
  66323. */
  66324. getSimpleName(): string;
  66325. /**
  66326. * Attach the input controls to a specific dom element to get the input from.
  66327. * @param element Defines the element the controls should be listened from
  66328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66329. */
  66330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66331. /**
  66332. * Detach the current controls from the specified dom element.
  66333. * @param element Defines the element to stop listening the inputs from
  66334. */
  66335. detachControl(element: Nullable<HTMLElement>): void;
  66336. /**
  66337. * Update the current camera state depending on the inputs that have been used this frame.
  66338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66339. */
  66340. checkInputs?: () => void;
  66341. }
  66342. /**
  66343. * Represents a map of input types to input instance or input index to input instance.
  66344. */
  66345. export interface CameraInputsMap<TCamera extends Camera> {
  66346. /**
  66347. * Accessor to the input by input type.
  66348. */
  66349. [name: string]: ICameraInput<TCamera>;
  66350. /**
  66351. * Accessor to the input by input index.
  66352. */
  66353. [idx: number]: ICameraInput<TCamera>;
  66354. }
  66355. /**
  66356. * This represents the input manager used within a camera.
  66357. * It helps dealing with all the different kind of input attached to a camera.
  66358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66359. */
  66360. export class CameraInputsManager<TCamera extends Camera> {
  66361. /**
  66362. * Defines the list of inputs attahed to the camera.
  66363. */
  66364. attached: CameraInputsMap<TCamera>;
  66365. /**
  66366. * Defines the dom element the camera is collecting inputs from.
  66367. * This is null if the controls have not been attached.
  66368. */
  66369. attachedElement: Nullable<HTMLElement>;
  66370. /**
  66371. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66372. */
  66373. noPreventDefault: boolean;
  66374. /**
  66375. * Defined the camera the input manager belongs to.
  66376. */
  66377. camera: TCamera;
  66378. /**
  66379. * Update the current camera state depending on the inputs that have been used this frame.
  66380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66381. */
  66382. checkInputs: () => void;
  66383. /**
  66384. * Instantiate a new Camera Input Manager.
  66385. * @param camera Defines the camera the input manager blongs to
  66386. */
  66387. constructor(camera: TCamera);
  66388. /**
  66389. * Add an input method to a camera
  66390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66391. * @param input camera input method
  66392. */
  66393. add(input: ICameraInput<TCamera>): void;
  66394. /**
  66395. * Remove a specific input method from a camera
  66396. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66397. * @param inputToRemove camera input method
  66398. */
  66399. remove(inputToRemove: ICameraInput<TCamera>): void;
  66400. /**
  66401. * Remove a specific input type from a camera
  66402. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66403. * @param inputType the type of the input to remove
  66404. */
  66405. removeByType(inputType: string): void;
  66406. private _addCheckInputs;
  66407. /**
  66408. * Attach the input controls to the currently attached dom element to listen the events from.
  66409. * @param input Defines the input to attach
  66410. */
  66411. attachInput(input: ICameraInput<TCamera>): void;
  66412. /**
  66413. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66414. * @param element Defines the dom element to collect the events from
  66415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66416. */
  66417. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66418. /**
  66419. * Detach the current manager inputs controls from a specific dom element.
  66420. * @param element Defines the dom element to collect the events from
  66421. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66422. */
  66423. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66424. /**
  66425. * Rebuild the dynamic inputCheck function from the current list of
  66426. * defined inputs in the manager.
  66427. */
  66428. rebuildInputCheck(): void;
  66429. /**
  66430. * Remove all attached input methods from a camera
  66431. */
  66432. clear(): void;
  66433. /**
  66434. * Serialize the current input manager attached to a camera.
  66435. * This ensures than once parsed,
  66436. * the input associated to the camera will be identical to the current ones
  66437. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66438. */
  66439. serialize(serializedCamera: any): void;
  66440. /**
  66441. * Parses an input manager serialized JSON to restore the previous list of inputs
  66442. * and states associated to a camera.
  66443. * @param parsedCamera Defines the JSON to parse
  66444. */
  66445. parse(parsedCamera: any): void;
  66446. }
  66447. }
  66448. declare module BABYLON {
  66449. /**
  66450. * Gather the list of keyboard event types as constants.
  66451. */
  66452. export class KeyboardEventTypes {
  66453. /**
  66454. * The keydown event is fired when a key becomes active (pressed).
  66455. */
  66456. static readonly KEYDOWN: number;
  66457. /**
  66458. * The keyup event is fired when a key has been released.
  66459. */
  66460. static readonly KEYUP: number;
  66461. }
  66462. /**
  66463. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66464. */
  66465. export class KeyboardInfo {
  66466. /**
  66467. * Defines the type of event (KeyboardEventTypes)
  66468. */
  66469. type: number;
  66470. /**
  66471. * Defines the related dom event
  66472. */
  66473. event: KeyboardEvent;
  66474. /**
  66475. * Instantiates a new keyboard info.
  66476. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66477. * @param type Defines the type of event (KeyboardEventTypes)
  66478. * @param event Defines the related dom event
  66479. */
  66480. constructor(
  66481. /**
  66482. * Defines the type of event (KeyboardEventTypes)
  66483. */
  66484. type: number,
  66485. /**
  66486. * Defines the related dom event
  66487. */
  66488. event: KeyboardEvent);
  66489. }
  66490. /**
  66491. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66492. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66493. */
  66494. export class KeyboardInfoPre extends KeyboardInfo {
  66495. /**
  66496. * Defines the type of event (KeyboardEventTypes)
  66497. */
  66498. type: number;
  66499. /**
  66500. * Defines the related dom event
  66501. */
  66502. event: KeyboardEvent;
  66503. /**
  66504. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66505. */
  66506. skipOnPointerObservable: boolean;
  66507. /**
  66508. * Instantiates a new keyboard pre info.
  66509. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66510. * @param type Defines the type of event (KeyboardEventTypes)
  66511. * @param event Defines the related dom event
  66512. */
  66513. constructor(
  66514. /**
  66515. * Defines the type of event (KeyboardEventTypes)
  66516. */
  66517. type: number,
  66518. /**
  66519. * Defines the related dom event
  66520. */
  66521. event: KeyboardEvent);
  66522. }
  66523. }
  66524. declare module BABYLON {
  66525. /**
  66526. * Manage the keyboard inputs to control the movement of a free camera.
  66527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66528. */
  66529. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66530. /**
  66531. * Defines the camera the input is attached to.
  66532. */
  66533. camera: FreeCamera;
  66534. /**
  66535. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66536. */
  66537. keysUp: number[];
  66538. /**
  66539. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66540. */
  66541. keysDown: number[];
  66542. /**
  66543. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66544. */
  66545. keysLeft: number[];
  66546. /**
  66547. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66548. */
  66549. keysRight: number[];
  66550. private _keys;
  66551. private _onCanvasBlurObserver;
  66552. private _onKeyboardObserver;
  66553. private _engine;
  66554. private _scene;
  66555. /**
  66556. * Attach the input controls to a specific dom element to get the input from.
  66557. * @param element Defines the element the controls should be listened from
  66558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66559. */
  66560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66561. /**
  66562. * Detach the current controls from the specified dom element.
  66563. * @param element Defines the element to stop listening the inputs from
  66564. */
  66565. detachControl(element: Nullable<HTMLElement>): void;
  66566. /**
  66567. * Update the current camera state depending on the inputs that have been used this frame.
  66568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66569. */
  66570. checkInputs(): void;
  66571. /**
  66572. * Gets the class name of the current intput.
  66573. * @returns the class name
  66574. */
  66575. getClassName(): string;
  66576. /** @hidden */
  66577. _onLostFocus(): void;
  66578. /**
  66579. * Get the friendly name associated with the input class.
  66580. * @returns the input friendly name
  66581. */
  66582. getSimpleName(): string;
  66583. }
  66584. }
  66585. declare module BABYLON {
  66586. /**
  66587. * Interface describing all the common properties and methods a shadow light needs to implement.
  66588. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66589. * as well as binding the different shadow properties to the effects.
  66590. */
  66591. export interface IShadowLight extends Light {
  66592. /**
  66593. * The light id in the scene (used in scene.findLighById for instance)
  66594. */
  66595. id: string;
  66596. /**
  66597. * The position the shdow will be casted from.
  66598. */
  66599. position: Vector3;
  66600. /**
  66601. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66602. */
  66603. direction: Vector3;
  66604. /**
  66605. * The transformed position. Position of the light in world space taking parenting in account.
  66606. */
  66607. transformedPosition: Vector3;
  66608. /**
  66609. * The transformed direction. Direction of the light in world space taking parenting in account.
  66610. */
  66611. transformedDirection: Vector3;
  66612. /**
  66613. * The friendly name of the light in the scene.
  66614. */
  66615. name: string;
  66616. /**
  66617. * Defines the shadow projection clipping minimum z value.
  66618. */
  66619. shadowMinZ: number;
  66620. /**
  66621. * Defines the shadow projection clipping maximum z value.
  66622. */
  66623. shadowMaxZ: number;
  66624. /**
  66625. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66626. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66627. */
  66628. computeTransformedInformation(): boolean;
  66629. /**
  66630. * Gets the scene the light belongs to.
  66631. * @returns The scene
  66632. */
  66633. getScene(): Scene;
  66634. /**
  66635. * Callback defining a custom Projection Matrix Builder.
  66636. * This can be used to override the default projection matrix computation.
  66637. */
  66638. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66639. /**
  66640. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66641. * @param matrix The materix to updated with the projection information
  66642. * @param viewMatrix The transform matrix of the light
  66643. * @param renderList The list of mesh to render in the map
  66644. * @returns The current light
  66645. */
  66646. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66647. /**
  66648. * Gets the current depth scale used in ESM.
  66649. * @returns The scale
  66650. */
  66651. getDepthScale(): number;
  66652. /**
  66653. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66654. * @returns true if a cube texture needs to be use
  66655. */
  66656. needCube(): boolean;
  66657. /**
  66658. * Detects if the projection matrix requires to be recomputed this frame.
  66659. * @returns true if it requires to be recomputed otherwise, false.
  66660. */
  66661. needProjectionMatrixCompute(): boolean;
  66662. /**
  66663. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66664. */
  66665. forceProjectionMatrixCompute(): void;
  66666. /**
  66667. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66668. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66669. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66670. */
  66671. getShadowDirection(faceIndex?: number): Vector3;
  66672. /**
  66673. * Gets the minZ used for shadow according to both the scene and the light.
  66674. * @param activeCamera The camera we are returning the min for
  66675. * @returns the depth min z
  66676. */
  66677. getDepthMinZ(activeCamera: Camera): number;
  66678. /**
  66679. * Gets the maxZ used for shadow according to both the scene and the light.
  66680. * @param activeCamera The camera we are returning the max for
  66681. * @returns the depth max z
  66682. */
  66683. getDepthMaxZ(activeCamera: Camera): number;
  66684. }
  66685. /**
  66686. * Base implementation IShadowLight
  66687. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66688. */
  66689. export abstract class ShadowLight extends Light implements IShadowLight {
  66690. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66691. protected _position: Vector3;
  66692. protected _setPosition(value: Vector3): void;
  66693. /**
  66694. * Sets the position the shadow will be casted from. Also use as the light position for both
  66695. * point and spot lights.
  66696. */
  66697. /**
  66698. * Sets the position the shadow will be casted from. Also use as the light position for both
  66699. * point and spot lights.
  66700. */
  66701. position: Vector3;
  66702. protected _direction: Vector3;
  66703. protected _setDirection(value: Vector3): void;
  66704. /**
  66705. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66706. * Also use as the light direction on spot and directional lights.
  66707. */
  66708. /**
  66709. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66710. * Also use as the light direction on spot and directional lights.
  66711. */
  66712. direction: Vector3;
  66713. private _shadowMinZ;
  66714. /**
  66715. * Gets the shadow projection clipping minimum z value.
  66716. */
  66717. /**
  66718. * Sets the shadow projection clipping minimum z value.
  66719. */
  66720. shadowMinZ: number;
  66721. private _shadowMaxZ;
  66722. /**
  66723. * Sets the shadow projection clipping maximum z value.
  66724. */
  66725. /**
  66726. * Gets the shadow projection clipping maximum z value.
  66727. */
  66728. shadowMaxZ: number;
  66729. /**
  66730. * Callback defining a custom Projection Matrix Builder.
  66731. * This can be used to override the default projection matrix computation.
  66732. */
  66733. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66734. /**
  66735. * The transformed position. Position of the light in world space taking parenting in account.
  66736. */
  66737. transformedPosition: Vector3;
  66738. /**
  66739. * The transformed direction. Direction of the light in world space taking parenting in account.
  66740. */
  66741. transformedDirection: Vector3;
  66742. private _needProjectionMatrixCompute;
  66743. /**
  66744. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66745. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66746. */
  66747. computeTransformedInformation(): boolean;
  66748. /**
  66749. * Return the depth scale used for the shadow map.
  66750. * @returns the depth scale.
  66751. */
  66752. getDepthScale(): number;
  66753. /**
  66754. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66755. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66756. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66757. */
  66758. getShadowDirection(faceIndex?: number): Vector3;
  66759. /**
  66760. * Returns the ShadowLight absolute position in the World.
  66761. * @returns the position vector in world space
  66762. */
  66763. getAbsolutePosition(): Vector3;
  66764. /**
  66765. * Sets the ShadowLight direction toward the passed target.
  66766. * @param target The point to target in local space
  66767. * @returns the updated ShadowLight direction
  66768. */
  66769. setDirectionToTarget(target: Vector3): Vector3;
  66770. /**
  66771. * Returns the light rotation in euler definition.
  66772. * @returns the x y z rotation in local space.
  66773. */
  66774. getRotation(): Vector3;
  66775. /**
  66776. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66777. * @returns true if a cube texture needs to be use
  66778. */
  66779. needCube(): boolean;
  66780. /**
  66781. * Detects if the projection matrix requires to be recomputed this frame.
  66782. * @returns true if it requires to be recomputed otherwise, false.
  66783. */
  66784. needProjectionMatrixCompute(): boolean;
  66785. /**
  66786. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66787. */
  66788. forceProjectionMatrixCompute(): void;
  66789. /** @hidden */
  66790. _initCache(): void;
  66791. /** @hidden */
  66792. _isSynchronized(): boolean;
  66793. /**
  66794. * Computes the world matrix of the node
  66795. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66796. * @returns the world matrix
  66797. */
  66798. computeWorldMatrix(force?: boolean): Matrix;
  66799. /**
  66800. * Gets the minZ used for shadow according to both the scene and the light.
  66801. * @param activeCamera The camera we are returning the min for
  66802. * @returns the depth min z
  66803. */
  66804. getDepthMinZ(activeCamera: Camera): number;
  66805. /**
  66806. * Gets the maxZ used for shadow according to both the scene and the light.
  66807. * @param activeCamera The camera we are returning the max for
  66808. * @returns the depth max z
  66809. */
  66810. getDepthMaxZ(activeCamera: Camera): number;
  66811. /**
  66812. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66813. * @param matrix The materix to updated with the projection information
  66814. * @param viewMatrix The transform matrix of the light
  66815. * @param renderList The list of mesh to render in the map
  66816. * @returns The current light
  66817. */
  66818. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66819. }
  66820. }
  66821. declare module BABYLON {
  66822. /**
  66823. * "Static Class" containing the most commonly used helper while dealing with material for
  66824. * rendering purpose.
  66825. *
  66826. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66827. *
  66828. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66829. */
  66830. export class MaterialHelper {
  66831. /**
  66832. * Bind the current view position to an effect.
  66833. * @param effect The effect to be bound
  66834. * @param scene The scene the eyes position is used from
  66835. */
  66836. static BindEyePosition(effect: Effect, scene: Scene): void;
  66837. /**
  66838. * Helps preparing the defines values about the UVs in used in the effect.
  66839. * UVs are shared as much as we can accross channels in the shaders.
  66840. * @param texture The texture we are preparing the UVs for
  66841. * @param defines The defines to update
  66842. * @param key The channel key "diffuse", "specular"... used in the shader
  66843. */
  66844. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66845. /**
  66846. * Binds a texture matrix value to its corrsponding uniform
  66847. * @param texture The texture to bind the matrix for
  66848. * @param uniformBuffer The uniform buffer receivin the data
  66849. * @param key The channel key "diffuse", "specular"... used in the shader
  66850. */
  66851. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66852. /**
  66853. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66854. * @param mesh defines the current mesh
  66855. * @param scene defines the current scene
  66856. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66857. * @param pointsCloud defines if point cloud rendering has to be turned on
  66858. * @param fogEnabled defines if fog has to be turned on
  66859. * @param alphaTest defines if alpha testing has to be turned on
  66860. * @param defines defines the current list of defines
  66861. */
  66862. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66863. /**
  66864. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66865. * @param scene defines the current scene
  66866. * @param engine defines the current engine
  66867. * @param defines specifies the list of active defines
  66868. * @param useInstances defines if instances have to be turned on
  66869. * @param useClipPlane defines if clip plane have to be turned on
  66870. */
  66871. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66872. /**
  66873. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66874. * @param mesh The mesh containing the geometry data we will draw
  66875. * @param defines The defines to update
  66876. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66877. * @param useBones Precise whether bones should be used or not (override mesh info)
  66878. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66879. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66880. * @returns false if defines are considered not dirty and have not been checked
  66881. */
  66882. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66883. /**
  66884. * Prepares the defines related to the light information passed in parameter
  66885. * @param scene The scene we are intending to draw
  66886. * @param mesh The mesh the effect is compiling for
  66887. * @param defines The defines to update
  66888. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66889. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66890. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66891. * @returns true if normals will be required for the rest of the effect
  66892. */
  66893. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66894. /**
  66895. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66896. * that won t be acctive due to defines being turned off.
  66897. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66898. * @param samplersList The samplers list
  66899. * @param defines The defines helping in the list generation
  66900. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66901. */
  66902. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66903. /**
  66904. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66905. * @param defines The defines to update while falling back
  66906. * @param fallbacks The authorized effect fallbacks
  66907. * @param maxSimultaneousLights The maximum number of lights allowed
  66908. * @param rank the current rank of the Effect
  66909. * @returns The newly affected rank
  66910. */
  66911. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66912. /**
  66913. * Prepares the list of attributes required for morph targets according to the effect defines.
  66914. * @param attribs The current list of supported attribs
  66915. * @param mesh The mesh to prepare the morph targets attributes for
  66916. * @param defines The current Defines of the effect
  66917. */
  66918. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66919. /**
  66920. * Prepares the list of attributes required for bones according to the effect defines.
  66921. * @param attribs The current list of supported attribs
  66922. * @param mesh The mesh to prepare the bones attributes for
  66923. * @param defines The current Defines of the effect
  66924. * @param fallbacks The current efffect fallback strategy
  66925. */
  66926. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66927. /**
  66928. * Prepares the list of attributes required for instances according to the effect defines.
  66929. * @param attribs The current list of supported attribs
  66930. * @param defines The current Defines of the effect
  66931. */
  66932. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66933. /**
  66934. * Binds the light shadow information to the effect for the given mesh.
  66935. * @param light The light containing the generator
  66936. * @param scene The scene the lights belongs to
  66937. * @param mesh The mesh we are binding the information to render
  66938. * @param lightIndex The light index in the effect used to render the mesh
  66939. * @param effect The effect we are binding the data to
  66940. */
  66941. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66942. /**
  66943. * Binds the light information to the effect.
  66944. * @param light The light containing the generator
  66945. * @param effect The effect we are binding the data to
  66946. * @param lightIndex The light index in the effect used to render
  66947. */
  66948. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66949. /**
  66950. * Binds the lights information from the scene to the effect for the given mesh.
  66951. * @param scene The scene the lights belongs to
  66952. * @param mesh The mesh we are binding the information to render
  66953. * @param effect The effect we are binding the data to
  66954. * @param defines The generated defines for the effect
  66955. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66956. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66957. */
  66958. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66959. private static _tempFogColor;
  66960. /**
  66961. * Binds the fog information from the scene to the effect for the given mesh.
  66962. * @param scene The scene the lights belongs to
  66963. * @param mesh The mesh we are binding the information to render
  66964. * @param effect The effect we are binding the data to
  66965. * @param linearSpace Defines if the fog effect is applied in linear space
  66966. */
  66967. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66968. /**
  66969. * Binds the bones information from the mesh to the effect.
  66970. * @param mesh The mesh we are binding the information to render
  66971. * @param effect The effect we are binding the data to
  66972. */
  66973. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66974. /**
  66975. * Binds the morph targets information from the mesh to the effect.
  66976. * @param abstractMesh The mesh we are binding the information to render
  66977. * @param effect The effect we are binding the data to
  66978. */
  66979. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66980. /**
  66981. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66982. * @param defines The generated defines used in the effect
  66983. * @param effect The effect we are binding the data to
  66984. * @param scene The scene we are willing to render with logarithmic scale for
  66985. */
  66986. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66987. /**
  66988. * Binds the clip plane information from the scene to the effect.
  66989. * @param scene The scene the clip plane information are extracted from
  66990. * @param effect The effect we are binding the data to
  66991. */
  66992. static BindClipPlane(effect: Effect, scene: Scene): void;
  66993. }
  66994. }
  66995. declare module BABYLON {
  66996. /** @hidden */
  66997. export var kernelBlurVaryingDeclaration: {
  66998. name: string;
  66999. shader: string;
  67000. };
  67001. }
  67002. declare module BABYLON {
  67003. /** @hidden */
  67004. export var kernelBlurFragment: {
  67005. name: string;
  67006. shader: string;
  67007. };
  67008. }
  67009. declare module BABYLON {
  67010. /** @hidden */
  67011. export var kernelBlurFragment2: {
  67012. name: string;
  67013. shader: string;
  67014. };
  67015. }
  67016. declare module BABYLON {
  67017. /** @hidden */
  67018. export var kernelBlurPixelShader: {
  67019. name: string;
  67020. shader: string;
  67021. };
  67022. }
  67023. declare module BABYLON {
  67024. /** @hidden */
  67025. export var kernelBlurVertex: {
  67026. name: string;
  67027. shader: string;
  67028. };
  67029. }
  67030. declare module BABYLON {
  67031. /** @hidden */
  67032. export var kernelBlurVertexShader: {
  67033. name: string;
  67034. shader: string;
  67035. };
  67036. }
  67037. declare module BABYLON {
  67038. /**
  67039. * The Blur Post Process which blurs an image based on a kernel and direction.
  67040. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67041. */
  67042. export class BlurPostProcess extends PostProcess {
  67043. /** The direction in which to blur the image. */
  67044. direction: Vector2;
  67045. private blockCompilation;
  67046. protected _kernel: number;
  67047. protected _idealKernel: number;
  67048. protected _packedFloat: boolean;
  67049. private _staticDefines;
  67050. /**
  67051. * Sets the length in pixels of the blur sample region
  67052. */
  67053. /**
  67054. * Gets the length in pixels of the blur sample region
  67055. */
  67056. kernel: number;
  67057. /**
  67058. * Sets wether or not the blur needs to unpack/repack floats
  67059. */
  67060. /**
  67061. * Gets wether or not the blur is unpacking/repacking floats
  67062. */
  67063. packedFloat: boolean;
  67064. /**
  67065. * Creates a new instance BlurPostProcess
  67066. * @param name The name of the effect.
  67067. * @param direction The direction in which to blur the image.
  67068. * @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.
  67069. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67070. * @param camera The camera to apply the render pass to.
  67071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67072. * @param engine The engine which the post process will be applied. (default: current engine)
  67073. * @param reusable If the post process can be reused on the same frame. (default: false)
  67074. * @param textureType Type of textures used when performing the post process. (default: 0)
  67075. * @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)
  67076. */
  67077. constructor(name: string,
  67078. /** The direction in which to blur the image. */
  67079. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67080. /**
  67081. * Updates the effect with the current post process compile time values and recompiles the shader.
  67082. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67083. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67084. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67085. * @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
  67086. * @param onCompiled Called when the shader has been compiled.
  67087. * @param onError Called if there is an error when compiling a shader.
  67088. */
  67089. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67090. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67091. /**
  67092. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67093. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67094. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67095. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67096. * The gaps between physical kernels are compensated for in the weighting of the samples
  67097. * @param idealKernel Ideal blur kernel.
  67098. * @return Nearest best kernel.
  67099. */
  67100. protected _nearestBestKernel(idealKernel: number): number;
  67101. /**
  67102. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67103. * @param x The point on the Gaussian distribution to sample.
  67104. * @return the value of the Gaussian function at x.
  67105. */
  67106. protected _gaussianWeight(x: number): number;
  67107. /**
  67108. * Generates a string that can be used as a floating point number in GLSL.
  67109. * @param x Value to print.
  67110. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67111. * @return GLSL float string.
  67112. */
  67113. protected _glslFloat(x: number, decimalFigures?: number): string;
  67114. }
  67115. }
  67116. declare module BABYLON {
  67117. /** @hidden */
  67118. export var shadowMapPixelShader: {
  67119. name: string;
  67120. shader: string;
  67121. };
  67122. }
  67123. declare module BABYLON {
  67124. /** @hidden */
  67125. export var bonesDeclaration: {
  67126. name: string;
  67127. shader: string;
  67128. };
  67129. }
  67130. declare module BABYLON {
  67131. /** @hidden */
  67132. export var morphTargetsVertexGlobalDeclaration: {
  67133. name: string;
  67134. shader: string;
  67135. };
  67136. }
  67137. declare module BABYLON {
  67138. /** @hidden */
  67139. export var morphTargetsVertexDeclaration: {
  67140. name: string;
  67141. shader: string;
  67142. };
  67143. }
  67144. declare module BABYLON {
  67145. /** @hidden */
  67146. export var instancesDeclaration: {
  67147. name: string;
  67148. shader: string;
  67149. };
  67150. }
  67151. declare module BABYLON {
  67152. /** @hidden */
  67153. export var helperFunctions: {
  67154. name: string;
  67155. shader: string;
  67156. };
  67157. }
  67158. declare module BABYLON {
  67159. /** @hidden */
  67160. export var morphTargetsVertex: {
  67161. name: string;
  67162. shader: string;
  67163. };
  67164. }
  67165. declare module BABYLON {
  67166. /** @hidden */
  67167. export var instancesVertex: {
  67168. name: string;
  67169. shader: string;
  67170. };
  67171. }
  67172. declare module BABYLON {
  67173. /** @hidden */
  67174. export var bonesVertex: {
  67175. name: string;
  67176. shader: string;
  67177. };
  67178. }
  67179. declare module BABYLON {
  67180. /** @hidden */
  67181. export var shadowMapVertexShader: {
  67182. name: string;
  67183. shader: string;
  67184. };
  67185. }
  67186. declare module BABYLON {
  67187. /** @hidden */
  67188. export var depthBoxBlurPixelShader: {
  67189. name: string;
  67190. shader: string;
  67191. };
  67192. }
  67193. declare module BABYLON {
  67194. /**
  67195. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67196. */
  67197. export interface ICustomShaderOptions {
  67198. /**
  67199. * Gets or sets the custom shader name to use
  67200. */
  67201. shaderName: string;
  67202. /**
  67203. * The list of attribute names used in the shader
  67204. */
  67205. attributes?: string[];
  67206. /**
  67207. * The list of unifrom names used in the shader
  67208. */
  67209. uniforms?: string[];
  67210. /**
  67211. * The list of sampler names used in the shader
  67212. */
  67213. samplers?: string[];
  67214. /**
  67215. * The list of defines used in the shader
  67216. */
  67217. defines?: string[];
  67218. }
  67219. /**
  67220. * Interface to implement to create a shadow generator compatible with BJS.
  67221. */
  67222. export interface IShadowGenerator {
  67223. /**
  67224. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67225. * @returns The render target texture if present otherwise, null
  67226. */
  67227. getShadowMap(): Nullable<RenderTargetTexture>;
  67228. /**
  67229. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67230. * @returns The render target texture if the shadow map is present otherwise, null
  67231. */
  67232. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67233. /**
  67234. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67235. * @param subMesh The submesh we want to render in the shadow map
  67236. * @param useInstances Defines wether will draw in the map using instances
  67237. * @returns true if ready otherwise, false
  67238. */
  67239. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67240. /**
  67241. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67242. * @param defines Defines of the material we want to update
  67243. * @param lightIndex Index of the light in the enabled light list of the material
  67244. */
  67245. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67246. /**
  67247. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67248. * defined in the generator but impacting the effect).
  67249. * It implies the unifroms available on the materials are the standard BJS ones.
  67250. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67251. * @param effect The effect we are binfing the information for
  67252. */
  67253. bindShadowLight(lightIndex: string, effect: Effect): void;
  67254. /**
  67255. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67256. * (eq to shadow prjection matrix * light transform matrix)
  67257. * @returns The transform matrix used to create the shadow map
  67258. */
  67259. getTransformMatrix(): Matrix;
  67260. /**
  67261. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67262. * Cube and 2D textures for instance.
  67263. */
  67264. recreateShadowMap(): void;
  67265. /**
  67266. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67267. * @param onCompiled Callback triggered at the and of the effects compilation
  67268. * @param options Sets of optional options forcing the compilation with different modes
  67269. */
  67270. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67271. useInstances: boolean;
  67272. }>): void;
  67273. /**
  67274. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67275. * @param options Sets of optional options forcing the compilation with different modes
  67276. * @returns A promise that resolves when the compilation completes
  67277. */
  67278. forceCompilationAsync(options?: Partial<{
  67279. useInstances: boolean;
  67280. }>): Promise<void>;
  67281. /**
  67282. * Serializes the shadow generator setup to a json object.
  67283. * @returns The serialized JSON object
  67284. */
  67285. serialize(): any;
  67286. /**
  67287. * Disposes the Shadow map and related Textures and effects.
  67288. */
  67289. dispose(): void;
  67290. }
  67291. /**
  67292. * Default implementation IShadowGenerator.
  67293. * This is the main object responsible of generating shadows in the framework.
  67294. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67295. */
  67296. export class ShadowGenerator implements IShadowGenerator {
  67297. /**
  67298. * Shadow generator mode None: no filtering applied.
  67299. */
  67300. static readonly FILTER_NONE: number;
  67301. /**
  67302. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67303. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67304. */
  67305. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67306. /**
  67307. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67308. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67309. */
  67310. static readonly FILTER_POISSONSAMPLING: number;
  67311. /**
  67312. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67313. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67314. */
  67315. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67316. /**
  67317. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67318. * edge artifacts on steep falloff.
  67319. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67320. */
  67321. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67322. /**
  67323. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67324. * edge artifacts on steep falloff.
  67325. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67326. */
  67327. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67328. /**
  67329. * Shadow generator mode PCF: Percentage Closer Filtering
  67330. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67331. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67332. */
  67333. static readonly FILTER_PCF: number;
  67334. /**
  67335. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67336. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67337. * Contact Hardening
  67338. */
  67339. static readonly FILTER_PCSS: number;
  67340. /**
  67341. * Reserved for PCF and PCSS
  67342. * Highest Quality.
  67343. *
  67344. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67345. *
  67346. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67347. */
  67348. static readonly QUALITY_HIGH: number;
  67349. /**
  67350. * Reserved for PCF and PCSS
  67351. * Good tradeoff for quality/perf cross devices
  67352. *
  67353. * Execute PCF on a 3*3 kernel.
  67354. *
  67355. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67356. */
  67357. static readonly QUALITY_MEDIUM: number;
  67358. /**
  67359. * Reserved for PCF and PCSS
  67360. * The lowest quality but the fastest.
  67361. *
  67362. * Execute PCF on a 1*1 kernel.
  67363. *
  67364. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67365. */
  67366. static readonly QUALITY_LOW: number;
  67367. /** Gets or sets the custom shader name to use */
  67368. customShaderOptions: ICustomShaderOptions;
  67369. /**
  67370. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67371. */
  67372. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67373. /**
  67374. * Observable triggered before a mesh is rendered in the shadow map.
  67375. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67376. */
  67377. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67378. private _bias;
  67379. /**
  67380. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67381. */
  67382. /**
  67383. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67384. */
  67385. bias: number;
  67386. private _normalBias;
  67387. /**
  67388. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67389. */
  67390. /**
  67391. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67392. */
  67393. normalBias: number;
  67394. private _blurBoxOffset;
  67395. /**
  67396. * Gets the blur box offset: offset applied during the blur pass.
  67397. * Only useful if useKernelBlur = false
  67398. */
  67399. /**
  67400. * Sets the blur box offset: offset applied during the blur pass.
  67401. * Only useful if useKernelBlur = false
  67402. */
  67403. blurBoxOffset: number;
  67404. private _blurScale;
  67405. /**
  67406. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67407. * 2 means half of the size.
  67408. */
  67409. /**
  67410. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67411. * 2 means half of the size.
  67412. */
  67413. blurScale: number;
  67414. private _blurKernel;
  67415. /**
  67416. * Gets the blur kernel: kernel size of the blur pass.
  67417. * Only useful if useKernelBlur = true
  67418. */
  67419. /**
  67420. * Sets the blur kernel: kernel size of the blur pass.
  67421. * Only useful if useKernelBlur = true
  67422. */
  67423. blurKernel: number;
  67424. private _useKernelBlur;
  67425. /**
  67426. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67427. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67428. */
  67429. /**
  67430. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67431. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67432. */
  67433. useKernelBlur: boolean;
  67434. private _depthScale;
  67435. /**
  67436. * Gets the depth scale used in ESM mode.
  67437. */
  67438. /**
  67439. * Sets the depth scale used in ESM mode.
  67440. * This can override the scale stored on the light.
  67441. */
  67442. depthScale: number;
  67443. private _filter;
  67444. /**
  67445. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67446. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67447. */
  67448. /**
  67449. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67450. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67451. */
  67452. filter: number;
  67453. /**
  67454. * Gets if the current filter is set to Poisson Sampling.
  67455. */
  67456. /**
  67457. * Sets the current filter to Poisson Sampling.
  67458. */
  67459. usePoissonSampling: boolean;
  67460. /**
  67461. * Gets if the current filter is set to ESM.
  67462. */
  67463. /**
  67464. * Sets the current filter is to ESM.
  67465. */
  67466. useExponentialShadowMap: boolean;
  67467. /**
  67468. * Gets if the current filter is set to filtered ESM.
  67469. */
  67470. /**
  67471. * Gets if the current filter is set to filtered ESM.
  67472. */
  67473. useBlurExponentialShadowMap: boolean;
  67474. /**
  67475. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67476. * exponential to prevent steep falloff artifacts).
  67477. */
  67478. /**
  67479. * Sets the current filter to "close ESM" (using the inverse of the
  67480. * exponential to prevent steep falloff artifacts).
  67481. */
  67482. useCloseExponentialShadowMap: boolean;
  67483. /**
  67484. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67485. * exponential to prevent steep falloff artifacts).
  67486. */
  67487. /**
  67488. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67489. * exponential to prevent steep falloff artifacts).
  67490. */
  67491. useBlurCloseExponentialShadowMap: boolean;
  67492. /**
  67493. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67494. */
  67495. /**
  67496. * Sets the current filter to "PCF" (percentage closer filtering).
  67497. */
  67498. usePercentageCloserFiltering: boolean;
  67499. private _filteringQuality;
  67500. /**
  67501. * Gets the PCF or PCSS Quality.
  67502. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67503. */
  67504. /**
  67505. * Sets the PCF or PCSS Quality.
  67506. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67507. */
  67508. filteringQuality: number;
  67509. /**
  67510. * Gets if the current filter is set to "PCSS" (contact hardening).
  67511. */
  67512. /**
  67513. * Sets the current filter to "PCSS" (contact hardening).
  67514. */
  67515. useContactHardeningShadow: boolean;
  67516. private _contactHardeningLightSizeUVRatio;
  67517. /**
  67518. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67519. * Using a ratio helps keeping shape stability independently of the map size.
  67520. *
  67521. * It does not account for the light projection as it was having too much
  67522. * instability during the light setup or during light position changes.
  67523. *
  67524. * Only valid if useContactHardeningShadow is true.
  67525. */
  67526. /**
  67527. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67528. * Using a ratio helps keeping shape stability independently of the map size.
  67529. *
  67530. * It does not account for the light projection as it was having too much
  67531. * instability during the light setup or during light position changes.
  67532. *
  67533. * Only valid if useContactHardeningShadow is true.
  67534. */
  67535. contactHardeningLightSizeUVRatio: number;
  67536. private _darkness;
  67537. /**
  67538. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67539. * 0 means strongest and 1 would means no shadow.
  67540. * @returns the darkness.
  67541. */
  67542. getDarkness(): number;
  67543. /**
  67544. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67545. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67546. * @returns the shadow generator allowing fluent coding.
  67547. */
  67548. setDarkness(darkness: number): ShadowGenerator;
  67549. private _transparencyShadow;
  67550. /**
  67551. * Sets the ability to have transparent shadow (boolean).
  67552. * @param transparent True if transparent else False
  67553. * @returns the shadow generator allowing fluent coding
  67554. */
  67555. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67556. private _shadowMap;
  67557. private _shadowMap2;
  67558. /**
  67559. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67560. * @returns The render target texture if present otherwise, null
  67561. */
  67562. getShadowMap(): Nullable<RenderTargetTexture>;
  67563. /**
  67564. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67565. * @returns The render target texture if the shadow map is present otherwise, null
  67566. */
  67567. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67568. /**
  67569. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67570. * @param mesh Mesh to add
  67571. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67572. * @returns the Shadow Generator itself
  67573. */
  67574. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67575. /**
  67576. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67577. * @param mesh Mesh to remove
  67578. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67579. * @returns the Shadow Generator itself
  67580. */
  67581. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67582. /**
  67583. * Controls the extent to which the shadows fade out at the edge of the frustum
  67584. * Used only by directionals and spots
  67585. */
  67586. frustumEdgeFalloff: number;
  67587. private _light;
  67588. /**
  67589. * Returns the associated light object.
  67590. * @returns the light generating the shadow
  67591. */
  67592. getLight(): IShadowLight;
  67593. /**
  67594. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67595. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67596. * It might on the other hand introduce peter panning.
  67597. */
  67598. forceBackFacesOnly: boolean;
  67599. private _scene;
  67600. private _lightDirection;
  67601. private _effect;
  67602. private _viewMatrix;
  67603. private _projectionMatrix;
  67604. private _transformMatrix;
  67605. private _cachedPosition;
  67606. private _cachedDirection;
  67607. private _cachedDefines;
  67608. private _currentRenderID;
  67609. private _boxBlurPostprocess;
  67610. private _kernelBlurXPostprocess;
  67611. private _kernelBlurYPostprocess;
  67612. private _blurPostProcesses;
  67613. private _mapSize;
  67614. private _currentFaceIndex;
  67615. private _currentFaceIndexCache;
  67616. private _textureType;
  67617. private _defaultTextureMatrix;
  67618. /** @hidden */
  67619. static _SceneComponentInitialization: (scene: Scene) => void;
  67620. /**
  67621. * Creates a ShadowGenerator object.
  67622. * A ShadowGenerator is the required tool to use the shadows.
  67623. * Each light casting shadows needs to use its own ShadowGenerator.
  67624. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67625. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67626. * @param light The light object generating the shadows.
  67627. * @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.
  67628. */
  67629. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67630. private _initializeGenerator;
  67631. private _initializeShadowMap;
  67632. private _initializeBlurRTTAndPostProcesses;
  67633. private _renderForShadowMap;
  67634. private _renderSubMeshForShadowMap;
  67635. private _applyFilterValues;
  67636. /**
  67637. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67638. * @param onCompiled Callback triggered at the and of the effects compilation
  67639. * @param options Sets of optional options forcing the compilation with different modes
  67640. */
  67641. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67642. useInstances: boolean;
  67643. }>): void;
  67644. /**
  67645. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67646. * @param options Sets of optional options forcing the compilation with different modes
  67647. * @returns A promise that resolves when the compilation completes
  67648. */
  67649. forceCompilationAsync(options?: Partial<{
  67650. useInstances: boolean;
  67651. }>): Promise<void>;
  67652. /**
  67653. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67654. * @param subMesh The submesh we want to render in the shadow map
  67655. * @param useInstances Defines wether will draw in the map using instances
  67656. * @returns true if ready otherwise, false
  67657. */
  67658. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67659. /**
  67660. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67661. * @param defines Defines of the material we want to update
  67662. * @param lightIndex Index of the light in the enabled light list of the material
  67663. */
  67664. prepareDefines(defines: any, lightIndex: number): void;
  67665. /**
  67666. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67667. * defined in the generator but impacting the effect).
  67668. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67669. * @param effect The effect we are binfing the information for
  67670. */
  67671. bindShadowLight(lightIndex: string, effect: Effect): void;
  67672. /**
  67673. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67674. * (eq to shadow prjection matrix * light transform matrix)
  67675. * @returns The transform matrix used to create the shadow map
  67676. */
  67677. getTransformMatrix(): Matrix;
  67678. /**
  67679. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67680. * Cube and 2D textures for instance.
  67681. */
  67682. recreateShadowMap(): void;
  67683. private _disposeBlurPostProcesses;
  67684. private _disposeRTTandPostProcesses;
  67685. /**
  67686. * Disposes the ShadowGenerator.
  67687. * Returns nothing.
  67688. */
  67689. dispose(): void;
  67690. /**
  67691. * Serializes the shadow generator setup to a json object.
  67692. * @returns The serialized JSON object
  67693. */
  67694. serialize(): any;
  67695. /**
  67696. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67697. * @param parsedShadowGenerator The JSON object to parse
  67698. * @param scene The scene to create the shadow map for
  67699. * @returns The parsed shadow generator
  67700. */
  67701. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67702. }
  67703. }
  67704. declare module BABYLON {
  67705. /**
  67706. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67707. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67708. * 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.
  67709. */
  67710. export abstract class Light extends Node {
  67711. /**
  67712. * Falloff Default: light is falling off following the material specification:
  67713. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67714. */
  67715. static readonly FALLOFF_DEFAULT: number;
  67716. /**
  67717. * Falloff Physical: light is falling off following the inverse squared distance law.
  67718. */
  67719. static readonly FALLOFF_PHYSICAL: number;
  67720. /**
  67721. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67722. * to enhance interoperability with other engines.
  67723. */
  67724. static readonly FALLOFF_GLTF: number;
  67725. /**
  67726. * Falloff Standard: light is falling off like in the standard material
  67727. * to enhance interoperability with other materials.
  67728. */
  67729. static readonly FALLOFF_STANDARD: number;
  67730. /**
  67731. * If every light affecting the material is in this lightmapMode,
  67732. * material.lightmapTexture adds or multiplies
  67733. * (depends on material.useLightmapAsShadowmap)
  67734. * after every other light calculations.
  67735. */
  67736. static readonly LIGHTMAP_DEFAULT: number;
  67737. /**
  67738. * material.lightmapTexture as only diffuse lighting from this light
  67739. * adds only specular lighting from this light
  67740. * adds dynamic shadows
  67741. */
  67742. static readonly LIGHTMAP_SPECULAR: number;
  67743. /**
  67744. * material.lightmapTexture as only lighting
  67745. * no light calculation from this light
  67746. * only adds dynamic shadows from this light
  67747. */
  67748. static readonly LIGHTMAP_SHADOWSONLY: number;
  67749. /**
  67750. * Each light type uses the default quantity according to its type:
  67751. * point/spot lights use luminous intensity
  67752. * directional lights use illuminance
  67753. */
  67754. static readonly INTENSITYMODE_AUTOMATIC: number;
  67755. /**
  67756. * lumen (lm)
  67757. */
  67758. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67759. /**
  67760. * candela (lm/sr)
  67761. */
  67762. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67763. /**
  67764. * lux (lm/m^2)
  67765. */
  67766. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67767. /**
  67768. * nit (cd/m^2)
  67769. */
  67770. static readonly INTENSITYMODE_LUMINANCE: number;
  67771. /**
  67772. * Light type const id of the point light.
  67773. */
  67774. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67775. /**
  67776. * Light type const id of the directional light.
  67777. */
  67778. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67779. /**
  67780. * Light type const id of the spot light.
  67781. */
  67782. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67783. /**
  67784. * Light type const id of the hemispheric light.
  67785. */
  67786. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67787. /**
  67788. * Diffuse gives the basic color to an object.
  67789. */
  67790. diffuse: Color3;
  67791. /**
  67792. * Specular produces a highlight color on an object.
  67793. * Note: This is note affecting PBR materials.
  67794. */
  67795. specular: Color3;
  67796. /**
  67797. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67798. * falling off base on range or angle.
  67799. * This can be set to any values in Light.FALLOFF_x.
  67800. *
  67801. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67802. * other types of materials.
  67803. */
  67804. falloffType: number;
  67805. /**
  67806. * Strength of the light.
  67807. * Note: By default it is define in the framework own unit.
  67808. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67809. */
  67810. intensity: number;
  67811. private _range;
  67812. protected _inverseSquaredRange: number;
  67813. /**
  67814. * Defines how far from the source the light is impacting in scene units.
  67815. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67816. */
  67817. /**
  67818. * Defines how far from the source the light is impacting in scene units.
  67819. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67820. */
  67821. range: number;
  67822. /**
  67823. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67824. * of light.
  67825. */
  67826. private _photometricScale;
  67827. private _intensityMode;
  67828. /**
  67829. * Gets the photometric scale used to interpret the intensity.
  67830. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67831. */
  67832. /**
  67833. * Sets the photometric scale used to interpret the intensity.
  67834. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67835. */
  67836. intensityMode: number;
  67837. private _radius;
  67838. /**
  67839. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67840. */
  67841. /**
  67842. * sets the light radius used by PBR Materials to simulate soft area lights.
  67843. */
  67844. radius: number;
  67845. private _renderPriority;
  67846. /**
  67847. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67848. * exceeding the number allowed of the materials.
  67849. */
  67850. renderPriority: number;
  67851. private _shadowEnabled;
  67852. /**
  67853. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67854. * the current shadow generator.
  67855. */
  67856. /**
  67857. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67858. * the current shadow generator.
  67859. */
  67860. shadowEnabled: boolean;
  67861. private _includedOnlyMeshes;
  67862. /**
  67863. * Gets the only meshes impacted by this light.
  67864. */
  67865. /**
  67866. * Sets the only meshes impacted by this light.
  67867. */
  67868. includedOnlyMeshes: AbstractMesh[];
  67869. private _excludedMeshes;
  67870. /**
  67871. * Gets the meshes not impacted by this light.
  67872. */
  67873. /**
  67874. * Sets the meshes not impacted by this light.
  67875. */
  67876. excludedMeshes: AbstractMesh[];
  67877. private _excludeWithLayerMask;
  67878. /**
  67879. * Gets the layer id use to find what meshes are not impacted by the light.
  67880. * Inactive if 0
  67881. */
  67882. /**
  67883. * Sets the layer id use to find what meshes are not impacted by the light.
  67884. * Inactive if 0
  67885. */
  67886. excludeWithLayerMask: number;
  67887. private _includeOnlyWithLayerMask;
  67888. /**
  67889. * Gets the layer id use to find what meshes are impacted by the light.
  67890. * Inactive if 0
  67891. */
  67892. /**
  67893. * Sets the layer id use to find what meshes are impacted by the light.
  67894. * Inactive if 0
  67895. */
  67896. includeOnlyWithLayerMask: number;
  67897. private _lightmapMode;
  67898. /**
  67899. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67900. */
  67901. /**
  67902. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67903. */
  67904. lightmapMode: number;
  67905. /**
  67906. * Shadow generator associted to the light.
  67907. * @hidden Internal use only.
  67908. */
  67909. _shadowGenerator: Nullable<IShadowGenerator>;
  67910. /**
  67911. * @hidden Internal use only.
  67912. */
  67913. _excludedMeshesIds: string[];
  67914. /**
  67915. * @hidden Internal use only.
  67916. */
  67917. _includedOnlyMeshesIds: string[];
  67918. /**
  67919. * The current light unifom buffer.
  67920. * @hidden Internal use only.
  67921. */
  67922. _uniformBuffer: UniformBuffer;
  67923. /**
  67924. * Creates a Light object in the scene.
  67925. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67926. * @param name The firendly name of the light
  67927. * @param scene The scene the light belongs too
  67928. */
  67929. constructor(name: string, scene: Scene);
  67930. protected abstract _buildUniformLayout(): void;
  67931. /**
  67932. * Sets the passed Effect "effect" with the Light information.
  67933. * @param effect The effect to update
  67934. * @param lightIndex The index of the light in the effect to update
  67935. * @returns The light
  67936. */
  67937. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67938. /**
  67939. * Returns the string "Light".
  67940. * @returns the class name
  67941. */
  67942. getClassName(): string;
  67943. /** @hidden */
  67944. readonly _isLight: boolean;
  67945. /**
  67946. * Converts the light information to a readable string for debug purpose.
  67947. * @param fullDetails Supports for multiple levels of logging within scene loading
  67948. * @returns the human readable light info
  67949. */
  67950. toString(fullDetails?: boolean): string;
  67951. /** @hidden */
  67952. protected _syncParentEnabledState(): void;
  67953. /**
  67954. * Set the enabled state of this node.
  67955. * @param value - the new enabled state
  67956. */
  67957. setEnabled(value: boolean): void;
  67958. /**
  67959. * Returns the Light associated shadow generator if any.
  67960. * @return the associated shadow generator.
  67961. */
  67962. getShadowGenerator(): Nullable<IShadowGenerator>;
  67963. /**
  67964. * Returns a Vector3, the absolute light position in the World.
  67965. * @returns the world space position of the light
  67966. */
  67967. getAbsolutePosition(): Vector3;
  67968. /**
  67969. * Specifies if the light will affect the passed mesh.
  67970. * @param mesh The mesh to test against the light
  67971. * @return true the mesh is affected otherwise, false.
  67972. */
  67973. canAffectMesh(mesh: AbstractMesh): boolean;
  67974. /**
  67975. * Sort function to order lights for rendering.
  67976. * @param a First Light object to compare to second.
  67977. * @param b Second Light object to compare first.
  67978. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67979. */
  67980. static CompareLightsPriority(a: Light, b: Light): number;
  67981. /**
  67982. * Releases resources associated with this node.
  67983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67985. */
  67986. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67987. /**
  67988. * Returns the light type ID (integer).
  67989. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67990. */
  67991. getTypeID(): number;
  67992. /**
  67993. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67994. * @returns the scaled intensity in intensity mode unit
  67995. */
  67996. getScaledIntensity(): number;
  67997. /**
  67998. * Returns a new Light object, named "name", from the current one.
  67999. * @param name The name of the cloned light
  68000. * @returns the new created light
  68001. */
  68002. clone(name: string): Nullable<Light>;
  68003. /**
  68004. * Serializes the current light into a Serialization object.
  68005. * @returns the serialized object.
  68006. */
  68007. serialize(): any;
  68008. /**
  68009. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68010. * This new light is named "name" and added to the passed scene.
  68011. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68012. * @param name The friendly name of the light
  68013. * @param scene The scene the new light will belong to
  68014. * @returns the constructor function
  68015. */
  68016. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68017. /**
  68018. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68019. * @param parsedLight The JSON representation of the light
  68020. * @param scene The scene to create the parsed light in
  68021. * @returns the created light after parsing
  68022. */
  68023. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68024. private _hookArrayForExcluded;
  68025. private _hookArrayForIncludedOnly;
  68026. private _resyncMeshes;
  68027. /**
  68028. * Forces the meshes to update their light related information in their rendering used effects
  68029. * @hidden Internal Use Only
  68030. */
  68031. _markMeshesAsLightDirty(): void;
  68032. /**
  68033. * Recomputes the cached photometric scale if needed.
  68034. */
  68035. private _computePhotometricScale;
  68036. /**
  68037. * Returns the Photometric Scale according to the light type and intensity mode.
  68038. */
  68039. private _getPhotometricScale;
  68040. /**
  68041. * Reorder the light in the scene according to their defined priority.
  68042. * @hidden Internal Use Only
  68043. */
  68044. _reorderLightsInScene(): void;
  68045. /**
  68046. * Prepares the list of defines specific to the light type.
  68047. * @param defines the list of defines
  68048. * @param lightIndex defines the index of the light for the effect
  68049. */
  68050. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68051. }
  68052. }
  68053. declare module BABYLON {
  68054. /**
  68055. * Interface used to define Action
  68056. */
  68057. export interface IAction {
  68058. /**
  68059. * Trigger for the action
  68060. */
  68061. trigger: number;
  68062. /** Options of the trigger */
  68063. triggerOptions: any;
  68064. /**
  68065. * Gets the trigger parameters
  68066. * @returns the trigger parameters
  68067. */
  68068. getTriggerParameter(): any;
  68069. /**
  68070. * Internal only - executes current action event
  68071. * @hidden
  68072. */
  68073. _executeCurrent(evt?: ActionEvent): void;
  68074. /**
  68075. * Serialize placeholder for child classes
  68076. * @param parent of child
  68077. * @returns the serialized object
  68078. */
  68079. serialize(parent: any): any;
  68080. /**
  68081. * Internal only
  68082. * @hidden
  68083. */
  68084. _prepare(): void;
  68085. /**
  68086. * Internal only - manager for action
  68087. * @hidden
  68088. */
  68089. _actionManager: AbstractActionManager;
  68090. }
  68091. /**
  68092. * The action to be carried out following a trigger
  68093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68094. */
  68095. export class Action implements IAction {
  68096. /** the trigger, with or without parameters, for the action */
  68097. triggerOptions: any;
  68098. /**
  68099. * Trigger for the action
  68100. */
  68101. trigger: number;
  68102. /**
  68103. * Internal only - manager for action
  68104. * @hidden
  68105. */
  68106. _actionManager: ActionManager;
  68107. private _nextActiveAction;
  68108. private _child;
  68109. private _condition?;
  68110. private _triggerParameter;
  68111. /**
  68112. * An event triggered prior to action being executed.
  68113. */
  68114. onBeforeExecuteObservable: Observable<Action>;
  68115. /**
  68116. * Creates a new Action
  68117. * @param triggerOptions the trigger, with or without parameters, for the action
  68118. * @param condition an optional determinant of action
  68119. */
  68120. constructor(
  68121. /** the trigger, with or without parameters, for the action */
  68122. triggerOptions: any, condition?: Condition);
  68123. /**
  68124. * Internal only
  68125. * @hidden
  68126. */
  68127. _prepare(): void;
  68128. /**
  68129. * Gets the trigger parameters
  68130. * @returns the trigger parameters
  68131. */
  68132. getTriggerParameter(): any;
  68133. /**
  68134. * Internal only - executes current action event
  68135. * @hidden
  68136. */
  68137. _executeCurrent(evt?: ActionEvent): void;
  68138. /**
  68139. * Execute placeholder for child classes
  68140. * @param evt optional action event
  68141. */
  68142. execute(evt?: ActionEvent): void;
  68143. /**
  68144. * Skips to next active action
  68145. */
  68146. skipToNextActiveAction(): void;
  68147. /**
  68148. * Adds action to chain of actions, may be a DoNothingAction
  68149. * @param action defines the next action to execute
  68150. * @returns The action passed in
  68151. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68152. */
  68153. then(action: Action): Action;
  68154. /**
  68155. * Internal only
  68156. * @hidden
  68157. */
  68158. _getProperty(propertyPath: string): string;
  68159. /**
  68160. * Internal only
  68161. * @hidden
  68162. */
  68163. _getEffectiveTarget(target: any, propertyPath: string): any;
  68164. /**
  68165. * Serialize placeholder for child classes
  68166. * @param parent of child
  68167. * @returns the serialized object
  68168. */
  68169. serialize(parent: any): any;
  68170. /**
  68171. * Internal only called by serialize
  68172. * @hidden
  68173. */
  68174. protected _serialize(serializedAction: any, parent?: any): any;
  68175. /**
  68176. * Internal only
  68177. * @hidden
  68178. */
  68179. static _SerializeValueAsString: (value: any) => string;
  68180. /**
  68181. * Internal only
  68182. * @hidden
  68183. */
  68184. static _GetTargetProperty: (target: Scene | Node) => {
  68185. name: string;
  68186. targetType: string;
  68187. value: string;
  68188. };
  68189. }
  68190. }
  68191. declare module BABYLON {
  68192. /**
  68193. * A Condition applied to an Action
  68194. */
  68195. export class Condition {
  68196. /**
  68197. * Internal only - manager for action
  68198. * @hidden
  68199. */
  68200. _actionManager: ActionManager;
  68201. /**
  68202. * Internal only
  68203. * @hidden
  68204. */
  68205. _evaluationId: number;
  68206. /**
  68207. * Internal only
  68208. * @hidden
  68209. */
  68210. _currentResult: boolean;
  68211. /**
  68212. * Creates a new Condition
  68213. * @param actionManager the manager of the action the condition is applied to
  68214. */
  68215. constructor(actionManager: ActionManager);
  68216. /**
  68217. * Check if the current condition is valid
  68218. * @returns a boolean
  68219. */
  68220. isValid(): boolean;
  68221. /**
  68222. * Internal only
  68223. * @hidden
  68224. */
  68225. _getProperty(propertyPath: string): string;
  68226. /**
  68227. * Internal only
  68228. * @hidden
  68229. */
  68230. _getEffectiveTarget(target: any, propertyPath: string): any;
  68231. /**
  68232. * Serialize placeholder for child classes
  68233. * @returns the serialized object
  68234. */
  68235. serialize(): any;
  68236. /**
  68237. * Internal only
  68238. * @hidden
  68239. */
  68240. protected _serialize(serializedCondition: any): any;
  68241. }
  68242. /**
  68243. * Defines specific conditional operators as extensions of Condition
  68244. */
  68245. export class ValueCondition extends Condition {
  68246. /** path to specify the property of the target the conditional operator uses */
  68247. propertyPath: string;
  68248. /** the value compared by the conditional operator against the current value of the property */
  68249. value: any;
  68250. /** the conditional operator, default ValueCondition.IsEqual */
  68251. operator: number;
  68252. /**
  68253. * Internal only
  68254. * @hidden
  68255. */
  68256. private static _IsEqual;
  68257. /**
  68258. * Internal only
  68259. * @hidden
  68260. */
  68261. private static _IsDifferent;
  68262. /**
  68263. * Internal only
  68264. * @hidden
  68265. */
  68266. private static _IsGreater;
  68267. /**
  68268. * Internal only
  68269. * @hidden
  68270. */
  68271. private static _IsLesser;
  68272. /**
  68273. * returns the number for IsEqual
  68274. */
  68275. static readonly IsEqual: number;
  68276. /**
  68277. * Returns the number for IsDifferent
  68278. */
  68279. static readonly IsDifferent: number;
  68280. /**
  68281. * Returns the number for IsGreater
  68282. */
  68283. static readonly IsGreater: number;
  68284. /**
  68285. * Returns the number for IsLesser
  68286. */
  68287. static readonly IsLesser: number;
  68288. /**
  68289. * Internal only The action manager for the condition
  68290. * @hidden
  68291. */
  68292. _actionManager: ActionManager;
  68293. /**
  68294. * Internal only
  68295. * @hidden
  68296. */
  68297. private _target;
  68298. /**
  68299. * Internal only
  68300. * @hidden
  68301. */
  68302. private _effectiveTarget;
  68303. /**
  68304. * Internal only
  68305. * @hidden
  68306. */
  68307. private _property;
  68308. /**
  68309. * Creates a new ValueCondition
  68310. * @param actionManager manager for the action the condition applies to
  68311. * @param target for the action
  68312. * @param propertyPath path to specify the property of the target the conditional operator uses
  68313. * @param value the value compared by the conditional operator against the current value of the property
  68314. * @param operator the conditional operator, default ValueCondition.IsEqual
  68315. */
  68316. constructor(actionManager: ActionManager, target: any,
  68317. /** path to specify the property of the target the conditional operator uses */
  68318. propertyPath: string,
  68319. /** the value compared by the conditional operator against the current value of the property */
  68320. value: any,
  68321. /** the conditional operator, default ValueCondition.IsEqual */
  68322. operator?: number);
  68323. /**
  68324. * Compares the given value with the property value for the specified conditional operator
  68325. * @returns the result of the comparison
  68326. */
  68327. isValid(): boolean;
  68328. /**
  68329. * Serialize the ValueCondition into a JSON compatible object
  68330. * @returns serialization object
  68331. */
  68332. serialize(): any;
  68333. /**
  68334. * Gets the name of the conditional operator for the ValueCondition
  68335. * @param operator the conditional operator
  68336. * @returns the name
  68337. */
  68338. static GetOperatorName(operator: number): string;
  68339. }
  68340. /**
  68341. * Defines a predicate condition as an extension of Condition
  68342. */
  68343. export class PredicateCondition extends Condition {
  68344. /** defines the predicate function used to validate the condition */
  68345. predicate: () => boolean;
  68346. /**
  68347. * Internal only - manager for action
  68348. * @hidden
  68349. */
  68350. _actionManager: ActionManager;
  68351. /**
  68352. * Creates a new PredicateCondition
  68353. * @param actionManager manager for the action the condition applies to
  68354. * @param predicate defines the predicate function used to validate the condition
  68355. */
  68356. constructor(actionManager: ActionManager,
  68357. /** defines the predicate function used to validate the condition */
  68358. predicate: () => boolean);
  68359. /**
  68360. * @returns the validity of the predicate condition
  68361. */
  68362. isValid(): boolean;
  68363. }
  68364. /**
  68365. * Defines a state condition as an extension of Condition
  68366. */
  68367. export class StateCondition extends Condition {
  68368. /** Value to compare with target state */
  68369. value: string;
  68370. /**
  68371. * Internal only - manager for action
  68372. * @hidden
  68373. */
  68374. _actionManager: ActionManager;
  68375. /**
  68376. * Internal only
  68377. * @hidden
  68378. */
  68379. private _target;
  68380. /**
  68381. * Creates a new StateCondition
  68382. * @param actionManager manager for the action the condition applies to
  68383. * @param target of the condition
  68384. * @param value to compare with target state
  68385. */
  68386. constructor(actionManager: ActionManager, target: any,
  68387. /** Value to compare with target state */
  68388. value: string);
  68389. /**
  68390. * Gets a boolean indicating if the current condition is met
  68391. * @returns the validity of the state
  68392. */
  68393. isValid(): boolean;
  68394. /**
  68395. * Serialize the StateCondition into a JSON compatible object
  68396. * @returns serialization object
  68397. */
  68398. serialize(): any;
  68399. }
  68400. }
  68401. declare module BABYLON {
  68402. /**
  68403. * This defines an action responsible to toggle a boolean once triggered.
  68404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68405. */
  68406. export class SwitchBooleanAction extends Action {
  68407. /**
  68408. * The path to the boolean property in the target object
  68409. */
  68410. propertyPath: string;
  68411. private _target;
  68412. private _effectiveTarget;
  68413. private _property;
  68414. /**
  68415. * Instantiate the action
  68416. * @param triggerOptions defines the trigger options
  68417. * @param target defines the object containing the boolean
  68418. * @param propertyPath defines the path to the boolean property in the target object
  68419. * @param condition defines the trigger related conditions
  68420. */
  68421. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68422. /** @hidden */
  68423. _prepare(): void;
  68424. /**
  68425. * Execute the action toggle the boolean value.
  68426. */
  68427. execute(): void;
  68428. /**
  68429. * Serializes the actions and its related information.
  68430. * @param parent defines the object to serialize in
  68431. * @returns the serialized object
  68432. */
  68433. serialize(parent: any): any;
  68434. }
  68435. /**
  68436. * This defines an action responsible to set a the state field of the target
  68437. * to a desired value once triggered.
  68438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68439. */
  68440. export class SetStateAction extends Action {
  68441. /**
  68442. * The value to store in the state field.
  68443. */
  68444. value: string;
  68445. private _target;
  68446. /**
  68447. * Instantiate the action
  68448. * @param triggerOptions defines the trigger options
  68449. * @param target defines the object containing the state property
  68450. * @param value defines the value to store in the state field
  68451. * @param condition defines the trigger related conditions
  68452. */
  68453. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68454. /**
  68455. * Execute the action and store the value on the target state property.
  68456. */
  68457. execute(): void;
  68458. /**
  68459. * Serializes the actions and its related information.
  68460. * @param parent defines the object to serialize in
  68461. * @returns the serialized object
  68462. */
  68463. serialize(parent: any): any;
  68464. }
  68465. /**
  68466. * This defines an action responsible to set a property of the target
  68467. * to a desired value once triggered.
  68468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68469. */
  68470. export class SetValueAction extends Action {
  68471. /**
  68472. * The path of the property to set in the target.
  68473. */
  68474. propertyPath: string;
  68475. /**
  68476. * The value to set in the property
  68477. */
  68478. value: any;
  68479. private _target;
  68480. private _effectiveTarget;
  68481. private _property;
  68482. /**
  68483. * Instantiate the action
  68484. * @param triggerOptions defines the trigger options
  68485. * @param target defines the object containing the property
  68486. * @param propertyPath defines the path of the property to set in the target
  68487. * @param value defines the value to set in the property
  68488. * @param condition defines the trigger related conditions
  68489. */
  68490. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68491. /** @hidden */
  68492. _prepare(): void;
  68493. /**
  68494. * Execute the action and set the targetted property to the desired value.
  68495. */
  68496. execute(): void;
  68497. /**
  68498. * Serializes the actions and its related information.
  68499. * @param parent defines the object to serialize in
  68500. * @returns the serialized object
  68501. */
  68502. serialize(parent: any): any;
  68503. }
  68504. /**
  68505. * This defines an action responsible to increment the target value
  68506. * to a desired value once triggered.
  68507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68508. */
  68509. export class IncrementValueAction extends Action {
  68510. /**
  68511. * The path of the property to increment in the target.
  68512. */
  68513. propertyPath: string;
  68514. /**
  68515. * The value we should increment the property by.
  68516. */
  68517. value: any;
  68518. private _target;
  68519. private _effectiveTarget;
  68520. private _property;
  68521. /**
  68522. * Instantiate the action
  68523. * @param triggerOptions defines the trigger options
  68524. * @param target defines the object containing the property
  68525. * @param propertyPath defines the path of the property to increment in the target
  68526. * @param value defines the value value we should increment the property by
  68527. * @param condition defines the trigger related conditions
  68528. */
  68529. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68530. /** @hidden */
  68531. _prepare(): void;
  68532. /**
  68533. * Execute the action and increment the target of the value amount.
  68534. */
  68535. execute(): void;
  68536. /**
  68537. * Serializes the actions and its related information.
  68538. * @param parent defines the object to serialize in
  68539. * @returns the serialized object
  68540. */
  68541. serialize(parent: any): any;
  68542. }
  68543. /**
  68544. * This defines an action responsible to start an animation once triggered.
  68545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68546. */
  68547. export class PlayAnimationAction extends Action {
  68548. /**
  68549. * Where the animation should start (animation frame)
  68550. */
  68551. from: number;
  68552. /**
  68553. * Where the animation should stop (animation frame)
  68554. */
  68555. to: number;
  68556. /**
  68557. * Define if the animation should loop or stop after the first play.
  68558. */
  68559. loop?: boolean;
  68560. private _target;
  68561. /**
  68562. * Instantiate the action
  68563. * @param triggerOptions defines the trigger options
  68564. * @param target defines the target animation or animation name
  68565. * @param from defines from where the animation should start (animation frame)
  68566. * @param end defines where the animation should stop (animation frame)
  68567. * @param loop defines if the animation should loop or stop after the first play
  68568. * @param condition defines the trigger related conditions
  68569. */
  68570. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68571. /** @hidden */
  68572. _prepare(): void;
  68573. /**
  68574. * Execute the action and play the animation.
  68575. */
  68576. execute(): void;
  68577. /**
  68578. * Serializes the actions and its related information.
  68579. * @param parent defines the object to serialize in
  68580. * @returns the serialized object
  68581. */
  68582. serialize(parent: any): any;
  68583. }
  68584. /**
  68585. * This defines an action responsible to stop an animation once triggered.
  68586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68587. */
  68588. export class StopAnimationAction extends Action {
  68589. private _target;
  68590. /**
  68591. * Instantiate the action
  68592. * @param triggerOptions defines the trigger options
  68593. * @param target defines the target animation or animation name
  68594. * @param condition defines the trigger related conditions
  68595. */
  68596. constructor(triggerOptions: any, target: any, condition?: Condition);
  68597. /** @hidden */
  68598. _prepare(): void;
  68599. /**
  68600. * Execute the action and stop the animation.
  68601. */
  68602. execute(): void;
  68603. /**
  68604. * Serializes the actions and its related information.
  68605. * @param parent defines the object to serialize in
  68606. * @returns the serialized object
  68607. */
  68608. serialize(parent: any): any;
  68609. }
  68610. /**
  68611. * This defines an action responsible that does nothing once triggered.
  68612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68613. */
  68614. export class DoNothingAction extends Action {
  68615. /**
  68616. * Instantiate the action
  68617. * @param triggerOptions defines the trigger options
  68618. * @param condition defines the trigger related conditions
  68619. */
  68620. constructor(triggerOptions?: any, condition?: Condition);
  68621. /**
  68622. * Execute the action and do nothing.
  68623. */
  68624. execute(): void;
  68625. /**
  68626. * Serializes the actions and its related information.
  68627. * @param parent defines the object to serialize in
  68628. * @returns the serialized object
  68629. */
  68630. serialize(parent: any): any;
  68631. }
  68632. /**
  68633. * This defines an action responsible to trigger several actions once triggered.
  68634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68635. */
  68636. export class CombineAction extends Action {
  68637. /**
  68638. * The list of aggregated animations to run.
  68639. */
  68640. children: Action[];
  68641. /**
  68642. * Instantiate the action
  68643. * @param triggerOptions defines the trigger options
  68644. * @param children defines the list of aggregated animations to run
  68645. * @param condition defines the trigger related conditions
  68646. */
  68647. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68648. /** @hidden */
  68649. _prepare(): void;
  68650. /**
  68651. * Execute the action and executes all the aggregated actions.
  68652. */
  68653. execute(evt: ActionEvent): void;
  68654. /**
  68655. * Serializes the actions and its related information.
  68656. * @param parent defines the object to serialize in
  68657. * @returns the serialized object
  68658. */
  68659. serialize(parent: any): any;
  68660. }
  68661. /**
  68662. * This defines an action responsible to run code (external event) once triggered.
  68663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68664. */
  68665. export class ExecuteCodeAction extends Action {
  68666. /**
  68667. * The callback function to run.
  68668. */
  68669. func: (evt: ActionEvent) => void;
  68670. /**
  68671. * Instantiate the action
  68672. * @param triggerOptions defines the trigger options
  68673. * @param func defines the callback function to run
  68674. * @param condition defines the trigger related conditions
  68675. */
  68676. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68677. /**
  68678. * Execute the action and run the attached code.
  68679. */
  68680. execute(evt: ActionEvent): void;
  68681. }
  68682. /**
  68683. * This defines an action responsible to set the parent property of the target once triggered.
  68684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68685. */
  68686. export class SetParentAction extends Action {
  68687. private _parent;
  68688. private _target;
  68689. /**
  68690. * Instantiate the action
  68691. * @param triggerOptions defines the trigger options
  68692. * @param target defines the target containing the parent property
  68693. * @param parent defines from where the animation should start (animation frame)
  68694. * @param condition defines the trigger related conditions
  68695. */
  68696. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68697. /** @hidden */
  68698. _prepare(): void;
  68699. /**
  68700. * Execute the action and set the parent property.
  68701. */
  68702. execute(): void;
  68703. /**
  68704. * Serializes the actions and its related information.
  68705. * @param parent defines the object to serialize in
  68706. * @returns the serialized object
  68707. */
  68708. serialize(parent: any): any;
  68709. }
  68710. }
  68711. declare module BABYLON {
  68712. /**
  68713. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68714. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68716. */
  68717. export class ActionManager extends AbstractActionManager {
  68718. /**
  68719. * Nothing
  68720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68721. */
  68722. static readonly NothingTrigger: number;
  68723. /**
  68724. * On pick
  68725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68726. */
  68727. static readonly OnPickTrigger: number;
  68728. /**
  68729. * On left pick
  68730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68731. */
  68732. static readonly OnLeftPickTrigger: number;
  68733. /**
  68734. * On right pick
  68735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68736. */
  68737. static readonly OnRightPickTrigger: number;
  68738. /**
  68739. * On center pick
  68740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68741. */
  68742. static readonly OnCenterPickTrigger: number;
  68743. /**
  68744. * On pick down
  68745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68746. */
  68747. static readonly OnPickDownTrigger: number;
  68748. /**
  68749. * On double pick
  68750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68751. */
  68752. static readonly OnDoublePickTrigger: number;
  68753. /**
  68754. * On pick up
  68755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68756. */
  68757. static readonly OnPickUpTrigger: number;
  68758. /**
  68759. * On pick out.
  68760. * This trigger will only be raised if you also declared a OnPickDown
  68761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68762. */
  68763. static readonly OnPickOutTrigger: number;
  68764. /**
  68765. * On long press
  68766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68767. */
  68768. static readonly OnLongPressTrigger: number;
  68769. /**
  68770. * On pointer over
  68771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68772. */
  68773. static readonly OnPointerOverTrigger: number;
  68774. /**
  68775. * On pointer out
  68776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68777. */
  68778. static readonly OnPointerOutTrigger: number;
  68779. /**
  68780. * On every frame
  68781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68782. */
  68783. static readonly OnEveryFrameTrigger: number;
  68784. /**
  68785. * On intersection enter
  68786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68787. */
  68788. static readonly OnIntersectionEnterTrigger: number;
  68789. /**
  68790. * On intersection exit
  68791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68792. */
  68793. static readonly OnIntersectionExitTrigger: number;
  68794. /**
  68795. * On key down
  68796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68797. */
  68798. static readonly OnKeyDownTrigger: number;
  68799. /**
  68800. * On key up
  68801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68802. */
  68803. static readonly OnKeyUpTrigger: number;
  68804. private _scene;
  68805. /**
  68806. * Creates a new action manager
  68807. * @param scene defines the hosting scene
  68808. */
  68809. constructor(scene: Scene);
  68810. /**
  68811. * Releases all associated resources
  68812. */
  68813. dispose(): void;
  68814. /**
  68815. * Gets hosting scene
  68816. * @returns the hosting scene
  68817. */
  68818. getScene(): Scene;
  68819. /**
  68820. * Does this action manager handles actions of any of the given triggers
  68821. * @param triggers defines the triggers to be tested
  68822. * @return a boolean indicating whether one (or more) of the triggers is handled
  68823. */
  68824. hasSpecificTriggers(triggers: number[]): boolean;
  68825. /**
  68826. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68827. * speed.
  68828. * @param triggerA defines the trigger to be tested
  68829. * @param triggerB defines the trigger to be tested
  68830. * @return a boolean indicating whether one (or more) of the triggers is handled
  68831. */
  68832. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68833. /**
  68834. * Does this action manager handles actions of a given trigger
  68835. * @param trigger defines the trigger to be tested
  68836. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68837. * @return whether the trigger is handled
  68838. */
  68839. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68840. /**
  68841. * Does this action manager has pointer triggers
  68842. */
  68843. readonly hasPointerTriggers: boolean;
  68844. /**
  68845. * Does this action manager has pick triggers
  68846. */
  68847. readonly hasPickTriggers: boolean;
  68848. /**
  68849. * Registers an action to this action manager
  68850. * @param action defines the action to be registered
  68851. * @return the action amended (prepared) after registration
  68852. */
  68853. registerAction(action: IAction): Nullable<IAction>;
  68854. /**
  68855. * Unregisters an action to this action manager
  68856. * @param action defines the action to be unregistered
  68857. * @return a boolean indicating whether the action has been unregistered
  68858. */
  68859. unregisterAction(action: IAction): Boolean;
  68860. /**
  68861. * Process a specific trigger
  68862. * @param trigger defines the trigger to process
  68863. * @param evt defines the event details to be processed
  68864. */
  68865. processTrigger(trigger: number, evt?: IActionEvent): void;
  68866. /** @hidden */
  68867. _getEffectiveTarget(target: any, propertyPath: string): any;
  68868. /** @hidden */
  68869. _getProperty(propertyPath: string): string;
  68870. /**
  68871. * Serialize this manager to a JSON object
  68872. * @param name defines the property name to store this manager
  68873. * @returns a JSON representation of this manager
  68874. */
  68875. serialize(name: string): any;
  68876. /**
  68877. * Creates a new ActionManager from a JSON data
  68878. * @param parsedActions defines the JSON data to read from
  68879. * @param object defines the hosting mesh
  68880. * @param scene defines the hosting scene
  68881. */
  68882. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68883. /**
  68884. * Get a trigger name by index
  68885. * @param trigger defines the trigger index
  68886. * @returns a trigger name
  68887. */
  68888. static GetTriggerName(trigger: number): string;
  68889. }
  68890. }
  68891. declare module BABYLON {
  68892. /**
  68893. * Class representing a ray with position and direction
  68894. */
  68895. export class Ray {
  68896. /** origin point */
  68897. origin: Vector3;
  68898. /** direction */
  68899. direction: Vector3;
  68900. /** length of the ray */
  68901. length: number;
  68902. private static readonly TmpVector3;
  68903. private _tmpRay;
  68904. /**
  68905. * Creates a new ray
  68906. * @param origin origin point
  68907. * @param direction direction
  68908. * @param length length of the ray
  68909. */
  68910. constructor(
  68911. /** origin point */
  68912. origin: Vector3,
  68913. /** direction */
  68914. direction: Vector3,
  68915. /** length of the ray */
  68916. length?: number);
  68917. /**
  68918. * Checks if the ray intersects a box
  68919. * @param minimum bound of the box
  68920. * @param maximum bound of the box
  68921. * @param intersectionTreshold extra extend to be added to the box in all direction
  68922. * @returns if the box was hit
  68923. */
  68924. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68925. /**
  68926. * Checks if the ray intersects a box
  68927. * @param box the bounding box to check
  68928. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68929. * @returns if the box was hit
  68930. */
  68931. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68932. /**
  68933. * If the ray hits a sphere
  68934. * @param sphere the bounding sphere to check
  68935. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68936. * @returns true if it hits the sphere
  68937. */
  68938. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68939. /**
  68940. * If the ray hits a triange
  68941. * @param vertex0 triangle vertex
  68942. * @param vertex1 triangle vertex
  68943. * @param vertex2 triangle vertex
  68944. * @returns intersection information if hit
  68945. */
  68946. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68947. /**
  68948. * Checks if ray intersects a plane
  68949. * @param plane the plane to check
  68950. * @returns the distance away it was hit
  68951. */
  68952. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68953. /**
  68954. * Checks if ray intersects a mesh
  68955. * @param mesh the mesh to check
  68956. * @param fastCheck if only the bounding box should checked
  68957. * @returns picking info of the intersecton
  68958. */
  68959. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68960. /**
  68961. * Checks if ray intersects a mesh
  68962. * @param meshes the meshes to check
  68963. * @param fastCheck if only the bounding box should checked
  68964. * @param results array to store result in
  68965. * @returns Array of picking infos
  68966. */
  68967. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68968. private _comparePickingInfo;
  68969. private static smallnum;
  68970. private static rayl;
  68971. /**
  68972. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68973. * @param sega the first point of the segment to test the intersection against
  68974. * @param segb the second point of the segment to test the intersection against
  68975. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68976. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68977. */
  68978. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68979. /**
  68980. * Update the ray from viewport position
  68981. * @param x position
  68982. * @param y y position
  68983. * @param viewportWidth viewport width
  68984. * @param viewportHeight viewport height
  68985. * @param world world matrix
  68986. * @param view view matrix
  68987. * @param projection projection matrix
  68988. * @returns this ray updated
  68989. */
  68990. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68991. /**
  68992. * Creates a ray with origin and direction of 0,0,0
  68993. * @returns the new ray
  68994. */
  68995. static Zero(): Ray;
  68996. /**
  68997. * Creates a new ray from screen space and viewport
  68998. * @param x position
  68999. * @param y y position
  69000. * @param viewportWidth viewport width
  69001. * @param viewportHeight viewport height
  69002. * @param world world matrix
  69003. * @param view view matrix
  69004. * @param projection projection matrix
  69005. * @returns new ray
  69006. */
  69007. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69008. /**
  69009. * 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
  69010. * transformed to the given world matrix.
  69011. * @param origin The origin point
  69012. * @param end The end point
  69013. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69014. * @returns the new ray
  69015. */
  69016. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69017. /**
  69018. * Transforms a ray by a matrix
  69019. * @param ray ray to transform
  69020. * @param matrix matrix to apply
  69021. * @returns the resulting new ray
  69022. */
  69023. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69024. /**
  69025. * Transforms a ray by a matrix
  69026. * @param ray ray to transform
  69027. * @param matrix matrix to apply
  69028. * @param result ray to store result in
  69029. */
  69030. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69031. /**
  69032. * Unproject a ray from screen space to object space
  69033. * @param sourceX defines the screen space x coordinate to use
  69034. * @param sourceY defines the screen space y coordinate to use
  69035. * @param viewportWidth defines the current width of the viewport
  69036. * @param viewportHeight defines the current height of the viewport
  69037. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69038. * @param view defines the view matrix to use
  69039. * @param projection defines the projection matrix to use
  69040. */
  69041. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69042. }
  69043. /**
  69044. * Type used to define predicate used to select faces when a mesh intersection is detected
  69045. */
  69046. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69047. interface Scene {
  69048. /** @hidden */
  69049. _tempPickingRay: Nullable<Ray>;
  69050. /** @hidden */
  69051. _cachedRayForTransform: Ray;
  69052. /** @hidden */
  69053. _pickWithRayInverseMatrix: Matrix;
  69054. /** @hidden */
  69055. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69056. /** @hidden */
  69057. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69058. }
  69059. }
  69060. declare module BABYLON {
  69061. /**
  69062. * Groups all the scene component constants in one place to ease maintenance.
  69063. * @hidden
  69064. */
  69065. export class SceneComponentConstants {
  69066. static readonly NAME_EFFECTLAYER: string;
  69067. static readonly NAME_LAYER: string;
  69068. static readonly NAME_LENSFLARESYSTEM: string;
  69069. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69070. static readonly NAME_PARTICLESYSTEM: string;
  69071. static readonly NAME_GAMEPAD: string;
  69072. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69073. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69074. static readonly NAME_DEPTHRENDERER: string;
  69075. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69076. static readonly NAME_SPRITE: string;
  69077. static readonly NAME_OUTLINERENDERER: string;
  69078. static readonly NAME_PROCEDURALTEXTURE: string;
  69079. static readonly NAME_SHADOWGENERATOR: string;
  69080. static readonly NAME_OCTREE: string;
  69081. static readonly NAME_PHYSICSENGINE: string;
  69082. static readonly NAME_AUDIO: string;
  69083. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69084. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69085. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69086. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69087. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69088. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69089. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69090. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69091. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69092. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69093. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69094. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69095. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69096. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69097. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69098. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69099. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69100. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69101. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69102. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69103. static readonly STEP_AFTERRENDER_AUDIO: number;
  69104. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69105. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69106. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69107. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69108. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69109. static readonly STEP_POINTERMOVE_SPRITE: number;
  69110. static readonly STEP_POINTERDOWN_SPRITE: number;
  69111. static readonly STEP_POINTERUP_SPRITE: number;
  69112. }
  69113. /**
  69114. * This represents a scene component.
  69115. *
  69116. * This is used to decouple the dependency the scene is having on the different workloads like
  69117. * layers, post processes...
  69118. */
  69119. export interface ISceneComponent {
  69120. /**
  69121. * The name of the component. Each component must have a unique name.
  69122. */
  69123. name: string;
  69124. /**
  69125. * The scene the component belongs to.
  69126. */
  69127. scene: Scene;
  69128. /**
  69129. * Register the component to one instance of a scene.
  69130. */
  69131. register(): void;
  69132. /**
  69133. * Rebuilds the elements related to this component in case of
  69134. * context lost for instance.
  69135. */
  69136. rebuild(): void;
  69137. /**
  69138. * Disposes the component and the associated ressources.
  69139. */
  69140. dispose(): void;
  69141. }
  69142. /**
  69143. * This represents a SERIALIZABLE scene component.
  69144. *
  69145. * This extends Scene Component to add Serialization methods on top.
  69146. */
  69147. export interface ISceneSerializableComponent extends ISceneComponent {
  69148. /**
  69149. * Adds all the element from the container to the scene
  69150. * @param container the container holding the elements
  69151. */
  69152. addFromContainer(container: AbstractScene): void;
  69153. /**
  69154. * Removes all the elements in the container from the scene
  69155. * @param container contains the elements to remove
  69156. */
  69157. removeFromContainer(container: AbstractScene): void;
  69158. /**
  69159. * Serializes the component data to the specified json object
  69160. * @param serializationObject The object to serialize to
  69161. */
  69162. serialize(serializationObject: any): void;
  69163. }
  69164. /**
  69165. * Strong typing of a Mesh related stage step action
  69166. */
  69167. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69168. /**
  69169. * Strong typing of a Evaluate Sub Mesh related stage step action
  69170. */
  69171. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69172. /**
  69173. * Strong typing of a Active Mesh related stage step action
  69174. */
  69175. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69176. /**
  69177. * Strong typing of a Camera related stage step action
  69178. */
  69179. export type CameraStageAction = (camera: Camera) => void;
  69180. /**
  69181. * Strong typing of a Render Target related stage step action
  69182. */
  69183. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69184. /**
  69185. * Strong typing of a RenderingGroup related stage step action
  69186. */
  69187. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69188. /**
  69189. * Strong typing of a Mesh Render related stage step action
  69190. */
  69191. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69192. /**
  69193. * Strong typing of a simple stage step action
  69194. */
  69195. export type SimpleStageAction = () => void;
  69196. /**
  69197. * Strong typing of a render target action.
  69198. */
  69199. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69200. /**
  69201. * Strong typing of a pointer move action.
  69202. */
  69203. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69204. /**
  69205. * Strong typing of a pointer up/down action.
  69206. */
  69207. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69208. /**
  69209. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69210. * @hidden
  69211. */
  69212. export class Stage<T extends Function> extends Array<{
  69213. index: number;
  69214. component: ISceneComponent;
  69215. action: T;
  69216. }> {
  69217. /**
  69218. * Hide ctor from the rest of the world.
  69219. * @param items The items to add.
  69220. */
  69221. private constructor();
  69222. /**
  69223. * Creates a new Stage.
  69224. * @returns A new instance of a Stage
  69225. */
  69226. static Create<T extends Function>(): Stage<T>;
  69227. /**
  69228. * Registers a step in an ordered way in the targeted stage.
  69229. * @param index Defines the position to register the step in
  69230. * @param component Defines the component attached to the step
  69231. * @param action Defines the action to launch during the step
  69232. */
  69233. registerStep(index: number, component: ISceneComponent, action: T): void;
  69234. /**
  69235. * Clears all the steps from the stage.
  69236. */
  69237. clear(): void;
  69238. }
  69239. }
  69240. declare module BABYLON {
  69241. interface Scene {
  69242. /** @hidden */
  69243. _pointerOverSprite: Nullable<Sprite>;
  69244. /** @hidden */
  69245. _pickedDownSprite: Nullable<Sprite>;
  69246. /** @hidden */
  69247. _tempSpritePickingRay: Nullable<Ray>;
  69248. /**
  69249. * All of the sprite managers added to this scene
  69250. * @see http://doc.babylonjs.com/babylon101/sprites
  69251. */
  69252. spriteManagers: Array<ISpriteManager>;
  69253. /**
  69254. * An event triggered when sprites rendering is about to start
  69255. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69256. */
  69257. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69258. /**
  69259. * An event triggered when sprites rendering is done
  69260. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69261. */
  69262. onAfterSpritesRenderingObservable: Observable<Scene>;
  69263. /** @hidden */
  69264. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69265. /** Launch a ray to try to pick a sprite in the scene
  69266. * @param x position on screen
  69267. * @param y position on screen
  69268. * @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
  69269. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69270. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69271. * @returns a PickingInfo
  69272. */
  69273. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69274. /** Use the given ray to pick a sprite in the scene
  69275. * @param ray The ray (in world space) to use to pick meshes
  69276. * @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
  69277. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69278. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69279. * @returns a PickingInfo
  69280. */
  69281. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69282. /**
  69283. * Force the sprite under the pointer
  69284. * @param sprite defines the sprite to use
  69285. */
  69286. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69287. /**
  69288. * Gets the sprite under the pointer
  69289. * @returns a Sprite or null if no sprite is under the pointer
  69290. */
  69291. getPointerOverSprite(): Nullable<Sprite>;
  69292. }
  69293. /**
  69294. * Defines the sprite scene component responsible to manage sprites
  69295. * in a given scene.
  69296. */
  69297. export class SpriteSceneComponent implements ISceneComponent {
  69298. /**
  69299. * The component name helpfull to identify the component in the list of scene components.
  69300. */
  69301. readonly name: string;
  69302. /**
  69303. * The scene the component belongs to.
  69304. */
  69305. scene: Scene;
  69306. /** @hidden */
  69307. private _spritePredicate;
  69308. /**
  69309. * Creates a new instance of the component for the given scene
  69310. * @param scene Defines the scene to register the component in
  69311. */
  69312. constructor(scene: Scene);
  69313. /**
  69314. * Registers the component in a given scene
  69315. */
  69316. register(): void;
  69317. /**
  69318. * Rebuilds the elements related to this component in case of
  69319. * context lost for instance.
  69320. */
  69321. rebuild(): void;
  69322. /**
  69323. * Disposes the component and the associated ressources.
  69324. */
  69325. dispose(): void;
  69326. private _pickSpriteButKeepRay;
  69327. private _pointerMove;
  69328. private _pointerDown;
  69329. private _pointerUp;
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /** @hidden */
  69334. export var fogFragmentDeclaration: {
  69335. name: string;
  69336. shader: string;
  69337. };
  69338. }
  69339. declare module BABYLON {
  69340. /** @hidden */
  69341. export var fogFragment: {
  69342. name: string;
  69343. shader: string;
  69344. };
  69345. }
  69346. declare module BABYLON {
  69347. /** @hidden */
  69348. export var spritesPixelShader: {
  69349. name: string;
  69350. shader: string;
  69351. };
  69352. }
  69353. declare module BABYLON {
  69354. /** @hidden */
  69355. export var fogVertexDeclaration: {
  69356. name: string;
  69357. shader: string;
  69358. };
  69359. }
  69360. declare module BABYLON {
  69361. /** @hidden */
  69362. export var spritesVertexShader: {
  69363. name: string;
  69364. shader: string;
  69365. };
  69366. }
  69367. declare module BABYLON {
  69368. /**
  69369. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69370. */
  69371. export interface ISpriteManager extends IDisposable {
  69372. /**
  69373. * Restricts the camera to viewing objects with the same layerMask.
  69374. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69375. */
  69376. layerMask: number;
  69377. /**
  69378. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69379. */
  69380. isPickable: boolean;
  69381. /**
  69382. * Specifies the rendering group id for this mesh (0 by default)
  69383. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69384. */
  69385. renderingGroupId: number;
  69386. /**
  69387. * Defines the list of sprites managed by the manager.
  69388. */
  69389. sprites: Array<Sprite>;
  69390. /**
  69391. * Tests the intersection of a sprite with a specific ray.
  69392. * @param ray The ray we are sending to test the collision
  69393. * @param camera The camera space we are sending rays in
  69394. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69395. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69396. * @returns picking info or null.
  69397. */
  69398. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69399. /**
  69400. * Renders the list of sprites on screen.
  69401. */
  69402. render(): void;
  69403. }
  69404. /**
  69405. * Class used to manage multiple sprites on the same spritesheet
  69406. * @see http://doc.babylonjs.com/babylon101/sprites
  69407. */
  69408. export class SpriteManager implements ISpriteManager {
  69409. /** defines the manager's name */
  69410. name: string;
  69411. /** Gets the list of sprites */
  69412. sprites: Sprite[];
  69413. /** Gets or sets the rendering group id (0 by default) */
  69414. renderingGroupId: number;
  69415. /** Gets or sets camera layer mask */
  69416. layerMask: number;
  69417. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69418. fogEnabled: boolean;
  69419. /** Gets or sets a boolean indicating if the sprites are pickable */
  69420. isPickable: boolean;
  69421. /** Defines the default width of a cell in the spritesheet */
  69422. cellWidth: number;
  69423. /** Defines the default height of a cell in the spritesheet */
  69424. cellHeight: number;
  69425. /**
  69426. * An event triggered when the manager is disposed.
  69427. */
  69428. onDisposeObservable: Observable<SpriteManager>;
  69429. private _onDisposeObserver;
  69430. /**
  69431. * Callback called when the manager is disposed
  69432. */
  69433. onDispose: () => void;
  69434. private _capacity;
  69435. private _spriteTexture;
  69436. private _epsilon;
  69437. private _scene;
  69438. private _vertexData;
  69439. private _buffer;
  69440. private _vertexBuffers;
  69441. private _indexBuffer;
  69442. private _effectBase;
  69443. private _effectFog;
  69444. /**
  69445. * Gets or sets the spritesheet texture
  69446. */
  69447. texture: Texture;
  69448. /**
  69449. * Creates a new sprite manager
  69450. * @param name defines the manager's name
  69451. * @param imgUrl defines the sprite sheet url
  69452. * @param capacity defines the maximum allowed number of sprites
  69453. * @param cellSize defines the size of a sprite cell
  69454. * @param scene defines the hosting scene
  69455. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69456. * @param samplingMode defines the smapling mode to use with spritesheet
  69457. */
  69458. constructor(
  69459. /** defines the manager's name */
  69460. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69461. private _appendSpriteVertex;
  69462. /**
  69463. * Intersects the sprites with a ray
  69464. * @param ray defines the ray to intersect with
  69465. * @param camera defines the current active camera
  69466. * @param predicate defines a predicate used to select candidate sprites
  69467. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69468. * @returns null if no hit or a PickingInfo
  69469. */
  69470. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69471. /**
  69472. * Render all child sprites
  69473. */
  69474. render(): void;
  69475. /**
  69476. * Release associated resources
  69477. */
  69478. dispose(): void;
  69479. }
  69480. }
  69481. declare module BABYLON {
  69482. /**
  69483. * Class used to represent a sprite
  69484. * @see http://doc.babylonjs.com/babylon101/sprites
  69485. */
  69486. export class Sprite {
  69487. /** defines the name */
  69488. name: string;
  69489. /** Gets or sets the current world position */
  69490. position: Vector3;
  69491. /** Gets or sets the main color */
  69492. color: Color4;
  69493. /** Gets or sets the width */
  69494. width: number;
  69495. /** Gets or sets the height */
  69496. height: number;
  69497. /** Gets or sets rotation angle */
  69498. angle: number;
  69499. /** Gets or sets the cell index in the sprite sheet */
  69500. cellIndex: number;
  69501. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69502. invertU: number;
  69503. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69504. invertV: number;
  69505. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69506. disposeWhenFinishedAnimating: boolean;
  69507. /** Gets the list of attached animations */
  69508. animations: Animation[];
  69509. /** Gets or sets a boolean indicating if the sprite can be picked */
  69510. isPickable: boolean;
  69511. /**
  69512. * Gets or sets the associated action manager
  69513. */
  69514. actionManager: Nullable<ActionManager>;
  69515. private _animationStarted;
  69516. private _loopAnimation;
  69517. private _fromIndex;
  69518. private _toIndex;
  69519. private _delay;
  69520. private _direction;
  69521. private _manager;
  69522. private _time;
  69523. private _onAnimationEnd;
  69524. /**
  69525. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69526. */
  69527. isVisible: boolean;
  69528. /**
  69529. * Gets or sets the sprite size
  69530. */
  69531. size: number;
  69532. /**
  69533. * Creates a new Sprite
  69534. * @param name defines the name
  69535. * @param manager defines the manager
  69536. */
  69537. constructor(
  69538. /** defines the name */
  69539. name: string, manager: ISpriteManager);
  69540. /**
  69541. * Starts an animation
  69542. * @param from defines the initial key
  69543. * @param to defines the end key
  69544. * @param loop defines if the animation must loop
  69545. * @param delay defines the start delay (in ms)
  69546. * @param onAnimationEnd defines a callback to call when animation ends
  69547. */
  69548. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69549. /** Stops current animation (if any) */
  69550. stopAnimation(): void;
  69551. /** @hidden */
  69552. _animate(deltaTime: number): void;
  69553. /** Release associated resources */
  69554. dispose(): void;
  69555. }
  69556. }
  69557. declare module BABYLON {
  69558. /**
  69559. * Information about the result of picking within a scene
  69560. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69561. */
  69562. export class PickingInfo {
  69563. /** @hidden */
  69564. _pickingUnavailable: boolean;
  69565. /**
  69566. * If the pick collided with an object
  69567. */
  69568. hit: boolean;
  69569. /**
  69570. * Distance away where the pick collided
  69571. */
  69572. distance: number;
  69573. /**
  69574. * The location of pick collision
  69575. */
  69576. pickedPoint: Nullable<Vector3>;
  69577. /**
  69578. * The mesh corresponding the the pick collision
  69579. */
  69580. pickedMesh: Nullable<AbstractMesh>;
  69581. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69582. bu: number;
  69583. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69584. bv: number;
  69585. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69586. faceId: number;
  69587. /** Id of the the submesh that was picked */
  69588. subMeshId: number;
  69589. /** If a sprite was picked, this will be the sprite the pick collided with */
  69590. pickedSprite: Nullable<Sprite>;
  69591. /**
  69592. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69593. */
  69594. originMesh: Nullable<AbstractMesh>;
  69595. /**
  69596. * The ray that was used to perform the picking.
  69597. */
  69598. ray: Nullable<Ray>;
  69599. /**
  69600. * Gets the normal correspodning to the face the pick collided with
  69601. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69602. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69603. * @returns The normal correspodning to the face the pick collided with
  69604. */
  69605. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69606. /**
  69607. * Gets the texture coordinates of where the pick occured
  69608. * @returns the vector containing the coordnates of the texture
  69609. */
  69610. getTextureCoordinates(): Nullable<Vector2>;
  69611. }
  69612. }
  69613. declare module BABYLON {
  69614. /**
  69615. * Gather the list of pointer event types as constants.
  69616. */
  69617. export class PointerEventTypes {
  69618. /**
  69619. * 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.
  69620. */
  69621. static readonly POINTERDOWN: number;
  69622. /**
  69623. * The pointerup event is fired when a pointer is no longer active.
  69624. */
  69625. static readonly POINTERUP: number;
  69626. /**
  69627. * The pointermove event is fired when a pointer changes coordinates.
  69628. */
  69629. static readonly POINTERMOVE: number;
  69630. /**
  69631. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69632. */
  69633. static readonly POINTERWHEEL: number;
  69634. /**
  69635. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69636. */
  69637. static readonly POINTERPICK: number;
  69638. /**
  69639. * The pointertap event is fired when a the object has been touched and released without drag.
  69640. */
  69641. static readonly POINTERTAP: number;
  69642. /**
  69643. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69644. */
  69645. static readonly POINTERDOUBLETAP: number;
  69646. }
  69647. /**
  69648. * Base class of pointer info types.
  69649. */
  69650. export class PointerInfoBase {
  69651. /**
  69652. * Defines the type of event (PointerEventTypes)
  69653. */
  69654. type: number;
  69655. /**
  69656. * Defines the related dom event
  69657. */
  69658. event: PointerEvent | MouseWheelEvent;
  69659. /**
  69660. * Instantiates the base class of pointers info.
  69661. * @param type Defines the type of event (PointerEventTypes)
  69662. * @param event Defines the related dom event
  69663. */
  69664. constructor(
  69665. /**
  69666. * Defines the type of event (PointerEventTypes)
  69667. */
  69668. type: number,
  69669. /**
  69670. * Defines the related dom event
  69671. */
  69672. event: PointerEvent | MouseWheelEvent);
  69673. }
  69674. /**
  69675. * This class is used to store pointer related info for the onPrePointerObservable event.
  69676. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69677. */
  69678. export class PointerInfoPre extends PointerInfoBase {
  69679. /**
  69680. * Ray from a pointer if availible (eg. 6dof controller)
  69681. */
  69682. ray: Nullable<Ray>;
  69683. /**
  69684. * Defines the local position of the pointer on the canvas.
  69685. */
  69686. localPosition: Vector2;
  69687. /**
  69688. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69689. */
  69690. skipOnPointerObservable: boolean;
  69691. /**
  69692. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69693. * @param type Defines the type of event (PointerEventTypes)
  69694. * @param event Defines the related dom event
  69695. * @param localX Defines the local x coordinates of the pointer when the event occured
  69696. * @param localY Defines the local y coordinates of the pointer when the event occured
  69697. */
  69698. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69699. }
  69700. /**
  69701. * This type contains all the data related to a pointer event in Babylon.js.
  69702. * 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.
  69703. */
  69704. export class PointerInfo extends PointerInfoBase {
  69705. /**
  69706. * Defines the picking info associated to the info (if any)\
  69707. */
  69708. pickInfo: Nullable<PickingInfo>;
  69709. /**
  69710. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69711. * @param type Defines the type of event (PointerEventTypes)
  69712. * @param event Defines the related dom event
  69713. * @param pickInfo Defines the picking info associated to the info (if any)\
  69714. */
  69715. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69716. /**
  69717. * Defines the picking info associated to the info (if any)\
  69718. */
  69719. pickInfo: Nullable<PickingInfo>);
  69720. }
  69721. /**
  69722. * Data relating to a touch event on the screen.
  69723. */
  69724. export interface PointerTouch {
  69725. /**
  69726. * X coordinate of touch.
  69727. */
  69728. x: number;
  69729. /**
  69730. * Y coordinate of touch.
  69731. */
  69732. y: number;
  69733. /**
  69734. * Id of touch. Unique for each finger.
  69735. */
  69736. pointerId: number;
  69737. /**
  69738. * Event type passed from DOM.
  69739. */
  69740. type: any;
  69741. }
  69742. }
  69743. declare module BABYLON {
  69744. /**
  69745. * Manage the mouse inputs to control the movement of a free camera.
  69746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69747. */
  69748. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69749. /**
  69750. * Define if touch is enabled in the mouse input
  69751. */
  69752. touchEnabled: boolean;
  69753. /**
  69754. * Defines the camera the input is attached to.
  69755. */
  69756. camera: FreeCamera;
  69757. /**
  69758. * Defines the buttons associated with the input to handle camera move.
  69759. */
  69760. buttons: number[];
  69761. /**
  69762. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69763. */
  69764. angularSensibility: number;
  69765. private _pointerInput;
  69766. private _onMouseMove;
  69767. private _observer;
  69768. private previousPosition;
  69769. /**
  69770. * Manage the mouse inputs to control the movement of a free camera.
  69771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69772. * @param touchEnabled Defines if touch is enabled or not
  69773. */
  69774. constructor(
  69775. /**
  69776. * Define if touch is enabled in the mouse input
  69777. */
  69778. touchEnabled?: boolean);
  69779. /**
  69780. * Attach the input controls to a specific dom element to get the input from.
  69781. * @param element Defines the element the controls should be listened from
  69782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69783. */
  69784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69785. /**
  69786. * Called on JS contextmenu event.
  69787. * Override this method to provide functionality.
  69788. */
  69789. protected onContextMenu(evt: PointerEvent): void;
  69790. /**
  69791. * Detach the current controls from the specified dom element.
  69792. * @param element Defines the element to stop listening the inputs from
  69793. */
  69794. detachControl(element: Nullable<HTMLElement>): void;
  69795. /**
  69796. * Gets the class name of the current intput.
  69797. * @returns the class name
  69798. */
  69799. getClassName(): string;
  69800. /**
  69801. * Get the friendly name associated with the input class.
  69802. * @returns the input friendly name
  69803. */
  69804. getSimpleName(): string;
  69805. }
  69806. }
  69807. declare module BABYLON {
  69808. /**
  69809. * Manage the touch inputs to control the movement of a free camera.
  69810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69811. */
  69812. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69813. /**
  69814. * Defines the camera the input is attached to.
  69815. */
  69816. camera: FreeCamera;
  69817. /**
  69818. * Defines the touch sensibility for rotation.
  69819. * The higher the faster.
  69820. */
  69821. touchAngularSensibility: number;
  69822. /**
  69823. * Defines the touch sensibility for move.
  69824. * The higher the faster.
  69825. */
  69826. touchMoveSensibility: number;
  69827. private _offsetX;
  69828. private _offsetY;
  69829. private _pointerPressed;
  69830. private _pointerInput;
  69831. private _observer;
  69832. private _onLostFocus;
  69833. /**
  69834. * Attach the input controls to a specific dom element to get the input from.
  69835. * @param element Defines the element the controls should be listened from
  69836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69837. */
  69838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69839. /**
  69840. * Detach the current controls from the specified dom element.
  69841. * @param element Defines the element to stop listening the inputs from
  69842. */
  69843. detachControl(element: Nullable<HTMLElement>): void;
  69844. /**
  69845. * Update the current camera state depending on the inputs that have been used this frame.
  69846. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69847. */
  69848. checkInputs(): void;
  69849. /**
  69850. * Gets the class name of the current intput.
  69851. * @returns the class name
  69852. */
  69853. getClassName(): string;
  69854. /**
  69855. * Get the friendly name associated with the input class.
  69856. * @returns the input friendly name
  69857. */
  69858. getSimpleName(): string;
  69859. }
  69860. }
  69861. declare module BABYLON {
  69862. /**
  69863. * Default Inputs manager for the FreeCamera.
  69864. * It groups all the default supported inputs for ease of use.
  69865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69866. */
  69867. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69868. /**
  69869. * Instantiates a new FreeCameraInputsManager.
  69870. * @param camera Defines the camera the inputs belong to
  69871. */
  69872. constructor(camera: FreeCamera);
  69873. /**
  69874. * Add keyboard input support to the input manager.
  69875. * @returns the current input manager
  69876. */
  69877. addKeyboard(): FreeCameraInputsManager;
  69878. /**
  69879. * Add mouse input support to the input manager.
  69880. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69881. * @returns the current input manager
  69882. */
  69883. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69884. /**
  69885. * Add touch input support to the input manager.
  69886. * @returns the current input manager
  69887. */
  69888. addTouch(): FreeCameraInputsManager;
  69889. }
  69890. }
  69891. declare module BABYLON {
  69892. /**
  69893. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69894. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69895. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69896. */
  69897. export class FreeCamera extends TargetCamera {
  69898. /**
  69899. * Define the collision ellipsoid of the camera.
  69900. * This is helpful to simulate a camera body like the player body around the camera
  69901. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69902. */
  69903. ellipsoid: Vector3;
  69904. /**
  69905. * Define an offset for the position of the ellipsoid around the camera.
  69906. * This can be helpful to determine the center of the body near the gravity center of the body
  69907. * instead of its head.
  69908. */
  69909. ellipsoidOffset: Vector3;
  69910. /**
  69911. * Enable or disable collisions of the camera with the rest of the scene objects.
  69912. */
  69913. checkCollisions: boolean;
  69914. /**
  69915. * Enable or disable gravity on the camera.
  69916. */
  69917. applyGravity: boolean;
  69918. /**
  69919. * Define the input manager associated to the camera.
  69920. */
  69921. inputs: FreeCameraInputsManager;
  69922. /**
  69923. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69924. * Higher values reduce sensitivity.
  69925. */
  69926. /**
  69927. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69928. * Higher values reduce sensitivity.
  69929. */
  69930. angularSensibility: number;
  69931. /**
  69932. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69933. */
  69934. keysUp: number[];
  69935. /**
  69936. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69937. */
  69938. keysDown: number[];
  69939. /**
  69940. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69941. */
  69942. keysLeft: number[];
  69943. /**
  69944. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69945. */
  69946. keysRight: number[];
  69947. /**
  69948. * Event raised when the camera collide with a mesh in the scene.
  69949. */
  69950. onCollide: (collidedMesh: AbstractMesh) => void;
  69951. private _collider;
  69952. private _needMoveForGravity;
  69953. private _oldPosition;
  69954. private _diffPosition;
  69955. private _newPosition;
  69956. /** @hidden */
  69957. _localDirection: Vector3;
  69958. /** @hidden */
  69959. _transformedDirection: Vector3;
  69960. /**
  69961. * Instantiates a Free Camera.
  69962. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69963. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69964. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69965. * @param name Define the name of the camera in the scene
  69966. * @param position Define the start position of the camera in the scene
  69967. * @param scene Define the scene the camera belongs to
  69968. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69969. */
  69970. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69971. /**
  69972. * Attached controls to the current camera.
  69973. * @param element Defines the element the controls should be listened from
  69974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69975. */
  69976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69977. /**
  69978. * Detach the current controls from the camera.
  69979. * The camera will stop reacting to inputs.
  69980. * @param element Defines the element to stop listening the inputs from
  69981. */
  69982. detachControl(element: HTMLElement): void;
  69983. private _collisionMask;
  69984. /**
  69985. * Define a collision mask to limit the list of object the camera can collide with
  69986. */
  69987. collisionMask: number;
  69988. /** @hidden */
  69989. _collideWithWorld(displacement: Vector3): void;
  69990. private _onCollisionPositionChange;
  69991. /** @hidden */
  69992. _checkInputs(): void;
  69993. /** @hidden */
  69994. _decideIfNeedsToMove(): boolean;
  69995. /** @hidden */
  69996. _updatePosition(): void;
  69997. /**
  69998. * Destroy the camera and release the current resources hold by it.
  69999. */
  70000. dispose(): void;
  70001. /**
  70002. * Gets the current object class name.
  70003. * @return the class name
  70004. */
  70005. getClassName(): string;
  70006. }
  70007. }
  70008. declare module BABYLON {
  70009. /**
  70010. * Represents a gamepad control stick position
  70011. */
  70012. export class StickValues {
  70013. /**
  70014. * The x component of the control stick
  70015. */
  70016. x: number;
  70017. /**
  70018. * The y component of the control stick
  70019. */
  70020. y: number;
  70021. /**
  70022. * Initializes the gamepad x and y control stick values
  70023. * @param x The x component of the gamepad control stick value
  70024. * @param y The y component of the gamepad control stick value
  70025. */
  70026. constructor(
  70027. /**
  70028. * The x component of the control stick
  70029. */
  70030. x: number,
  70031. /**
  70032. * The y component of the control stick
  70033. */
  70034. y: number);
  70035. }
  70036. /**
  70037. * An interface which manages callbacks for gamepad button changes
  70038. */
  70039. export interface GamepadButtonChanges {
  70040. /**
  70041. * Called when a gamepad has been changed
  70042. */
  70043. changed: boolean;
  70044. /**
  70045. * Called when a gamepad press event has been triggered
  70046. */
  70047. pressChanged: boolean;
  70048. /**
  70049. * Called when a touch event has been triggered
  70050. */
  70051. touchChanged: boolean;
  70052. /**
  70053. * Called when a value has changed
  70054. */
  70055. valueChanged: boolean;
  70056. }
  70057. /**
  70058. * Represents a gamepad
  70059. */
  70060. export class Gamepad {
  70061. /**
  70062. * The id of the gamepad
  70063. */
  70064. id: string;
  70065. /**
  70066. * The index of the gamepad
  70067. */
  70068. index: number;
  70069. /**
  70070. * The browser gamepad
  70071. */
  70072. browserGamepad: any;
  70073. /**
  70074. * Specifies what type of gamepad this represents
  70075. */
  70076. type: number;
  70077. private _leftStick;
  70078. private _rightStick;
  70079. /** @hidden */
  70080. _isConnected: boolean;
  70081. private _leftStickAxisX;
  70082. private _leftStickAxisY;
  70083. private _rightStickAxisX;
  70084. private _rightStickAxisY;
  70085. /**
  70086. * Triggered when the left control stick has been changed
  70087. */
  70088. private _onleftstickchanged;
  70089. /**
  70090. * Triggered when the right control stick has been changed
  70091. */
  70092. private _onrightstickchanged;
  70093. /**
  70094. * Represents a gamepad controller
  70095. */
  70096. static GAMEPAD: number;
  70097. /**
  70098. * Represents a generic controller
  70099. */
  70100. static GENERIC: number;
  70101. /**
  70102. * Represents an XBox controller
  70103. */
  70104. static XBOX: number;
  70105. /**
  70106. * Represents a pose-enabled controller
  70107. */
  70108. static POSE_ENABLED: number;
  70109. /**
  70110. * Specifies whether the left control stick should be Y-inverted
  70111. */
  70112. protected _invertLeftStickY: boolean;
  70113. /**
  70114. * Specifies if the gamepad has been connected
  70115. */
  70116. readonly isConnected: boolean;
  70117. /**
  70118. * Initializes the gamepad
  70119. * @param id The id of the gamepad
  70120. * @param index The index of the gamepad
  70121. * @param browserGamepad The browser gamepad
  70122. * @param leftStickX The x component of the left joystick
  70123. * @param leftStickY The y component of the left joystick
  70124. * @param rightStickX The x component of the right joystick
  70125. * @param rightStickY The y component of the right joystick
  70126. */
  70127. constructor(
  70128. /**
  70129. * The id of the gamepad
  70130. */
  70131. id: string,
  70132. /**
  70133. * The index of the gamepad
  70134. */
  70135. index: number,
  70136. /**
  70137. * The browser gamepad
  70138. */
  70139. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70140. /**
  70141. * Callback triggered when the left joystick has changed
  70142. * @param callback
  70143. */
  70144. onleftstickchanged(callback: (values: StickValues) => void): void;
  70145. /**
  70146. * Callback triggered when the right joystick has changed
  70147. * @param callback
  70148. */
  70149. onrightstickchanged(callback: (values: StickValues) => void): void;
  70150. /**
  70151. * Gets the left joystick
  70152. */
  70153. /**
  70154. * Sets the left joystick values
  70155. */
  70156. leftStick: StickValues;
  70157. /**
  70158. * Gets the right joystick
  70159. */
  70160. /**
  70161. * Sets the right joystick value
  70162. */
  70163. rightStick: StickValues;
  70164. /**
  70165. * Updates the gamepad joystick positions
  70166. */
  70167. update(): void;
  70168. /**
  70169. * Disposes the gamepad
  70170. */
  70171. dispose(): void;
  70172. }
  70173. /**
  70174. * Represents a generic gamepad
  70175. */
  70176. export class GenericPad extends Gamepad {
  70177. private _buttons;
  70178. private _onbuttondown;
  70179. private _onbuttonup;
  70180. /**
  70181. * Observable triggered when a button has been pressed
  70182. */
  70183. onButtonDownObservable: Observable<number>;
  70184. /**
  70185. * Observable triggered when a button has been released
  70186. */
  70187. onButtonUpObservable: Observable<number>;
  70188. /**
  70189. * Callback triggered when a button has been pressed
  70190. * @param callback Called when a button has been pressed
  70191. */
  70192. onbuttondown(callback: (buttonPressed: number) => void): void;
  70193. /**
  70194. * Callback triggered when a button has been released
  70195. * @param callback Called when a button has been released
  70196. */
  70197. onbuttonup(callback: (buttonReleased: number) => void): void;
  70198. /**
  70199. * Initializes the generic gamepad
  70200. * @param id The id of the generic gamepad
  70201. * @param index The index of the generic gamepad
  70202. * @param browserGamepad The browser gamepad
  70203. */
  70204. constructor(id: string, index: number, browserGamepad: any);
  70205. private _setButtonValue;
  70206. /**
  70207. * Updates the generic gamepad
  70208. */
  70209. update(): void;
  70210. /**
  70211. * Disposes the generic gamepad
  70212. */
  70213. dispose(): void;
  70214. }
  70215. }
  70216. declare module BABYLON {
  70217. /**
  70218. * Defines the types of pose enabled controllers that are supported
  70219. */
  70220. export enum PoseEnabledControllerType {
  70221. /**
  70222. * HTC Vive
  70223. */
  70224. VIVE = 0,
  70225. /**
  70226. * Oculus Rift
  70227. */
  70228. OCULUS = 1,
  70229. /**
  70230. * Windows mixed reality
  70231. */
  70232. WINDOWS = 2,
  70233. /**
  70234. * Samsung gear VR
  70235. */
  70236. GEAR_VR = 3,
  70237. /**
  70238. * Google Daydream
  70239. */
  70240. DAYDREAM = 4,
  70241. /**
  70242. * Generic
  70243. */
  70244. GENERIC = 5
  70245. }
  70246. /**
  70247. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70248. */
  70249. export interface MutableGamepadButton {
  70250. /**
  70251. * Value of the button/trigger
  70252. */
  70253. value: number;
  70254. /**
  70255. * If the button/trigger is currently touched
  70256. */
  70257. touched: boolean;
  70258. /**
  70259. * If the button/trigger is currently pressed
  70260. */
  70261. pressed: boolean;
  70262. }
  70263. /**
  70264. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70265. * @hidden
  70266. */
  70267. export interface ExtendedGamepadButton extends GamepadButton {
  70268. /**
  70269. * If the button/trigger is currently pressed
  70270. */
  70271. readonly pressed: boolean;
  70272. /**
  70273. * If the button/trigger is currently touched
  70274. */
  70275. readonly touched: boolean;
  70276. /**
  70277. * Value of the button/trigger
  70278. */
  70279. readonly value: number;
  70280. }
  70281. /** @hidden */
  70282. export interface _GamePadFactory {
  70283. /**
  70284. * Returns wether or not the current gamepad can be created for this type of controller.
  70285. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70286. * @returns true if it can be created, otherwise false
  70287. */
  70288. canCreate(gamepadInfo: any): boolean;
  70289. /**
  70290. * Creates a new instance of the Gamepad.
  70291. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70292. * @returns the new gamepad instance
  70293. */
  70294. create(gamepadInfo: any): Gamepad;
  70295. }
  70296. /**
  70297. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70298. */
  70299. export class PoseEnabledControllerHelper {
  70300. /** @hidden */
  70301. static _ControllerFactories: _GamePadFactory[];
  70302. /** @hidden */
  70303. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70304. /**
  70305. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70306. * @param vrGamepad the gamepad to initialized
  70307. * @returns a vr controller of the type the gamepad identified as
  70308. */
  70309. static InitiateController(vrGamepad: any): Gamepad;
  70310. }
  70311. /**
  70312. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70313. */
  70314. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70315. private _deviceRoomPosition;
  70316. private _deviceRoomRotationQuaternion;
  70317. /**
  70318. * The device position in babylon space
  70319. */
  70320. devicePosition: Vector3;
  70321. /**
  70322. * The device rotation in babylon space
  70323. */
  70324. deviceRotationQuaternion: Quaternion;
  70325. /**
  70326. * The scale factor of the device in babylon space
  70327. */
  70328. deviceScaleFactor: number;
  70329. /**
  70330. * (Likely devicePosition should be used instead) The device position in its room space
  70331. */
  70332. position: Vector3;
  70333. /**
  70334. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70335. */
  70336. rotationQuaternion: Quaternion;
  70337. /**
  70338. * The type of controller (Eg. Windows mixed reality)
  70339. */
  70340. controllerType: PoseEnabledControllerType;
  70341. protected _calculatedPosition: Vector3;
  70342. private _calculatedRotation;
  70343. /**
  70344. * The raw pose from the device
  70345. */
  70346. rawPose: DevicePose;
  70347. private _trackPosition;
  70348. private _maxRotationDistFromHeadset;
  70349. private _draggedRoomRotation;
  70350. /**
  70351. * @hidden
  70352. */
  70353. _disableTrackPosition(fixedPosition: Vector3): void;
  70354. /**
  70355. * Internal, the mesh attached to the controller
  70356. * @hidden
  70357. */
  70358. _mesh: Nullable<AbstractMesh>;
  70359. private _poseControlledCamera;
  70360. private _leftHandSystemQuaternion;
  70361. /**
  70362. * Internal, matrix used to convert room space to babylon space
  70363. * @hidden
  70364. */
  70365. _deviceToWorld: Matrix;
  70366. /**
  70367. * Node to be used when casting a ray from the controller
  70368. * @hidden
  70369. */
  70370. _pointingPoseNode: Nullable<TransformNode>;
  70371. /**
  70372. * Name of the child mesh that can be used to cast a ray from the controller
  70373. */
  70374. static readonly POINTING_POSE: string;
  70375. /**
  70376. * Creates a new PoseEnabledController from a gamepad
  70377. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70378. */
  70379. constructor(browserGamepad: any);
  70380. private _workingMatrix;
  70381. /**
  70382. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70383. */
  70384. update(): void;
  70385. /**
  70386. * Updates only the pose device and mesh without doing any button event checking
  70387. */
  70388. protected _updatePoseAndMesh(): void;
  70389. /**
  70390. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70391. * @param poseData raw pose fromthe device
  70392. */
  70393. updateFromDevice(poseData: DevicePose): void;
  70394. /**
  70395. * @hidden
  70396. */
  70397. _meshAttachedObservable: Observable<AbstractMesh>;
  70398. /**
  70399. * Attaches a mesh to the controller
  70400. * @param mesh the mesh to be attached
  70401. */
  70402. attachToMesh(mesh: AbstractMesh): void;
  70403. /**
  70404. * Attaches the controllers mesh to a camera
  70405. * @param camera the camera the mesh should be attached to
  70406. */
  70407. attachToPoseControlledCamera(camera: TargetCamera): void;
  70408. /**
  70409. * Disposes of the controller
  70410. */
  70411. dispose(): void;
  70412. /**
  70413. * The mesh that is attached to the controller
  70414. */
  70415. readonly mesh: Nullable<AbstractMesh>;
  70416. /**
  70417. * Gets the ray of the controller in the direction the controller is pointing
  70418. * @param length the length the resulting ray should be
  70419. * @returns a ray in the direction the controller is pointing
  70420. */
  70421. getForwardRay(length?: number): Ray;
  70422. }
  70423. }
  70424. declare module BABYLON {
  70425. /**
  70426. * Defines the WebVRController object that represents controllers tracked in 3D space
  70427. */
  70428. export abstract class WebVRController extends PoseEnabledController {
  70429. /**
  70430. * Internal, the default controller model for the controller
  70431. */
  70432. protected _defaultModel: AbstractMesh;
  70433. /**
  70434. * Fired when the trigger state has changed
  70435. */
  70436. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70437. /**
  70438. * Fired when the main button state has changed
  70439. */
  70440. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70441. /**
  70442. * Fired when the secondary button state has changed
  70443. */
  70444. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70445. /**
  70446. * Fired when the pad state has changed
  70447. */
  70448. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70449. /**
  70450. * Fired when controllers stick values have changed
  70451. */
  70452. onPadValuesChangedObservable: Observable<StickValues>;
  70453. /**
  70454. * Array of button availible on the controller
  70455. */
  70456. protected _buttons: Array<MutableGamepadButton>;
  70457. private _onButtonStateChange;
  70458. /**
  70459. * Fired when a controller button's state has changed
  70460. * @param callback the callback containing the button that was modified
  70461. */
  70462. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70463. /**
  70464. * X and Y axis corrisponding to the controllers joystick
  70465. */
  70466. pad: StickValues;
  70467. /**
  70468. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70469. */
  70470. hand: string;
  70471. /**
  70472. * The default controller model for the controller
  70473. */
  70474. readonly defaultModel: AbstractMesh;
  70475. /**
  70476. * Creates a new WebVRController from a gamepad
  70477. * @param vrGamepad the gamepad that the WebVRController should be created from
  70478. */
  70479. constructor(vrGamepad: any);
  70480. /**
  70481. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70482. */
  70483. update(): void;
  70484. /**
  70485. * Function to be called when a button is modified
  70486. */
  70487. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70488. /**
  70489. * Loads a mesh and attaches it to the controller
  70490. * @param scene the scene the mesh should be added to
  70491. * @param meshLoaded callback for when the mesh has been loaded
  70492. */
  70493. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70494. private _setButtonValue;
  70495. private _changes;
  70496. private _checkChanges;
  70497. /**
  70498. * Disposes of th webVRCOntroller
  70499. */
  70500. dispose(): void;
  70501. }
  70502. }
  70503. declare module BABYLON {
  70504. /**
  70505. * The HemisphericLight simulates the ambient environment light,
  70506. * so the passed direction is the light reflection direction, not the incoming direction.
  70507. */
  70508. export class HemisphericLight extends Light {
  70509. /**
  70510. * The groundColor is the light in the opposite direction to the one specified during creation.
  70511. * 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.
  70512. */
  70513. groundColor: Color3;
  70514. /**
  70515. * The light reflection direction, not the incoming direction.
  70516. */
  70517. direction: Vector3;
  70518. /**
  70519. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70520. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70521. * The HemisphericLight can't cast shadows.
  70522. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70523. * @param name The friendly name of the light
  70524. * @param direction The direction of the light reflection
  70525. * @param scene The scene the light belongs to
  70526. */
  70527. constructor(name: string, direction: Vector3, scene: Scene);
  70528. protected _buildUniformLayout(): void;
  70529. /**
  70530. * Returns the string "HemisphericLight".
  70531. * @return The class name
  70532. */
  70533. getClassName(): string;
  70534. /**
  70535. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70536. * Returns the updated direction.
  70537. * @param target The target the direction should point to
  70538. * @return The computed direction
  70539. */
  70540. setDirectionToTarget(target: Vector3): Vector3;
  70541. /**
  70542. * Returns the shadow generator associated to the light.
  70543. * @returns Always null for hemispheric lights because it does not support shadows.
  70544. */
  70545. getShadowGenerator(): Nullable<IShadowGenerator>;
  70546. /**
  70547. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70548. * @param effect The effect to update
  70549. * @param lightIndex The index of the light in the effect to update
  70550. * @returns The hemispheric light
  70551. */
  70552. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70553. /**
  70554. * Computes the world matrix of the node
  70555. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70556. * @param useWasUpdatedFlag defines a reserved property
  70557. * @returns the world matrix
  70558. */
  70559. computeWorldMatrix(): Matrix;
  70560. /**
  70561. * Returns the integer 3.
  70562. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70563. */
  70564. getTypeID(): number;
  70565. /**
  70566. * Prepares the list of defines specific to the light type.
  70567. * @param defines the list of defines
  70568. * @param lightIndex defines the index of the light for the effect
  70569. */
  70570. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70571. }
  70572. }
  70573. declare module BABYLON {
  70574. /**
  70575. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70576. * IMPORTANT!! The data is right-hand data.
  70577. * @export
  70578. * @interface DevicePose
  70579. */
  70580. export interface DevicePose {
  70581. /**
  70582. * The position of the device, values in array are [x,y,z].
  70583. */
  70584. readonly position: Nullable<Float32Array>;
  70585. /**
  70586. * The linearVelocity of the device, values in array are [x,y,z].
  70587. */
  70588. readonly linearVelocity: Nullable<Float32Array>;
  70589. /**
  70590. * The linearAcceleration of the device, values in array are [x,y,z].
  70591. */
  70592. readonly linearAcceleration: Nullable<Float32Array>;
  70593. /**
  70594. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70595. */
  70596. readonly orientation: Nullable<Float32Array>;
  70597. /**
  70598. * The angularVelocity of the device, values in array are [x,y,z].
  70599. */
  70600. readonly angularVelocity: Nullable<Float32Array>;
  70601. /**
  70602. * The angularAcceleration of the device, values in array are [x,y,z].
  70603. */
  70604. readonly angularAcceleration: Nullable<Float32Array>;
  70605. }
  70606. /**
  70607. * Interface representing a pose controlled object in Babylon.
  70608. * A pose controlled object has both regular pose values as well as pose values
  70609. * from an external device such as a VR head mounted display
  70610. */
  70611. export interface PoseControlled {
  70612. /**
  70613. * The position of the object in babylon space.
  70614. */
  70615. position: Vector3;
  70616. /**
  70617. * The rotation quaternion of the object in babylon space.
  70618. */
  70619. rotationQuaternion: Quaternion;
  70620. /**
  70621. * The position of the device in babylon space.
  70622. */
  70623. devicePosition?: Vector3;
  70624. /**
  70625. * The rotation quaternion of the device in babylon space.
  70626. */
  70627. deviceRotationQuaternion: Quaternion;
  70628. /**
  70629. * The raw pose coming from the device.
  70630. */
  70631. rawPose: Nullable<DevicePose>;
  70632. /**
  70633. * The scale of the device to be used when translating from device space to babylon space.
  70634. */
  70635. deviceScaleFactor: number;
  70636. /**
  70637. * Updates the poseControlled values based on the input device pose.
  70638. * @param poseData the pose data to update the object with
  70639. */
  70640. updateFromDevice(poseData: DevicePose): void;
  70641. }
  70642. /**
  70643. * Set of options to customize the webVRCamera
  70644. */
  70645. export interface WebVROptions {
  70646. /**
  70647. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70648. */
  70649. trackPosition?: boolean;
  70650. /**
  70651. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70652. */
  70653. positionScale?: number;
  70654. /**
  70655. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70656. */
  70657. displayName?: string;
  70658. /**
  70659. * Should the native controller meshes be initialized. (default: true)
  70660. */
  70661. controllerMeshes?: boolean;
  70662. /**
  70663. * Creating a default HemiLight only on controllers. (default: true)
  70664. */
  70665. defaultLightingOnControllers?: boolean;
  70666. /**
  70667. * If you don't want to use the default VR button of the helper. (default: false)
  70668. */
  70669. useCustomVRButton?: boolean;
  70670. /**
  70671. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70672. */
  70673. customVRButton?: HTMLButtonElement;
  70674. /**
  70675. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70676. */
  70677. rayLength?: number;
  70678. /**
  70679. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70680. */
  70681. defaultHeight?: number;
  70682. }
  70683. /**
  70684. * This represents a WebVR camera.
  70685. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70686. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70687. */
  70688. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70689. private webVROptions;
  70690. /**
  70691. * @hidden
  70692. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70693. */
  70694. _vrDevice: any;
  70695. /**
  70696. * The rawPose of the vrDevice.
  70697. */
  70698. rawPose: Nullable<DevicePose>;
  70699. private _onVREnabled;
  70700. private _specsVersion;
  70701. private _attached;
  70702. private _frameData;
  70703. protected _descendants: Array<Node>;
  70704. private _deviceRoomPosition;
  70705. /** @hidden */
  70706. _deviceRoomRotationQuaternion: Quaternion;
  70707. private _standingMatrix;
  70708. /**
  70709. * Represents device position in babylon space.
  70710. */
  70711. devicePosition: Vector3;
  70712. /**
  70713. * Represents device rotation in babylon space.
  70714. */
  70715. deviceRotationQuaternion: Quaternion;
  70716. /**
  70717. * The scale of the device to be used when translating from device space to babylon space.
  70718. */
  70719. deviceScaleFactor: number;
  70720. private _deviceToWorld;
  70721. private _worldToDevice;
  70722. /**
  70723. * References to the webVR controllers for the vrDevice.
  70724. */
  70725. controllers: Array<WebVRController>;
  70726. /**
  70727. * Emits an event when a controller is attached.
  70728. */
  70729. onControllersAttachedObservable: Observable<WebVRController[]>;
  70730. /**
  70731. * Emits an event when a controller's mesh has been loaded;
  70732. */
  70733. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70734. /**
  70735. * Emits an event when the HMD's pose has been updated.
  70736. */
  70737. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70738. private _poseSet;
  70739. /**
  70740. * If the rig cameras be used as parent instead of this camera.
  70741. */
  70742. rigParenting: boolean;
  70743. private _lightOnControllers;
  70744. private _defaultHeight?;
  70745. /**
  70746. * Instantiates a WebVRFreeCamera.
  70747. * @param name The name of the WebVRFreeCamera
  70748. * @param position The starting anchor position for the camera
  70749. * @param scene The scene the camera belongs to
  70750. * @param webVROptions a set of customizable options for the webVRCamera
  70751. */
  70752. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70753. /**
  70754. * Gets the device distance from the ground in meters.
  70755. * @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.
  70756. */
  70757. deviceDistanceToRoomGround(): number;
  70758. /**
  70759. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70760. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70761. */
  70762. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70763. /**
  70764. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70765. * @returns A promise with a boolean set to if the standing matrix is supported.
  70766. */
  70767. useStandingMatrixAsync(): Promise<boolean>;
  70768. /**
  70769. * Disposes the camera
  70770. */
  70771. dispose(): void;
  70772. /**
  70773. * Gets a vrController by name.
  70774. * @param name The name of the controller to retreive
  70775. * @returns the controller matching the name specified or null if not found
  70776. */
  70777. getControllerByName(name: string): Nullable<WebVRController>;
  70778. private _leftController;
  70779. /**
  70780. * The controller corrisponding to the users left hand.
  70781. */
  70782. readonly leftController: Nullable<WebVRController>;
  70783. private _rightController;
  70784. /**
  70785. * The controller corrisponding to the users right hand.
  70786. */
  70787. readonly rightController: Nullable<WebVRController>;
  70788. /**
  70789. * Casts a ray forward from the vrCamera's gaze.
  70790. * @param length Length of the ray (default: 100)
  70791. * @returns the ray corrisponding to the gaze
  70792. */
  70793. getForwardRay(length?: number): Ray;
  70794. /**
  70795. * @hidden
  70796. * Updates the camera based on device's frame data
  70797. */
  70798. _checkInputs(): void;
  70799. /**
  70800. * Updates the poseControlled values based on the input device pose.
  70801. * @param poseData Pose coming from the device
  70802. */
  70803. updateFromDevice(poseData: DevicePose): void;
  70804. private _htmlElementAttached;
  70805. private _detachIfAttached;
  70806. /**
  70807. * WebVR's attach control will start broadcasting frames to the device.
  70808. * Note that in certain browsers (chrome for example) this function must be called
  70809. * within a user-interaction callback. Example:
  70810. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70811. *
  70812. * @param element html element to attach the vrDevice to
  70813. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70814. */
  70815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70816. /**
  70817. * Detaches the camera from the html element and disables VR
  70818. *
  70819. * @param element html element to detach from
  70820. */
  70821. detachControl(element: HTMLElement): void;
  70822. /**
  70823. * @returns the name of this class
  70824. */
  70825. getClassName(): string;
  70826. /**
  70827. * Calls resetPose on the vrDisplay
  70828. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70829. */
  70830. resetToCurrentRotation(): void;
  70831. /**
  70832. * @hidden
  70833. * Updates the rig cameras (left and right eye)
  70834. */
  70835. _updateRigCameras(): void;
  70836. private _workingVector;
  70837. private _oneVector;
  70838. private _workingMatrix;
  70839. private updateCacheCalled;
  70840. private _correctPositionIfNotTrackPosition;
  70841. /**
  70842. * @hidden
  70843. * Updates the cached values of the camera
  70844. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70845. */
  70846. _updateCache(ignoreParentClass?: boolean): void;
  70847. /**
  70848. * @hidden
  70849. * Get current device position in babylon world
  70850. */
  70851. _computeDevicePosition(): void;
  70852. /**
  70853. * Updates the current device position and rotation in the babylon world
  70854. */
  70855. update(): void;
  70856. /**
  70857. * @hidden
  70858. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70859. * @returns an identity matrix
  70860. */
  70861. _getViewMatrix(): Matrix;
  70862. private _tmpMatrix;
  70863. /**
  70864. * This function is called by the two RIG cameras.
  70865. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70866. * @hidden
  70867. */
  70868. _getWebVRViewMatrix(): Matrix;
  70869. /** @hidden */
  70870. _getWebVRProjectionMatrix(): Matrix;
  70871. private _onGamepadConnectedObserver;
  70872. private _onGamepadDisconnectedObserver;
  70873. private _updateCacheWhenTrackingDisabledObserver;
  70874. /**
  70875. * Initializes the controllers and their meshes
  70876. */
  70877. initControllers(): void;
  70878. }
  70879. }
  70880. declare module BABYLON {
  70881. /**
  70882. * Size options for a post process
  70883. */
  70884. export type PostProcessOptions = {
  70885. width: number;
  70886. height: number;
  70887. };
  70888. /**
  70889. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70890. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70891. */
  70892. export class PostProcess {
  70893. /** Name of the PostProcess. */
  70894. name: string;
  70895. /**
  70896. * Gets or sets the unique id of the post process
  70897. */
  70898. uniqueId: number;
  70899. /**
  70900. * Width of the texture to apply the post process on
  70901. */
  70902. width: number;
  70903. /**
  70904. * Height of the texture to apply the post process on
  70905. */
  70906. height: number;
  70907. /**
  70908. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70909. * @hidden
  70910. */
  70911. _outputTexture: Nullable<InternalTexture>;
  70912. /**
  70913. * Sampling mode used by the shader
  70914. * See https://doc.babylonjs.com/classes/3.1/texture
  70915. */
  70916. renderTargetSamplingMode: number;
  70917. /**
  70918. * Clear color to use when screen clearing
  70919. */
  70920. clearColor: Color4;
  70921. /**
  70922. * If the buffer needs to be cleared before applying the post process. (default: true)
  70923. * Should be set to false if shader will overwrite all previous pixels.
  70924. */
  70925. autoClear: boolean;
  70926. /**
  70927. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70928. */
  70929. alphaMode: number;
  70930. /**
  70931. * Sets the setAlphaBlendConstants of the babylon engine
  70932. */
  70933. alphaConstants: Color4;
  70934. /**
  70935. * Animations to be used for the post processing
  70936. */
  70937. animations: Animation[];
  70938. /**
  70939. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70940. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70941. */
  70942. enablePixelPerfectMode: boolean;
  70943. /**
  70944. * Force the postprocess to be applied without taking in account viewport
  70945. */
  70946. forceFullscreenViewport: boolean;
  70947. /**
  70948. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70949. *
  70950. * | Value | Type | Description |
  70951. * | ----- | ----------------------------------- | ----------- |
  70952. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70953. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70954. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70955. *
  70956. */
  70957. scaleMode: number;
  70958. /**
  70959. * Force textures to be a power of two (default: false)
  70960. */
  70961. alwaysForcePOT: boolean;
  70962. private _samples;
  70963. /**
  70964. * Number of sample textures (default: 1)
  70965. */
  70966. samples: number;
  70967. /**
  70968. * Modify the scale of the post process to be the same as the viewport (default: false)
  70969. */
  70970. adaptScaleToCurrentViewport: boolean;
  70971. private _camera;
  70972. private _scene;
  70973. private _engine;
  70974. private _options;
  70975. private _reusable;
  70976. private _textureType;
  70977. /**
  70978. * Smart array of input and output textures for the post process.
  70979. * @hidden
  70980. */
  70981. _textures: SmartArray<InternalTexture>;
  70982. /**
  70983. * The index in _textures that corresponds to the output texture.
  70984. * @hidden
  70985. */
  70986. _currentRenderTextureInd: number;
  70987. private _effect;
  70988. private _samplers;
  70989. private _fragmentUrl;
  70990. private _vertexUrl;
  70991. private _parameters;
  70992. private _scaleRatio;
  70993. protected _indexParameters: any;
  70994. private _shareOutputWithPostProcess;
  70995. private _texelSize;
  70996. private _forcedOutputTexture;
  70997. /**
  70998. * Returns the fragment url or shader name used in the post process.
  70999. * @returns the fragment url or name in the shader store.
  71000. */
  71001. getEffectName(): string;
  71002. /**
  71003. * An event triggered when the postprocess is activated.
  71004. */
  71005. onActivateObservable: Observable<Camera>;
  71006. private _onActivateObserver;
  71007. /**
  71008. * A function that is added to the onActivateObservable
  71009. */
  71010. onActivate: Nullable<(camera: Camera) => void>;
  71011. /**
  71012. * An event triggered when the postprocess changes its size.
  71013. */
  71014. onSizeChangedObservable: Observable<PostProcess>;
  71015. private _onSizeChangedObserver;
  71016. /**
  71017. * A function that is added to the onSizeChangedObservable
  71018. */
  71019. onSizeChanged: (postProcess: PostProcess) => void;
  71020. /**
  71021. * An event triggered when the postprocess applies its effect.
  71022. */
  71023. onApplyObservable: Observable<Effect>;
  71024. private _onApplyObserver;
  71025. /**
  71026. * A function that is added to the onApplyObservable
  71027. */
  71028. onApply: (effect: Effect) => void;
  71029. /**
  71030. * An event triggered before rendering the postprocess
  71031. */
  71032. onBeforeRenderObservable: Observable<Effect>;
  71033. private _onBeforeRenderObserver;
  71034. /**
  71035. * A function that is added to the onBeforeRenderObservable
  71036. */
  71037. onBeforeRender: (effect: Effect) => void;
  71038. /**
  71039. * An event triggered after rendering the postprocess
  71040. */
  71041. onAfterRenderObservable: Observable<Effect>;
  71042. private _onAfterRenderObserver;
  71043. /**
  71044. * A function that is added to the onAfterRenderObservable
  71045. */
  71046. onAfterRender: (efect: Effect) => void;
  71047. /**
  71048. * 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
  71049. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71050. */
  71051. inputTexture: InternalTexture;
  71052. /**
  71053. * Gets the camera which post process is applied to.
  71054. * @returns The camera the post process is applied to.
  71055. */
  71056. getCamera(): Camera;
  71057. /**
  71058. * Gets the texel size of the postprocess.
  71059. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71060. */
  71061. readonly texelSize: Vector2;
  71062. /**
  71063. * Creates a new instance PostProcess
  71064. * @param name The name of the PostProcess.
  71065. * @param fragmentUrl The url of the fragment shader to be used.
  71066. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71067. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71068. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71069. * @param camera The camera to apply the render pass to.
  71070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71071. * @param engine The engine which the post process will be applied. (default: current engine)
  71072. * @param reusable If the post process can be reused on the same frame. (default: false)
  71073. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71074. * @param textureType Type of textures used when performing the post process. (default: 0)
  71075. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71076. * @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
  71077. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71078. */
  71079. constructor(
  71080. /** Name of the PostProcess. */
  71081. 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);
  71082. /**
  71083. * Gets a string idenfifying the name of the class
  71084. * @returns "PostProcess" string
  71085. */
  71086. getClassName(): string;
  71087. /**
  71088. * Gets the engine which this post process belongs to.
  71089. * @returns The engine the post process was enabled with.
  71090. */
  71091. getEngine(): Engine;
  71092. /**
  71093. * The effect that is created when initializing the post process.
  71094. * @returns The created effect corrisponding the the postprocess.
  71095. */
  71096. getEffect(): Effect;
  71097. /**
  71098. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71099. * @param postProcess The post process to share the output with.
  71100. * @returns This post process.
  71101. */
  71102. shareOutputWith(postProcess: PostProcess): PostProcess;
  71103. /**
  71104. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71105. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71106. */
  71107. useOwnOutput(): void;
  71108. /**
  71109. * Updates the effect with the current post process compile time values and recompiles the shader.
  71110. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71111. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71112. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71113. * @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
  71114. * @param onCompiled Called when the shader has been compiled.
  71115. * @param onError Called if there is an error when compiling a shader.
  71116. */
  71117. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71118. /**
  71119. * The post process is reusable if it can be used multiple times within one frame.
  71120. * @returns If the post process is reusable
  71121. */
  71122. isReusable(): boolean;
  71123. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71124. markTextureDirty(): void;
  71125. /**
  71126. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71127. * 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.
  71128. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71129. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71130. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71131. * @returns The target texture that was bound to be written to.
  71132. */
  71133. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71134. /**
  71135. * If the post process is supported.
  71136. */
  71137. readonly isSupported: boolean;
  71138. /**
  71139. * The aspect ratio of the output texture.
  71140. */
  71141. readonly aspectRatio: number;
  71142. /**
  71143. * Get a value indicating if the post-process is ready to be used
  71144. * @returns true if the post-process is ready (shader is compiled)
  71145. */
  71146. isReady(): boolean;
  71147. /**
  71148. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71149. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71150. */
  71151. apply(): Nullable<Effect>;
  71152. private _disposeTextures;
  71153. /**
  71154. * Disposes the post process.
  71155. * @param camera The camera to dispose the post process on.
  71156. */
  71157. dispose(camera?: Camera): void;
  71158. }
  71159. }
  71160. declare module BABYLON {
  71161. /**
  71162. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71163. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71164. */
  71165. export class PostProcessManager {
  71166. private _scene;
  71167. private _indexBuffer;
  71168. private _vertexBuffers;
  71169. /**
  71170. * Creates a new instance PostProcess
  71171. * @param scene The scene that the post process is associated with.
  71172. */
  71173. constructor(scene: Scene);
  71174. private _prepareBuffers;
  71175. private _buildIndexBuffer;
  71176. /**
  71177. * Rebuilds the vertex buffers of the manager.
  71178. * @hidden
  71179. */
  71180. _rebuild(): void;
  71181. /**
  71182. * Prepares a frame to be run through a post process.
  71183. * @param sourceTexture The input texture to the post procesess. (default: null)
  71184. * @param postProcesses An array of post processes to be run. (default: null)
  71185. * @returns True if the post processes were able to be run.
  71186. * @hidden
  71187. */
  71188. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71189. /**
  71190. * Manually render a set of post processes to a texture.
  71191. * @param postProcesses An array of post processes to be run.
  71192. * @param targetTexture The target texture to render to.
  71193. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71194. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71195. * @param lodLevel defines which lod of the texture to render to
  71196. */
  71197. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71198. /**
  71199. * Finalize the result of the output of the postprocesses.
  71200. * @param doNotPresent If true the result will not be displayed to the screen.
  71201. * @param targetTexture The target texture to render to.
  71202. * @param faceIndex The index of the face to bind the target texture to.
  71203. * @param postProcesses The array of post processes to render.
  71204. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71205. * @hidden
  71206. */
  71207. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71208. /**
  71209. * Disposes of the post process manager.
  71210. */
  71211. dispose(): void;
  71212. }
  71213. }
  71214. declare module BABYLON {
  71215. interface AbstractScene {
  71216. /**
  71217. * The list of layers (background and foreground) of the scene
  71218. */
  71219. layers: Array<Layer>;
  71220. }
  71221. /**
  71222. * Defines the layer scene component responsible to manage any layers
  71223. * in a given scene.
  71224. */
  71225. export class LayerSceneComponent implements ISceneComponent {
  71226. /**
  71227. * The component name helpfull to identify the component in the list of scene components.
  71228. */
  71229. readonly name: string;
  71230. /**
  71231. * The scene the component belongs to.
  71232. */
  71233. scene: Scene;
  71234. private _engine;
  71235. /**
  71236. * Creates a new instance of the component for the given scene
  71237. * @param scene Defines the scene to register the component in
  71238. */
  71239. constructor(scene: Scene);
  71240. /**
  71241. * Registers the component in a given scene
  71242. */
  71243. register(): void;
  71244. /**
  71245. * Rebuilds the elements related to this component in case of
  71246. * context lost for instance.
  71247. */
  71248. rebuild(): void;
  71249. /**
  71250. * Disposes the component and the associated ressources.
  71251. */
  71252. dispose(): void;
  71253. private _draw;
  71254. private _drawCameraPredicate;
  71255. private _drawCameraBackground;
  71256. private _drawCameraForeground;
  71257. private _drawRenderTargetPredicate;
  71258. private _drawRenderTargetBackground;
  71259. private _drawRenderTargetForeground;
  71260. }
  71261. }
  71262. declare module BABYLON {
  71263. /** @hidden */
  71264. export var layerPixelShader: {
  71265. name: string;
  71266. shader: string;
  71267. };
  71268. }
  71269. declare module BABYLON {
  71270. /** @hidden */
  71271. export var layerVertexShader: {
  71272. name: string;
  71273. shader: string;
  71274. };
  71275. }
  71276. declare module BABYLON {
  71277. /**
  71278. * This represents a full screen 2d layer.
  71279. * This can be useful to display a picture in the background of your scene for instance.
  71280. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71281. */
  71282. export class Layer {
  71283. /**
  71284. * Define the name of the layer.
  71285. */
  71286. name: string;
  71287. /**
  71288. * Define the texture the layer should display.
  71289. */
  71290. texture: Nullable<Texture>;
  71291. /**
  71292. * Is the layer in background or foreground.
  71293. */
  71294. isBackground: boolean;
  71295. /**
  71296. * Define the color of the layer (instead of texture).
  71297. */
  71298. color: Color4;
  71299. /**
  71300. * Define the scale of the layer in order to zoom in out of the texture.
  71301. */
  71302. scale: Vector2;
  71303. /**
  71304. * Define an offset for the layer in order to shift the texture.
  71305. */
  71306. offset: Vector2;
  71307. /**
  71308. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71309. */
  71310. alphaBlendingMode: number;
  71311. /**
  71312. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71313. * Alpha test will not mix with the background color in case of transparency.
  71314. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71315. */
  71316. alphaTest: boolean;
  71317. /**
  71318. * Define a mask to restrict the layer to only some of the scene cameras.
  71319. */
  71320. layerMask: number;
  71321. /**
  71322. * Define the list of render target the layer is visible into.
  71323. */
  71324. renderTargetTextures: RenderTargetTexture[];
  71325. /**
  71326. * Define if the layer is only used in renderTarget or if it also
  71327. * renders in the main frame buffer of the canvas.
  71328. */
  71329. renderOnlyInRenderTargetTextures: boolean;
  71330. private _scene;
  71331. private _vertexBuffers;
  71332. private _indexBuffer;
  71333. private _effect;
  71334. private _alphaTestEffect;
  71335. /**
  71336. * An event triggered when the layer is disposed.
  71337. */
  71338. onDisposeObservable: Observable<Layer>;
  71339. private _onDisposeObserver;
  71340. /**
  71341. * Back compatibility with callback before the onDisposeObservable existed.
  71342. * The set callback will be triggered when the layer has been disposed.
  71343. */
  71344. onDispose: () => void;
  71345. /**
  71346. * An event triggered before rendering the scene
  71347. */
  71348. onBeforeRenderObservable: Observable<Layer>;
  71349. private _onBeforeRenderObserver;
  71350. /**
  71351. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71352. * The set callback will be triggered just before rendering the layer.
  71353. */
  71354. onBeforeRender: () => void;
  71355. /**
  71356. * An event triggered after rendering the scene
  71357. */
  71358. onAfterRenderObservable: Observable<Layer>;
  71359. private _onAfterRenderObserver;
  71360. /**
  71361. * Back compatibility with callback before the onAfterRenderObservable existed.
  71362. * The set callback will be triggered just after rendering the layer.
  71363. */
  71364. onAfterRender: () => void;
  71365. /**
  71366. * Instantiates a new layer.
  71367. * This represents a full screen 2d layer.
  71368. * This can be useful to display a picture in the background of your scene for instance.
  71369. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71370. * @param name Define the name of the layer in the scene
  71371. * @param imgUrl Define the url of the texture to display in the layer
  71372. * @param scene Define the scene the layer belongs to
  71373. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71374. * @param color Defines a color for the layer
  71375. */
  71376. constructor(
  71377. /**
  71378. * Define the name of the layer.
  71379. */
  71380. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71381. private _createIndexBuffer;
  71382. /** @hidden */
  71383. _rebuild(): void;
  71384. /**
  71385. * Renders the layer in the scene.
  71386. */
  71387. render(): void;
  71388. /**
  71389. * Disposes and releases the associated ressources.
  71390. */
  71391. dispose(): void;
  71392. }
  71393. }
  71394. declare module BABYLON {
  71395. interface AbstractScene {
  71396. /**
  71397. * The list of procedural textures added to the scene
  71398. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71399. */
  71400. proceduralTextures: Array<ProceduralTexture>;
  71401. }
  71402. /**
  71403. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71404. * in a given scene.
  71405. */
  71406. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71407. /**
  71408. * The component name helpfull to identify the component in the list of scene components.
  71409. */
  71410. readonly name: string;
  71411. /**
  71412. * The scene the component belongs to.
  71413. */
  71414. scene: Scene;
  71415. /**
  71416. * Creates a new instance of the component for the given scene
  71417. * @param scene Defines the scene to register the component in
  71418. */
  71419. constructor(scene: Scene);
  71420. /**
  71421. * Registers the component in a given scene
  71422. */
  71423. register(): void;
  71424. /**
  71425. * Rebuilds the elements related to this component in case of
  71426. * context lost for instance.
  71427. */
  71428. rebuild(): void;
  71429. /**
  71430. * Disposes the component and the associated ressources.
  71431. */
  71432. dispose(): void;
  71433. private _beforeClear;
  71434. }
  71435. }
  71436. declare module BABYLON {
  71437. /** @hidden */
  71438. export var proceduralVertexShader: {
  71439. name: string;
  71440. shader: string;
  71441. };
  71442. }
  71443. declare module BABYLON {
  71444. /**
  71445. * 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.
  71446. * This is the base class of any Procedural texture and contains most of the shareable code.
  71447. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71448. */
  71449. export class ProceduralTexture extends Texture {
  71450. isCube: boolean;
  71451. /**
  71452. * Define if the texture is enabled or not (disabled texture will not render)
  71453. */
  71454. isEnabled: boolean;
  71455. /**
  71456. * Define if the texture must be cleared before rendering (default is true)
  71457. */
  71458. autoClear: boolean;
  71459. /**
  71460. * Callback called when the texture is generated
  71461. */
  71462. onGenerated: () => void;
  71463. /**
  71464. * Event raised when the texture is generated
  71465. */
  71466. onGeneratedObservable: Observable<ProceduralTexture>;
  71467. /** @hidden */
  71468. _generateMipMaps: boolean;
  71469. /** @hidden **/
  71470. _effect: Effect;
  71471. /** @hidden */
  71472. _textures: {
  71473. [key: string]: Texture;
  71474. };
  71475. private _size;
  71476. private _currentRefreshId;
  71477. private _refreshRate;
  71478. private _vertexBuffers;
  71479. private _indexBuffer;
  71480. private _uniforms;
  71481. private _samplers;
  71482. private _fragment;
  71483. private _floats;
  71484. private _ints;
  71485. private _floatsArrays;
  71486. private _colors3;
  71487. private _colors4;
  71488. private _vectors2;
  71489. private _vectors3;
  71490. private _matrices;
  71491. private _fallbackTexture;
  71492. private _fallbackTextureUsed;
  71493. private _engine;
  71494. private _cachedDefines;
  71495. private _contentUpdateId;
  71496. private _contentData;
  71497. /**
  71498. * Instantiates a new procedural texture.
  71499. * 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.
  71500. * This is the base class of any Procedural texture and contains most of the shareable code.
  71501. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71502. * @param name Define the name of the texture
  71503. * @param size Define the size of the texture to create
  71504. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71505. * @param scene Define the scene the texture belongs to
  71506. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71507. * @param generateMipMaps Define if the texture should creates mip maps or not
  71508. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71509. */
  71510. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71511. /**
  71512. * The effect that is created when initializing the post process.
  71513. * @returns The created effect corrisponding the the postprocess.
  71514. */
  71515. getEffect(): Effect;
  71516. /**
  71517. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71518. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71519. */
  71520. getContent(): Nullable<ArrayBufferView>;
  71521. private _createIndexBuffer;
  71522. /** @hidden */
  71523. _rebuild(): void;
  71524. /**
  71525. * Resets the texture in order to recreate its associated resources.
  71526. * This can be called in case of context loss
  71527. */
  71528. reset(): void;
  71529. protected _getDefines(): string;
  71530. /**
  71531. * Is the texture ready to be used ? (rendered at least once)
  71532. * @returns true if ready, otherwise, false.
  71533. */
  71534. isReady(): boolean;
  71535. /**
  71536. * Resets the refresh counter of the texture and start bak from scratch.
  71537. * Could be useful to regenerate the texture if it is setup to render only once.
  71538. */
  71539. resetRefreshCounter(): void;
  71540. /**
  71541. * Set the fragment shader to use in order to render the texture.
  71542. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71543. */
  71544. setFragment(fragment: any): void;
  71545. /**
  71546. * Define the refresh rate of the texture or the rendering frequency.
  71547. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71548. */
  71549. refreshRate: number;
  71550. /** @hidden */
  71551. _shouldRender(): boolean;
  71552. /**
  71553. * Get the size the texture is rendering at.
  71554. * @returns the size (texture is always squared)
  71555. */
  71556. getRenderSize(): number;
  71557. /**
  71558. * Resize the texture to new value.
  71559. * @param size Define the new size the texture should have
  71560. * @param generateMipMaps Define whether the new texture should create mip maps
  71561. */
  71562. resize(size: number, generateMipMaps: boolean): void;
  71563. private _checkUniform;
  71564. /**
  71565. * Set a texture in the shader program used to render.
  71566. * @param name Define the name of the uniform samplers as defined in the shader
  71567. * @param texture Define the texture to bind to this sampler
  71568. * @return the texture itself allowing "fluent" like uniform updates
  71569. */
  71570. setTexture(name: string, texture: Texture): ProceduralTexture;
  71571. /**
  71572. * Set a float in the shader.
  71573. * @param name Define the name of the uniform as defined in the shader
  71574. * @param value Define the value to give to the uniform
  71575. * @return the texture itself allowing "fluent" like uniform updates
  71576. */
  71577. setFloat(name: string, value: number): ProceduralTexture;
  71578. /**
  71579. * Set a int in the shader.
  71580. * @param name Define the name of the uniform as defined in the shader
  71581. * @param value Define the value to give to the uniform
  71582. * @return the texture itself allowing "fluent" like uniform updates
  71583. */
  71584. setInt(name: string, value: number): ProceduralTexture;
  71585. /**
  71586. * Set an array of floats in the shader.
  71587. * @param name Define the name of the uniform as defined in the shader
  71588. * @param value Define the value to give to the uniform
  71589. * @return the texture itself allowing "fluent" like uniform updates
  71590. */
  71591. setFloats(name: string, value: number[]): ProceduralTexture;
  71592. /**
  71593. * Set a vec3 in the shader from a Color3.
  71594. * @param name Define the name of the uniform as defined in the shader
  71595. * @param value Define the value to give to the uniform
  71596. * @return the texture itself allowing "fluent" like uniform updates
  71597. */
  71598. setColor3(name: string, value: Color3): ProceduralTexture;
  71599. /**
  71600. * Set a vec4 in the shader from a Color4.
  71601. * @param name Define the name of the uniform as defined in the shader
  71602. * @param value Define the value to give to the uniform
  71603. * @return the texture itself allowing "fluent" like uniform updates
  71604. */
  71605. setColor4(name: string, value: Color4): ProceduralTexture;
  71606. /**
  71607. * Set a vec2 in the shader from a Vector2.
  71608. * @param name Define the name of the uniform as defined in the shader
  71609. * @param value Define the value to give to the uniform
  71610. * @return the texture itself allowing "fluent" like uniform updates
  71611. */
  71612. setVector2(name: string, value: Vector2): ProceduralTexture;
  71613. /**
  71614. * Set a vec3 in the shader from a Vector3.
  71615. * @param name Define the name of the uniform as defined in the shader
  71616. * @param value Define the value to give to the uniform
  71617. * @return the texture itself allowing "fluent" like uniform updates
  71618. */
  71619. setVector3(name: string, value: Vector3): ProceduralTexture;
  71620. /**
  71621. * Set a mat4 in the shader from a MAtrix.
  71622. * @param name Define the name of the uniform as defined in the shader
  71623. * @param value Define the value to give to the uniform
  71624. * @return the texture itself allowing "fluent" like uniform updates
  71625. */
  71626. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71627. /**
  71628. * Render the texture to its associated render target.
  71629. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71630. */
  71631. render(useCameraPostProcess?: boolean): void;
  71632. /**
  71633. * Clone the texture.
  71634. * @returns the cloned texture
  71635. */
  71636. clone(): ProceduralTexture;
  71637. /**
  71638. * Dispose the texture and release its asoociated resources.
  71639. */
  71640. dispose(): void;
  71641. }
  71642. }
  71643. declare module BABYLON {
  71644. /**
  71645. * This represents the base class for particle system in Babylon.
  71646. * 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.
  71647. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71648. * @example https://doc.babylonjs.com/babylon101/particles
  71649. */
  71650. export class BaseParticleSystem {
  71651. /**
  71652. * Source color is added to the destination color without alpha affecting the result
  71653. */
  71654. static BLENDMODE_ONEONE: number;
  71655. /**
  71656. * Blend current color and particle color using particle’s alpha
  71657. */
  71658. static BLENDMODE_STANDARD: number;
  71659. /**
  71660. * Add current color and particle color multiplied by particle’s alpha
  71661. */
  71662. static BLENDMODE_ADD: number;
  71663. /**
  71664. * Multiply current color with particle color
  71665. */
  71666. static BLENDMODE_MULTIPLY: number;
  71667. /**
  71668. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71669. */
  71670. static BLENDMODE_MULTIPLYADD: number;
  71671. /**
  71672. * List of animations used by the particle system.
  71673. */
  71674. animations: Animation[];
  71675. /**
  71676. * The id of the Particle system.
  71677. */
  71678. id: string;
  71679. /**
  71680. * The friendly name of the Particle system.
  71681. */
  71682. name: string;
  71683. /**
  71684. * The rendering group used by the Particle system to chose when to render.
  71685. */
  71686. renderingGroupId: number;
  71687. /**
  71688. * The emitter represents the Mesh or position we are attaching the particle system to.
  71689. */
  71690. emitter: Nullable<AbstractMesh | Vector3>;
  71691. /**
  71692. * The maximum number of particles to emit per frame
  71693. */
  71694. emitRate: number;
  71695. /**
  71696. * If you want to launch only a few particles at once, that can be done, as well.
  71697. */
  71698. manualEmitCount: number;
  71699. /**
  71700. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71701. */
  71702. updateSpeed: number;
  71703. /**
  71704. * The amount of time the particle system is running (depends of the overall update speed).
  71705. */
  71706. targetStopDuration: number;
  71707. /**
  71708. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71709. */
  71710. disposeOnStop: boolean;
  71711. /**
  71712. * Minimum power of emitting particles.
  71713. */
  71714. minEmitPower: number;
  71715. /**
  71716. * Maximum power of emitting particles.
  71717. */
  71718. maxEmitPower: number;
  71719. /**
  71720. * Minimum life time of emitting particles.
  71721. */
  71722. minLifeTime: number;
  71723. /**
  71724. * Maximum life time of emitting particles.
  71725. */
  71726. maxLifeTime: number;
  71727. /**
  71728. * Minimum Size of emitting particles.
  71729. */
  71730. minSize: number;
  71731. /**
  71732. * Maximum Size of emitting particles.
  71733. */
  71734. maxSize: number;
  71735. /**
  71736. * Minimum scale of emitting particles on X axis.
  71737. */
  71738. minScaleX: number;
  71739. /**
  71740. * Maximum scale of emitting particles on X axis.
  71741. */
  71742. maxScaleX: number;
  71743. /**
  71744. * Minimum scale of emitting particles on Y axis.
  71745. */
  71746. minScaleY: number;
  71747. /**
  71748. * Maximum scale of emitting particles on Y axis.
  71749. */
  71750. maxScaleY: number;
  71751. /**
  71752. * Gets or sets the minimal initial rotation in radians.
  71753. */
  71754. minInitialRotation: number;
  71755. /**
  71756. * Gets or sets the maximal initial rotation in radians.
  71757. */
  71758. maxInitialRotation: number;
  71759. /**
  71760. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71761. */
  71762. minAngularSpeed: number;
  71763. /**
  71764. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71765. */
  71766. maxAngularSpeed: number;
  71767. /**
  71768. * The texture used to render each particle. (this can be a spritesheet)
  71769. */
  71770. particleTexture: Nullable<Texture>;
  71771. /**
  71772. * The layer mask we are rendering the particles through.
  71773. */
  71774. layerMask: number;
  71775. /**
  71776. * This can help using your own shader to render the particle system.
  71777. * The according effect will be created
  71778. */
  71779. customShader: any;
  71780. /**
  71781. * By default particle system starts as soon as they are created. This prevents the
  71782. * automatic start to happen and let you decide when to start emitting particles.
  71783. */
  71784. preventAutoStart: boolean;
  71785. private _noiseTexture;
  71786. /**
  71787. * Gets or sets a texture used to add random noise to particle positions
  71788. */
  71789. noiseTexture: Nullable<ProceduralTexture>;
  71790. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71791. noiseStrength: Vector3;
  71792. /**
  71793. * Callback triggered when the particle animation is ending.
  71794. */
  71795. onAnimationEnd: Nullable<() => void>;
  71796. /**
  71797. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71798. */
  71799. blendMode: number;
  71800. /**
  71801. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71802. * to override the particles.
  71803. */
  71804. forceDepthWrite: boolean;
  71805. /** 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 */
  71806. preWarmCycles: number;
  71807. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71808. preWarmStepOffset: number;
  71809. /**
  71810. * 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)
  71811. */
  71812. spriteCellChangeSpeed: number;
  71813. /**
  71814. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71815. */
  71816. startSpriteCellID: number;
  71817. /**
  71818. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71819. */
  71820. endSpriteCellID: number;
  71821. /**
  71822. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71823. */
  71824. spriteCellWidth: number;
  71825. /**
  71826. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71827. */
  71828. spriteCellHeight: number;
  71829. /**
  71830. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71831. */
  71832. spriteRandomStartCell: boolean;
  71833. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71834. translationPivot: Vector2;
  71835. /** @hidden */
  71836. protected _isAnimationSheetEnabled: boolean;
  71837. /**
  71838. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71839. */
  71840. beginAnimationOnStart: boolean;
  71841. /**
  71842. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71843. */
  71844. beginAnimationFrom: number;
  71845. /**
  71846. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71847. */
  71848. beginAnimationTo: number;
  71849. /**
  71850. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71851. */
  71852. beginAnimationLoop: boolean;
  71853. /**
  71854. * Gets or sets a world offset applied to all particles
  71855. */
  71856. worldOffset: Vector3;
  71857. /**
  71858. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71859. */
  71860. isAnimationSheetEnabled: boolean;
  71861. /**
  71862. * Get hosting scene
  71863. * @returns the scene
  71864. */
  71865. getScene(): Scene;
  71866. /**
  71867. * You can use gravity if you want to give an orientation to your particles.
  71868. */
  71869. gravity: Vector3;
  71870. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71871. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71872. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71873. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71874. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71875. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71876. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71877. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71878. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71879. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71880. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71881. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71882. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71883. /**
  71884. * Defines the delay in milliseconds before starting the system (0 by default)
  71885. */
  71886. startDelay: number;
  71887. /**
  71888. * Gets the current list of drag gradients.
  71889. * You must use addDragGradient and removeDragGradient to udpate this list
  71890. * @returns the list of drag gradients
  71891. */
  71892. getDragGradients(): Nullable<Array<FactorGradient>>;
  71893. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71894. limitVelocityDamping: number;
  71895. /**
  71896. * Gets the current list of limit velocity gradients.
  71897. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71898. * @returns the list of limit velocity gradients
  71899. */
  71900. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71901. /**
  71902. * Gets the current list of color gradients.
  71903. * You must use addColorGradient and removeColorGradient to udpate this list
  71904. * @returns the list of color gradients
  71905. */
  71906. getColorGradients(): Nullable<Array<ColorGradient>>;
  71907. /**
  71908. * Gets the current list of size gradients.
  71909. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71910. * @returns the list of size gradients
  71911. */
  71912. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71913. /**
  71914. * Gets the current list of color remap gradients.
  71915. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71916. * @returns the list of color remap gradients
  71917. */
  71918. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71919. /**
  71920. * Gets the current list of alpha remap gradients.
  71921. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71922. * @returns the list of alpha remap gradients
  71923. */
  71924. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71925. /**
  71926. * Gets the current list of life time gradients.
  71927. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71928. * @returns the list of life time gradients
  71929. */
  71930. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71931. /**
  71932. * Gets the current list of angular speed gradients.
  71933. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71934. * @returns the list of angular speed gradients
  71935. */
  71936. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71937. /**
  71938. * Gets the current list of velocity gradients.
  71939. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71940. * @returns the list of velocity gradients
  71941. */
  71942. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71943. /**
  71944. * Gets the current list of start size gradients.
  71945. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71946. * @returns the list of start size gradients
  71947. */
  71948. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71949. /**
  71950. * Gets the current list of emit rate gradients.
  71951. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71952. * @returns the list of emit rate gradients
  71953. */
  71954. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71955. /**
  71956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71957. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71958. */
  71959. direction1: Vector3;
  71960. /**
  71961. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71962. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71963. */
  71964. direction2: Vector3;
  71965. /**
  71966. * 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.
  71967. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71968. */
  71969. minEmitBox: Vector3;
  71970. /**
  71971. * 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.
  71972. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71973. */
  71974. maxEmitBox: Vector3;
  71975. /**
  71976. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71977. */
  71978. color1: Color4;
  71979. /**
  71980. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71981. */
  71982. color2: Color4;
  71983. /**
  71984. * Color the particle will have at the end of its lifetime
  71985. */
  71986. colorDead: Color4;
  71987. /**
  71988. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71989. */
  71990. textureMask: Color4;
  71991. /**
  71992. * The particle emitter type defines the emitter used by the particle system.
  71993. * It can be for example box, sphere, or cone...
  71994. */
  71995. particleEmitterType: IParticleEmitterType;
  71996. /** @hidden */
  71997. _isSubEmitter: boolean;
  71998. /**
  71999. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72000. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72001. */
  72002. billboardMode: number;
  72003. protected _isBillboardBased: boolean;
  72004. /**
  72005. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72006. */
  72007. isBillboardBased: boolean;
  72008. /**
  72009. * The scene the particle system belongs to.
  72010. */
  72011. protected _scene: Scene;
  72012. /**
  72013. * Local cache of defines for image processing.
  72014. */
  72015. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72016. /**
  72017. * Default configuration related to image processing available in the standard Material.
  72018. */
  72019. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72020. /**
  72021. * Gets the image processing configuration used either in this material.
  72022. */
  72023. /**
  72024. * Sets the Default image processing configuration used either in the this material.
  72025. *
  72026. * If sets to null, the scene one is in use.
  72027. */
  72028. imageProcessingConfiguration: ImageProcessingConfiguration;
  72029. /**
  72030. * Attaches a new image processing configuration to the Standard Material.
  72031. * @param configuration
  72032. */
  72033. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72034. /** @hidden */
  72035. protected _reset(): void;
  72036. /** @hidden */
  72037. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72038. /**
  72039. * Instantiates a particle system.
  72040. * 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.
  72041. * @param name The name of the particle system
  72042. */
  72043. constructor(name: string);
  72044. /**
  72045. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72046. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72047. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72048. * @returns the emitter
  72049. */
  72050. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72051. /**
  72052. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72053. * @param radius The radius of the hemisphere to emit from
  72054. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72055. * @returns the emitter
  72056. */
  72057. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72058. /**
  72059. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72060. * @param radius The radius of the sphere to emit from
  72061. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72062. * @returns the emitter
  72063. */
  72064. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72065. /**
  72066. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72067. * @param radius The radius of the sphere to emit from
  72068. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72069. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72070. * @returns the emitter
  72071. */
  72072. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72073. /**
  72074. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72075. * @param radius The radius of the emission cylinder
  72076. * @param height The height of the emission cylinder
  72077. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72078. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72079. * @returns the emitter
  72080. */
  72081. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72082. /**
  72083. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72084. * @param radius The radius of the cylinder to emit from
  72085. * @param height The height of the emission cylinder
  72086. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72087. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72088. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72089. * @returns the emitter
  72090. */
  72091. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72092. /**
  72093. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72094. * @param radius The radius of the cone to emit from
  72095. * @param angle The base angle of the cone
  72096. * @returns the emitter
  72097. */
  72098. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72099. /**
  72100. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72103. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72104. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72105. * @returns the emitter
  72106. */
  72107. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72108. }
  72109. }
  72110. declare module BABYLON {
  72111. /**
  72112. * Type of sub emitter
  72113. */
  72114. export enum SubEmitterType {
  72115. /**
  72116. * Attached to the particle over it's lifetime
  72117. */
  72118. ATTACHED = 0,
  72119. /**
  72120. * Created when the particle dies
  72121. */
  72122. END = 1
  72123. }
  72124. /**
  72125. * Sub emitter class used to emit particles from an existing particle
  72126. */
  72127. export class SubEmitter {
  72128. /**
  72129. * the particle system to be used by the sub emitter
  72130. */
  72131. particleSystem: ParticleSystem;
  72132. /**
  72133. * Type of the submitter (Default: END)
  72134. */
  72135. type: SubEmitterType;
  72136. /**
  72137. * 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)
  72138. * Note: This only is supported when using an emitter of type Mesh
  72139. */
  72140. inheritDirection: boolean;
  72141. /**
  72142. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72143. */
  72144. inheritedVelocityAmount: number;
  72145. /**
  72146. * Creates a sub emitter
  72147. * @param particleSystem the particle system to be used by the sub emitter
  72148. */
  72149. constructor(
  72150. /**
  72151. * the particle system to be used by the sub emitter
  72152. */
  72153. particleSystem: ParticleSystem);
  72154. /**
  72155. * Clones the sub emitter
  72156. * @returns the cloned sub emitter
  72157. */
  72158. clone(): SubEmitter;
  72159. /**
  72160. * Serialize current object to a JSON object
  72161. * @returns the serialized object
  72162. */
  72163. serialize(): any;
  72164. /** @hidden */
  72165. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72166. /**
  72167. * Creates a new SubEmitter from a serialized JSON version
  72168. * @param serializationObject defines the JSON object to read from
  72169. * @param scene defines the hosting scene
  72170. * @param rootUrl defines the rootUrl for data loading
  72171. * @returns a new SubEmitter
  72172. */
  72173. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72174. /** Release associated resources */
  72175. dispose(): void;
  72176. }
  72177. }
  72178. declare module BABYLON {
  72179. /** @hidden */
  72180. export var clipPlaneFragmentDeclaration: {
  72181. name: string;
  72182. shader: string;
  72183. };
  72184. }
  72185. declare module BABYLON {
  72186. /** @hidden */
  72187. export var imageProcessingDeclaration: {
  72188. name: string;
  72189. shader: string;
  72190. };
  72191. }
  72192. declare module BABYLON {
  72193. /** @hidden */
  72194. export var imageProcessingFunctions: {
  72195. name: string;
  72196. shader: string;
  72197. };
  72198. }
  72199. declare module BABYLON {
  72200. /** @hidden */
  72201. export var clipPlaneFragment: {
  72202. name: string;
  72203. shader: string;
  72204. };
  72205. }
  72206. declare module BABYLON {
  72207. /** @hidden */
  72208. export var particlesPixelShader: {
  72209. name: string;
  72210. shader: string;
  72211. };
  72212. }
  72213. declare module BABYLON {
  72214. /** @hidden */
  72215. export var clipPlaneVertexDeclaration: {
  72216. name: string;
  72217. shader: string;
  72218. };
  72219. }
  72220. declare module BABYLON {
  72221. /** @hidden */
  72222. export var clipPlaneVertex: {
  72223. name: string;
  72224. shader: string;
  72225. };
  72226. }
  72227. declare module BABYLON {
  72228. /** @hidden */
  72229. export var particlesVertexShader: {
  72230. name: string;
  72231. shader: string;
  72232. };
  72233. }
  72234. declare module BABYLON {
  72235. /**
  72236. * This represents a particle system in Babylon.
  72237. * 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.
  72238. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72239. * @example https://doc.babylonjs.com/babylon101/particles
  72240. */
  72241. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72242. /**
  72243. * Billboard mode will only apply to Y axis
  72244. */
  72245. static readonly BILLBOARDMODE_Y: number;
  72246. /**
  72247. * Billboard mode will apply to all axes
  72248. */
  72249. static readonly BILLBOARDMODE_ALL: number;
  72250. /**
  72251. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72252. */
  72253. static readonly BILLBOARDMODE_STRETCHED: number;
  72254. /**
  72255. * This function can be defined to provide custom update for active particles.
  72256. * This function will be called instead of regular update (age, position, color, etc.).
  72257. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72258. */
  72259. updateFunction: (particles: Particle[]) => void;
  72260. private _emitterWorldMatrix;
  72261. /**
  72262. * This function can be defined to specify initial direction for every new particle.
  72263. * It by default use the emitterType defined function
  72264. */
  72265. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72266. /**
  72267. * This function can be defined to specify initial position for every new particle.
  72268. * It by default use the emitterType defined function
  72269. */
  72270. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72271. /**
  72272. * @hidden
  72273. */
  72274. _inheritedVelocityOffset: Vector3;
  72275. /**
  72276. * An event triggered when the system is disposed
  72277. */
  72278. onDisposeObservable: Observable<ParticleSystem>;
  72279. private _onDisposeObserver;
  72280. /**
  72281. * Sets a callback that will be triggered when the system is disposed
  72282. */
  72283. onDispose: () => void;
  72284. private _particles;
  72285. private _epsilon;
  72286. private _capacity;
  72287. private _stockParticles;
  72288. private _newPartsExcess;
  72289. private _vertexData;
  72290. private _vertexBuffer;
  72291. private _vertexBuffers;
  72292. private _spriteBuffer;
  72293. private _indexBuffer;
  72294. private _effect;
  72295. private _customEffect;
  72296. private _cachedDefines;
  72297. private _scaledColorStep;
  72298. private _colorDiff;
  72299. private _scaledDirection;
  72300. private _scaledGravity;
  72301. private _currentRenderId;
  72302. private _alive;
  72303. private _useInstancing;
  72304. private _started;
  72305. private _stopped;
  72306. private _actualFrame;
  72307. private _scaledUpdateSpeed;
  72308. private _vertexBufferSize;
  72309. /** @hidden */
  72310. _currentEmitRateGradient: Nullable<FactorGradient>;
  72311. /** @hidden */
  72312. _currentEmitRate1: number;
  72313. /** @hidden */
  72314. _currentEmitRate2: number;
  72315. /** @hidden */
  72316. _currentStartSizeGradient: Nullable<FactorGradient>;
  72317. /** @hidden */
  72318. _currentStartSize1: number;
  72319. /** @hidden */
  72320. _currentStartSize2: number;
  72321. private readonly _rawTextureWidth;
  72322. private _rampGradientsTexture;
  72323. private _useRampGradients;
  72324. /** Gets or sets a boolean indicating that ramp gradients must be used
  72325. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72326. */
  72327. useRampGradients: boolean;
  72328. /**
  72329. * 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.
  72330. * 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: [])
  72331. */
  72332. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72333. private _subEmitters;
  72334. /**
  72335. * @hidden
  72336. * If the particle systems emitter should be disposed when the particle system is disposed
  72337. */
  72338. _disposeEmitterOnDispose: boolean;
  72339. /**
  72340. * The current active Sub-systems, this property is used by the root particle system only.
  72341. */
  72342. activeSubSystems: Array<ParticleSystem>;
  72343. private _rootParticleSystem;
  72344. /**
  72345. * Gets the current list of active particles
  72346. */
  72347. readonly particles: Particle[];
  72348. /**
  72349. * Returns the string "ParticleSystem"
  72350. * @returns a string containing the class name
  72351. */
  72352. getClassName(): string;
  72353. /**
  72354. * Instantiates a particle system.
  72355. * 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.
  72356. * @param name The name of the particle system
  72357. * @param capacity The max number of particles alive at the same time
  72358. * @param scene The scene the particle system belongs to
  72359. * @param customEffect a custom effect used to change the way particles are rendered by default
  72360. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72361. * @param epsilon Offset used to render the particles
  72362. */
  72363. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72364. private _addFactorGradient;
  72365. private _removeFactorGradient;
  72366. /**
  72367. * Adds a new life time gradient
  72368. * @param gradient defines the gradient to use (between 0 and 1)
  72369. * @param factor defines the life time factor to affect to the specified gradient
  72370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72371. * @returns the current particle system
  72372. */
  72373. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72374. /**
  72375. * Remove a specific life time gradient
  72376. * @param gradient defines the gradient to remove
  72377. * @returns the current particle system
  72378. */
  72379. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72380. /**
  72381. * Adds a new size gradient
  72382. * @param gradient defines the gradient to use (between 0 and 1)
  72383. * @param factor defines the size factor to affect to the specified gradient
  72384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72385. * @returns the current particle system
  72386. */
  72387. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72388. /**
  72389. * Remove a specific size gradient
  72390. * @param gradient defines the gradient to remove
  72391. * @returns the current particle system
  72392. */
  72393. removeSizeGradient(gradient: number): IParticleSystem;
  72394. /**
  72395. * Adds a new color remap gradient
  72396. * @param gradient defines the gradient to use (between 0 and 1)
  72397. * @param min defines the color remap minimal range
  72398. * @param max defines the color remap maximal range
  72399. * @returns the current particle system
  72400. */
  72401. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72402. /**
  72403. * Remove a specific color remap gradient
  72404. * @param gradient defines the gradient to remove
  72405. * @returns the current particle system
  72406. */
  72407. removeColorRemapGradient(gradient: number): IParticleSystem;
  72408. /**
  72409. * Adds a new alpha remap gradient
  72410. * @param gradient defines the gradient to use (between 0 and 1)
  72411. * @param min defines the alpha remap minimal range
  72412. * @param max defines the alpha remap maximal range
  72413. * @returns the current particle system
  72414. */
  72415. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72416. /**
  72417. * Remove a specific alpha remap gradient
  72418. * @param gradient defines the gradient to remove
  72419. * @returns the current particle system
  72420. */
  72421. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72422. /**
  72423. * Adds a new angular speed gradient
  72424. * @param gradient defines the gradient to use (between 0 and 1)
  72425. * @param factor defines the angular speed to affect to the specified gradient
  72426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72427. * @returns the current particle system
  72428. */
  72429. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72430. /**
  72431. * Remove a specific angular speed gradient
  72432. * @param gradient defines the gradient to remove
  72433. * @returns the current particle system
  72434. */
  72435. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72436. /**
  72437. * Adds a new velocity gradient
  72438. * @param gradient defines the gradient to use (between 0 and 1)
  72439. * @param factor defines the velocity to affect to the specified gradient
  72440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72441. * @returns the current particle system
  72442. */
  72443. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72444. /**
  72445. * Remove a specific velocity gradient
  72446. * @param gradient defines the gradient to remove
  72447. * @returns the current particle system
  72448. */
  72449. removeVelocityGradient(gradient: number): IParticleSystem;
  72450. /**
  72451. * Adds a new limit velocity gradient
  72452. * @param gradient defines the gradient to use (between 0 and 1)
  72453. * @param factor defines the limit velocity value to affect to the specified gradient
  72454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72455. * @returns the current particle system
  72456. */
  72457. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72458. /**
  72459. * Remove a specific limit velocity gradient
  72460. * @param gradient defines the gradient to remove
  72461. * @returns the current particle system
  72462. */
  72463. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72464. /**
  72465. * Adds a new drag gradient
  72466. * @param gradient defines the gradient to use (between 0 and 1)
  72467. * @param factor defines the drag value to affect to the specified gradient
  72468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72469. * @returns the current particle system
  72470. */
  72471. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72472. /**
  72473. * Remove a specific drag gradient
  72474. * @param gradient defines the gradient to remove
  72475. * @returns the current particle system
  72476. */
  72477. removeDragGradient(gradient: number): IParticleSystem;
  72478. /**
  72479. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72480. * @param gradient defines the gradient to use (between 0 and 1)
  72481. * @param factor defines the emit rate value to affect to the specified gradient
  72482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72483. * @returns the current particle system
  72484. */
  72485. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72486. /**
  72487. * Remove a specific emit rate gradient
  72488. * @param gradient defines the gradient to remove
  72489. * @returns the current particle system
  72490. */
  72491. removeEmitRateGradient(gradient: number): IParticleSystem;
  72492. /**
  72493. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72494. * @param gradient defines the gradient to use (between 0 and 1)
  72495. * @param factor defines the start size value to affect to the specified gradient
  72496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72497. * @returns the current particle system
  72498. */
  72499. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72500. /**
  72501. * Remove a specific start size gradient
  72502. * @param gradient defines the gradient to remove
  72503. * @returns the current particle system
  72504. */
  72505. removeStartSizeGradient(gradient: number): IParticleSystem;
  72506. private _createRampGradientTexture;
  72507. /**
  72508. * Gets the current list of ramp gradients.
  72509. * You must use addRampGradient and removeRampGradient to udpate this list
  72510. * @returns the list of ramp gradients
  72511. */
  72512. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72513. /**
  72514. * Adds a new ramp gradient used to remap particle colors
  72515. * @param gradient defines the gradient to use (between 0 and 1)
  72516. * @param color defines the color to affect to the specified gradient
  72517. * @returns the current particle system
  72518. */
  72519. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72520. /**
  72521. * Remove a specific ramp gradient
  72522. * @param gradient defines the gradient to remove
  72523. * @returns the current particle system
  72524. */
  72525. removeRampGradient(gradient: number): ParticleSystem;
  72526. /**
  72527. * Adds a new color gradient
  72528. * @param gradient defines the gradient to use (between 0 and 1)
  72529. * @param color1 defines the color to affect to the specified gradient
  72530. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72531. * @returns this particle system
  72532. */
  72533. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72534. /**
  72535. * Remove a specific color gradient
  72536. * @param gradient defines the gradient to remove
  72537. * @returns this particle system
  72538. */
  72539. removeColorGradient(gradient: number): IParticleSystem;
  72540. private _fetchR;
  72541. protected _reset(): void;
  72542. private _resetEffect;
  72543. private _createVertexBuffers;
  72544. private _createIndexBuffer;
  72545. /**
  72546. * Gets the maximum number of particles active at the same time.
  72547. * @returns The max number of active particles.
  72548. */
  72549. getCapacity(): number;
  72550. /**
  72551. * Gets whether there are still active particles in the system.
  72552. * @returns True if it is alive, otherwise false.
  72553. */
  72554. isAlive(): boolean;
  72555. /**
  72556. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72557. * @returns True if it has been started, otherwise false.
  72558. */
  72559. isStarted(): boolean;
  72560. private _prepareSubEmitterInternalArray;
  72561. /**
  72562. * Starts the particle system and begins to emit
  72563. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72564. */
  72565. start(delay?: number): void;
  72566. /**
  72567. * Stops the particle system.
  72568. * @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.
  72569. */
  72570. stop(stopSubEmitters?: boolean): void;
  72571. /**
  72572. * Remove all active particles
  72573. */
  72574. reset(): void;
  72575. /**
  72576. * @hidden (for internal use only)
  72577. */
  72578. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72579. /**
  72580. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72581. * Its lifetime will start back at 0.
  72582. */
  72583. recycleParticle: (particle: Particle) => void;
  72584. private _stopSubEmitters;
  72585. private _createParticle;
  72586. private _removeFromRoot;
  72587. private _emitFromParticle;
  72588. private _update;
  72589. /** @hidden */
  72590. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72591. /** @hidden */
  72592. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72593. /** @hidden */
  72594. private _getEffect;
  72595. /**
  72596. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72597. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72598. */
  72599. animate(preWarmOnly?: boolean): void;
  72600. private _appendParticleVertices;
  72601. /**
  72602. * Rebuilds the particle system.
  72603. */
  72604. rebuild(): void;
  72605. /**
  72606. * Is this system ready to be used/rendered
  72607. * @return true if the system is ready
  72608. */
  72609. isReady(): boolean;
  72610. private _render;
  72611. /**
  72612. * Renders the particle system in its current state.
  72613. * @returns the current number of particles
  72614. */
  72615. render(): number;
  72616. /**
  72617. * Disposes the particle system and free the associated resources
  72618. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72619. */
  72620. dispose(disposeTexture?: boolean): void;
  72621. /**
  72622. * Clones the particle system.
  72623. * @param name The name of the cloned object
  72624. * @param newEmitter The new emitter to use
  72625. * @returns the cloned particle system
  72626. */
  72627. clone(name: string, newEmitter: any): ParticleSystem;
  72628. /**
  72629. * Serializes the particle system to a JSON object.
  72630. * @returns the JSON object
  72631. */
  72632. serialize(): any;
  72633. /** @hidden */
  72634. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72635. /** @hidden */
  72636. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72637. /**
  72638. * Parses a JSON object to create a particle system.
  72639. * @param parsedParticleSystem The JSON object to parse
  72640. * @param scene The scene to create the particle system in
  72641. * @param rootUrl The root url to use to load external dependencies like texture
  72642. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72643. * @returns the Parsed particle system
  72644. */
  72645. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72646. }
  72647. }
  72648. declare module BABYLON {
  72649. /**
  72650. * A particle represents one of the element emitted by a particle system.
  72651. * This is mainly define by its coordinates, direction, velocity and age.
  72652. */
  72653. export class Particle {
  72654. /**
  72655. * The particle system the particle belongs to.
  72656. */
  72657. particleSystem: ParticleSystem;
  72658. private static _Count;
  72659. /**
  72660. * Unique ID of the particle
  72661. */
  72662. id: number;
  72663. /**
  72664. * The world position of the particle in the scene.
  72665. */
  72666. position: Vector3;
  72667. /**
  72668. * The world direction of the particle in the scene.
  72669. */
  72670. direction: Vector3;
  72671. /**
  72672. * The color of the particle.
  72673. */
  72674. color: Color4;
  72675. /**
  72676. * The color change of the particle per step.
  72677. */
  72678. colorStep: Color4;
  72679. /**
  72680. * Defines how long will the life of the particle be.
  72681. */
  72682. lifeTime: number;
  72683. /**
  72684. * The current age of the particle.
  72685. */
  72686. age: number;
  72687. /**
  72688. * The current size of the particle.
  72689. */
  72690. size: number;
  72691. /**
  72692. * The current scale of the particle.
  72693. */
  72694. scale: Vector2;
  72695. /**
  72696. * The current angle of the particle.
  72697. */
  72698. angle: number;
  72699. /**
  72700. * Defines how fast is the angle changing.
  72701. */
  72702. angularSpeed: number;
  72703. /**
  72704. * Defines the cell index used by the particle to be rendered from a sprite.
  72705. */
  72706. cellIndex: number;
  72707. /**
  72708. * The information required to support color remapping
  72709. */
  72710. remapData: Vector4;
  72711. /** @hidden */
  72712. _randomCellOffset?: number;
  72713. /** @hidden */
  72714. _initialDirection: Nullable<Vector3>;
  72715. /** @hidden */
  72716. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72717. /** @hidden */
  72718. _initialStartSpriteCellID: number;
  72719. /** @hidden */
  72720. _initialEndSpriteCellID: number;
  72721. /** @hidden */
  72722. _currentColorGradient: Nullable<ColorGradient>;
  72723. /** @hidden */
  72724. _currentColor1: Color4;
  72725. /** @hidden */
  72726. _currentColor2: Color4;
  72727. /** @hidden */
  72728. _currentSizeGradient: Nullable<FactorGradient>;
  72729. /** @hidden */
  72730. _currentSize1: number;
  72731. /** @hidden */
  72732. _currentSize2: number;
  72733. /** @hidden */
  72734. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72735. /** @hidden */
  72736. _currentAngularSpeed1: number;
  72737. /** @hidden */
  72738. _currentAngularSpeed2: number;
  72739. /** @hidden */
  72740. _currentVelocityGradient: Nullable<FactorGradient>;
  72741. /** @hidden */
  72742. _currentVelocity1: number;
  72743. /** @hidden */
  72744. _currentVelocity2: number;
  72745. /** @hidden */
  72746. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72747. /** @hidden */
  72748. _currentLimitVelocity1: number;
  72749. /** @hidden */
  72750. _currentLimitVelocity2: number;
  72751. /** @hidden */
  72752. _currentDragGradient: Nullable<FactorGradient>;
  72753. /** @hidden */
  72754. _currentDrag1: number;
  72755. /** @hidden */
  72756. _currentDrag2: number;
  72757. /** @hidden */
  72758. _randomNoiseCoordinates1: Vector3;
  72759. /** @hidden */
  72760. _randomNoiseCoordinates2: Vector3;
  72761. /**
  72762. * Creates a new instance Particle
  72763. * @param particleSystem the particle system the particle belongs to
  72764. */
  72765. constructor(
  72766. /**
  72767. * The particle system the particle belongs to.
  72768. */
  72769. particleSystem: ParticleSystem);
  72770. private updateCellInfoFromSystem;
  72771. /**
  72772. * Defines how the sprite cell index is updated for the particle
  72773. */
  72774. updateCellIndex(): void;
  72775. /** @hidden */
  72776. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72777. /** @hidden */
  72778. _inheritParticleInfoToSubEmitters(): void;
  72779. /** @hidden */
  72780. _reset(): void;
  72781. /**
  72782. * Copy the properties of particle to another one.
  72783. * @param other the particle to copy the information to.
  72784. */
  72785. copyTo(other: Particle): void;
  72786. }
  72787. }
  72788. declare module BABYLON {
  72789. /**
  72790. * Particle emitter represents a volume emitting particles.
  72791. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72792. */
  72793. export interface IParticleEmitterType {
  72794. /**
  72795. * Called by the particle System when the direction is computed for the created particle.
  72796. * @param worldMatrix is the world matrix of the particle system
  72797. * @param directionToUpdate is the direction vector to update with the result
  72798. * @param particle is the particle we are computed the direction for
  72799. */
  72800. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72801. /**
  72802. * Called by the particle System when the position is computed for the created particle.
  72803. * @param worldMatrix is the world matrix of the particle system
  72804. * @param positionToUpdate is the position vector to update with the result
  72805. * @param particle is the particle we are computed the position for
  72806. */
  72807. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72808. /**
  72809. * Clones the current emitter and returns a copy of it
  72810. * @returns the new emitter
  72811. */
  72812. clone(): IParticleEmitterType;
  72813. /**
  72814. * Called by the GPUParticleSystem to setup the update shader
  72815. * @param effect defines the update shader
  72816. */
  72817. applyToShader(effect: Effect): void;
  72818. /**
  72819. * Returns a string to use to update the GPU particles update shader
  72820. * @returns the effect defines string
  72821. */
  72822. getEffectDefines(): string;
  72823. /**
  72824. * Returns a string representing the class name
  72825. * @returns a string containing the class name
  72826. */
  72827. getClassName(): string;
  72828. /**
  72829. * Serializes the particle system to a JSON object.
  72830. * @returns the JSON object
  72831. */
  72832. serialize(): any;
  72833. /**
  72834. * Parse properties from a JSON object
  72835. * @param serializationObject defines the JSON object
  72836. */
  72837. parse(serializationObject: any): void;
  72838. }
  72839. }
  72840. declare module BABYLON {
  72841. /**
  72842. * Particle emitter emitting particles from the inside of a box.
  72843. * It emits the particles randomly between 2 given directions.
  72844. */
  72845. export class BoxParticleEmitter implements IParticleEmitterType {
  72846. /**
  72847. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72848. */
  72849. direction1: Vector3;
  72850. /**
  72851. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72852. */
  72853. direction2: Vector3;
  72854. /**
  72855. * 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.
  72856. */
  72857. minEmitBox: Vector3;
  72858. /**
  72859. * 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.
  72860. */
  72861. maxEmitBox: Vector3;
  72862. /**
  72863. * Creates a new instance BoxParticleEmitter
  72864. */
  72865. constructor();
  72866. /**
  72867. * Called by the particle System when the direction is computed for the created particle.
  72868. * @param worldMatrix is the world matrix of the particle system
  72869. * @param directionToUpdate is the direction vector to update with the result
  72870. * @param particle is the particle we are computed the direction for
  72871. */
  72872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72873. /**
  72874. * Called by the particle System when the position is computed for the created particle.
  72875. * @param worldMatrix is the world matrix of the particle system
  72876. * @param positionToUpdate is the position vector to update with the result
  72877. * @param particle is the particle we are computed the position for
  72878. */
  72879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72880. /**
  72881. * Clones the current emitter and returns a copy of it
  72882. * @returns the new emitter
  72883. */
  72884. clone(): BoxParticleEmitter;
  72885. /**
  72886. * Called by the GPUParticleSystem to setup the update shader
  72887. * @param effect defines the update shader
  72888. */
  72889. applyToShader(effect: Effect): void;
  72890. /**
  72891. * Returns a string to use to update the GPU particles update shader
  72892. * @returns a string containng the defines string
  72893. */
  72894. getEffectDefines(): string;
  72895. /**
  72896. * Returns the string "BoxParticleEmitter"
  72897. * @returns a string containing the class name
  72898. */
  72899. getClassName(): string;
  72900. /**
  72901. * Serializes the particle system to a JSON object.
  72902. * @returns the JSON object
  72903. */
  72904. serialize(): any;
  72905. /**
  72906. * Parse properties from a JSON object
  72907. * @param serializationObject defines the JSON object
  72908. */
  72909. parse(serializationObject: any): void;
  72910. }
  72911. }
  72912. declare module BABYLON {
  72913. /**
  72914. * Particle emitter emitting particles from the inside of a cone.
  72915. * It emits the particles alongside the cone volume from the base to the particle.
  72916. * The emission direction might be randomized.
  72917. */
  72918. export class ConeParticleEmitter implements IParticleEmitterType {
  72919. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72920. directionRandomizer: number;
  72921. private _radius;
  72922. private _angle;
  72923. private _height;
  72924. /**
  72925. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72926. */
  72927. radiusRange: number;
  72928. /**
  72929. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72930. */
  72931. heightRange: number;
  72932. /**
  72933. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72934. */
  72935. emitFromSpawnPointOnly: boolean;
  72936. /**
  72937. * Gets or sets the radius of the emission cone
  72938. */
  72939. radius: number;
  72940. /**
  72941. * Gets or sets the angle of the emission cone
  72942. */
  72943. angle: number;
  72944. private _buildHeight;
  72945. /**
  72946. * Creates a new instance ConeParticleEmitter
  72947. * @param radius the radius of the emission cone (1 by default)
  72948. * @param angle the cone base angle (PI by default)
  72949. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72950. */
  72951. constructor(radius?: number, angle?: number,
  72952. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72953. directionRandomizer?: number);
  72954. /**
  72955. * Called by the particle System when the direction is computed for the created particle.
  72956. * @param worldMatrix is the world matrix of the particle system
  72957. * @param directionToUpdate is the direction vector to update with the result
  72958. * @param particle is the particle we are computed the direction for
  72959. */
  72960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72961. /**
  72962. * Called by the particle System when the position is computed for the created particle.
  72963. * @param worldMatrix is the world matrix of the particle system
  72964. * @param positionToUpdate is the position vector to update with the result
  72965. * @param particle is the particle we are computed the position for
  72966. */
  72967. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72968. /**
  72969. * Clones the current emitter and returns a copy of it
  72970. * @returns the new emitter
  72971. */
  72972. clone(): ConeParticleEmitter;
  72973. /**
  72974. * Called by the GPUParticleSystem to setup the update shader
  72975. * @param effect defines the update shader
  72976. */
  72977. applyToShader(effect: Effect): void;
  72978. /**
  72979. * Returns a string to use to update the GPU particles update shader
  72980. * @returns a string containng the defines string
  72981. */
  72982. getEffectDefines(): string;
  72983. /**
  72984. * Returns the string "ConeParticleEmitter"
  72985. * @returns a string containing the class name
  72986. */
  72987. getClassName(): string;
  72988. /**
  72989. * Serializes the particle system to a JSON object.
  72990. * @returns the JSON object
  72991. */
  72992. serialize(): any;
  72993. /**
  72994. * Parse properties from a JSON object
  72995. * @param serializationObject defines the JSON object
  72996. */
  72997. parse(serializationObject: any): void;
  72998. }
  72999. }
  73000. declare module BABYLON {
  73001. /**
  73002. * Particle emitter emitting particles from the inside of a cylinder.
  73003. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73004. */
  73005. export class CylinderParticleEmitter implements IParticleEmitterType {
  73006. /**
  73007. * The radius of the emission cylinder.
  73008. */
  73009. radius: number;
  73010. /**
  73011. * The height of the emission cylinder.
  73012. */
  73013. height: number;
  73014. /**
  73015. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73016. */
  73017. radiusRange: number;
  73018. /**
  73019. * How much to randomize the particle direction [0-1].
  73020. */
  73021. directionRandomizer: number;
  73022. /**
  73023. * Creates a new instance CylinderParticleEmitter
  73024. * @param radius the radius of the emission cylinder (1 by default)
  73025. * @param height the height of the emission cylinder (1 by default)
  73026. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73027. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73028. */
  73029. constructor(
  73030. /**
  73031. * The radius of the emission cylinder.
  73032. */
  73033. radius?: number,
  73034. /**
  73035. * The height of the emission cylinder.
  73036. */
  73037. height?: number,
  73038. /**
  73039. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73040. */
  73041. radiusRange?: number,
  73042. /**
  73043. * How much to randomize the particle direction [0-1].
  73044. */
  73045. directionRandomizer?: number);
  73046. /**
  73047. * Called by the particle System when the direction is computed for the created particle.
  73048. * @param worldMatrix is the world matrix of the particle system
  73049. * @param directionToUpdate is the direction vector to update with the result
  73050. * @param particle is the particle we are computed the direction for
  73051. */
  73052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73053. /**
  73054. * Called by the particle System when the position is computed for the created particle.
  73055. * @param worldMatrix is the world matrix of the particle system
  73056. * @param positionToUpdate is the position vector to update with the result
  73057. * @param particle is the particle we are computed the position for
  73058. */
  73059. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73060. /**
  73061. * Clones the current emitter and returns a copy of it
  73062. * @returns the new emitter
  73063. */
  73064. clone(): CylinderParticleEmitter;
  73065. /**
  73066. * Called by the GPUParticleSystem to setup the update shader
  73067. * @param effect defines the update shader
  73068. */
  73069. applyToShader(effect: Effect): void;
  73070. /**
  73071. * Returns a string to use to update the GPU particles update shader
  73072. * @returns a string containng the defines string
  73073. */
  73074. getEffectDefines(): string;
  73075. /**
  73076. * Returns the string "CylinderParticleEmitter"
  73077. * @returns a string containing the class name
  73078. */
  73079. getClassName(): string;
  73080. /**
  73081. * Serializes the particle system to a JSON object.
  73082. * @returns the JSON object
  73083. */
  73084. serialize(): any;
  73085. /**
  73086. * Parse properties from a JSON object
  73087. * @param serializationObject defines the JSON object
  73088. */
  73089. parse(serializationObject: any): void;
  73090. }
  73091. /**
  73092. * Particle emitter emitting particles from the inside of a cylinder.
  73093. * It emits the particles randomly between two vectors.
  73094. */
  73095. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73096. /**
  73097. * The min limit of the emission direction.
  73098. */
  73099. direction1: Vector3;
  73100. /**
  73101. * The max limit of the emission direction.
  73102. */
  73103. direction2: Vector3;
  73104. /**
  73105. * Creates a new instance CylinderDirectedParticleEmitter
  73106. * @param radius the radius of the emission cylinder (1 by default)
  73107. * @param height the height of the emission cylinder (1 by default)
  73108. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73109. * @param direction1 the min limit of the emission direction (up vector by default)
  73110. * @param direction2 the max limit of the emission direction (up vector by default)
  73111. */
  73112. constructor(radius?: number, height?: number, radiusRange?: number,
  73113. /**
  73114. * The min limit of the emission direction.
  73115. */
  73116. direction1?: Vector3,
  73117. /**
  73118. * The max limit of the emission direction.
  73119. */
  73120. direction2?: Vector3);
  73121. /**
  73122. * Called by the particle System when the direction is computed for the created particle.
  73123. * @param worldMatrix is the world matrix of the particle system
  73124. * @param directionToUpdate is the direction vector to update with the result
  73125. * @param particle is the particle we are computed the direction for
  73126. */
  73127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73128. /**
  73129. * Clones the current emitter and returns a copy of it
  73130. * @returns the new emitter
  73131. */
  73132. clone(): CylinderDirectedParticleEmitter;
  73133. /**
  73134. * Called by the GPUParticleSystem to setup the update shader
  73135. * @param effect defines the update shader
  73136. */
  73137. applyToShader(effect: Effect): void;
  73138. /**
  73139. * Returns a string to use to update the GPU particles update shader
  73140. * @returns a string containng the defines string
  73141. */
  73142. getEffectDefines(): string;
  73143. /**
  73144. * Returns the string "CylinderDirectedParticleEmitter"
  73145. * @returns a string containing the class name
  73146. */
  73147. getClassName(): string;
  73148. /**
  73149. * Serializes the particle system to a JSON object.
  73150. * @returns the JSON object
  73151. */
  73152. serialize(): any;
  73153. /**
  73154. * Parse properties from a JSON object
  73155. * @param serializationObject defines the JSON object
  73156. */
  73157. parse(serializationObject: any): void;
  73158. }
  73159. }
  73160. declare module BABYLON {
  73161. /**
  73162. * Particle emitter emitting particles from the inside of a hemisphere.
  73163. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73164. */
  73165. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73166. /**
  73167. * The radius of the emission hemisphere.
  73168. */
  73169. radius: number;
  73170. /**
  73171. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73172. */
  73173. radiusRange: number;
  73174. /**
  73175. * How much to randomize the particle direction [0-1].
  73176. */
  73177. directionRandomizer: number;
  73178. /**
  73179. * Creates a new instance HemisphericParticleEmitter
  73180. * @param radius the radius of the emission hemisphere (1 by default)
  73181. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73182. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73183. */
  73184. constructor(
  73185. /**
  73186. * The radius of the emission hemisphere.
  73187. */
  73188. radius?: number,
  73189. /**
  73190. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73191. */
  73192. radiusRange?: number,
  73193. /**
  73194. * How much to randomize the particle direction [0-1].
  73195. */
  73196. directionRandomizer?: number);
  73197. /**
  73198. * Called by the particle System when the direction is computed for the created particle.
  73199. * @param worldMatrix is the world matrix of the particle system
  73200. * @param directionToUpdate is the direction vector to update with the result
  73201. * @param particle is the particle we are computed the direction for
  73202. */
  73203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73204. /**
  73205. * Called by the particle System when the position is computed for the created particle.
  73206. * @param worldMatrix is the world matrix of the particle system
  73207. * @param positionToUpdate is the position vector to update with the result
  73208. * @param particle is the particle we are computed the position for
  73209. */
  73210. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73211. /**
  73212. * Clones the current emitter and returns a copy of it
  73213. * @returns the new emitter
  73214. */
  73215. clone(): HemisphericParticleEmitter;
  73216. /**
  73217. * Called by the GPUParticleSystem to setup the update shader
  73218. * @param effect defines the update shader
  73219. */
  73220. applyToShader(effect: Effect): void;
  73221. /**
  73222. * Returns a string to use to update the GPU particles update shader
  73223. * @returns a string containng the defines string
  73224. */
  73225. getEffectDefines(): string;
  73226. /**
  73227. * Returns the string "HemisphericParticleEmitter"
  73228. * @returns a string containing the class name
  73229. */
  73230. getClassName(): string;
  73231. /**
  73232. * Serializes the particle system to a JSON object.
  73233. * @returns the JSON object
  73234. */
  73235. serialize(): any;
  73236. /**
  73237. * Parse properties from a JSON object
  73238. * @param serializationObject defines the JSON object
  73239. */
  73240. parse(serializationObject: any): void;
  73241. }
  73242. }
  73243. declare module BABYLON {
  73244. /**
  73245. * Particle emitter emitting particles from a point.
  73246. * It emits the particles randomly between 2 given directions.
  73247. */
  73248. export class PointParticleEmitter implements IParticleEmitterType {
  73249. /**
  73250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73251. */
  73252. direction1: Vector3;
  73253. /**
  73254. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73255. */
  73256. direction2: Vector3;
  73257. /**
  73258. * Creates a new instance PointParticleEmitter
  73259. */
  73260. constructor();
  73261. /**
  73262. * Called by the particle System when the direction is computed for the created particle.
  73263. * @param worldMatrix is the world matrix of the particle system
  73264. * @param directionToUpdate is the direction vector to update with the result
  73265. * @param particle is the particle we are computed the direction for
  73266. */
  73267. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73268. /**
  73269. * Called by the particle System when the position is computed for the created particle.
  73270. * @param worldMatrix is the world matrix of the particle system
  73271. * @param positionToUpdate is the position vector to update with the result
  73272. * @param particle is the particle we are computed the position for
  73273. */
  73274. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73275. /**
  73276. * Clones the current emitter and returns a copy of it
  73277. * @returns the new emitter
  73278. */
  73279. clone(): PointParticleEmitter;
  73280. /**
  73281. * Called by the GPUParticleSystem to setup the update shader
  73282. * @param effect defines the update shader
  73283. */
  73284. applyToShader(effect: Effect): void;
  73285. /**
  73286. * Returns a string to use to update the GPU particles update shader
  73287. * @returns a string containng the defines string
  73288. */
  73289. getEffectDefines(): string;
  73290. /**
  73291. * Returns the string "PointParticleEmitter"
  73292. * @returns a string containing the class name
  73293. */
  73294. getClassName(): string;
  73295. /**
  73296. * Serializes the particle system to a JSON object.
  73297. * @returns the JSON object
  73298. */
  73299. serialize(): any;
  73300. /**
  73301. * Parse properties from a JSON object
  73302. * @param serializationObject defines the JSON object
  73303. */
  73304. parse(serializationObject: any): void;
  73305. }
  73306. }
  73307. declare module BABYLON {
  73308. /**
  73309. * Particle emitter emitting particles from the inside of a sphere.
  73310. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73311. */
  73312. export class SphereParticleEmitter implements IParticleEmitterType {
  73313. /**
  73314. * The radius of the emission sphere.
  73315. */
  73316. radius: number;
  73317. /**
  73318. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73319. */
  73320. radiusRange: number;
  73321. /**
  73322. * How much to randomize the particle direction [0-1].
  73323. */
  73324. directionRandomizer: number;
  73325. /**
  73326. * Creates a new instance SphereParticleEmitter
  73327. * @param radius the radius of the emission sphere (1 by default)
  73328. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73329. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73330. */
  73331. constructor(
  73332. /**
  73333. * The radius of the emission sphere.
  73334. */
  73335. radius?: number,
  73336. /**
  73337. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73338. */
  73339. radiusRange?: number,
  73340. /**
  73341. * How much to randomize the particle direction [0-1].
  73342. */
  73343. directionRandomizer?: number);
  73344. /**
  73345. * Called by the particle System when the direction is computed for the created particle.
  73346. * @param worldMatrix is the world matrix of the particle system
  73347. * @param directionToUpdate is the direction vector to update with the result
  73348. * @param particle is the particle we are computed the direction for
  73349. */
  73350. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73351. /**
  73352. * Called by the particle System when the position is computed for the created particle.
  73353. * @param worldMatrix is the world matrix of the particle system
  73354. * @param positionToUpdate is the position vector to update with the result
  73355. * @param particle is the particle we are computed the position for
  73356. */
  73357. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73358. /**
  73359. * Clones the current emitter and returns a copy of it
  73360. * @returns the new emitter
  73361. */
  73362. clone(): SphereParticleEmitter;
  73363. /**
  73364. * Called by the GPUParticleSystem to setup the update shader
  73365. * @param effect defines the update shader
  73366. */
  73367. applyToShader(effect: Effect): void;
  73368. /**
  73369. * Returns a string to use to update the GPU particles update shader
  73370. * @returns a string containng the defines string
  73371. */
  73372. getEffectDefines(): string;
  73373. /**
  73374. * Returns the string "SphereParticleEmitter"
  73375. * @returns a string containing the class name
  73376. */
  73377. getClassName(): string;
  73378. /**
  73379. * Serializes the particle system to a JSON object.
  73380. * @returns the JSON object
  73381. */
  73382. serialize(): any;
  73383. /**
  73384. * Parse properties from a JSON object
  73385. * @param serializationObject defines the JSON object
  73386. */
  73387. parse(serializationObject: any): void;
  73388. }
  73389. /**
  73390. * Particle emitter emitting particles from the inside of a sphere.
  73391. * It emits the particles randomly between two vectors.
  73392. */
  73393. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73394. /**
  73395. * The min limit of the emission direction.
  73396. */
  73397. direction1: Vector3;
  73398. /**
  73399. * The max limit of the emission direction.
  73400. */
  73401. direction2: Vector3;
  73402. /**
  73403. * Creates a new instance SphereDirectedParticleEmitter
  73404. * @param radius the radius of the emission sphere (1 by default)
  73405. * @param direction1 the min limit of the emission direction (up vector by default)
  73406. * @param direction2 the max limit of the emission direction (up vector by default)
  73407. */
  73408. constructor(radius?: number,
  73409. /**
  73410. * The min limit of the emission direction.
  73411. */
  73412. direction1?: Vector3,
  73413. /**
  73414. * The max limit of the emission direction.
  73415. */
  73416. direction2?: Vector3);
  73417. /**
  73418. * Called by the particle System when the direction is computed for the created particle.
  73419. * @param worldMatrix is the world matrix of the particle system
  73420. * @param directionToUpdate is the direction vector to update with the result
  73421. * @param particle is the particle we are computed the direction for
  73422. */
  73423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73424. /**
  73425. * Clones the current emitter and returns a copy of it
  73426. * @returns the new emitter
  73427. */
  73428. clone(): SphereDirectedParticleEmitter;
  73429. /**
  73430. * Called by the GPUParticleSystem to setup the update shader
  73431. * @param effect defines the update shader
  73432. */
  73433. applyToShader(effect: Effect): void;
  73434. /**
  73435. * Returns a string to use to update the GPU particles update shader
  73436. * @returns a string containng the defines string
  73437. */
  73438. getEffectDefines(): string;
  73439. /**
  73440. * Returns the string "SphereDirectedParticleEmitter"
  73441. * @returns a string containing the class name
  73442. */
  73443. getClassName(): string;
  73444. /**
  73445. * Serializes the particle system to a JSON object.
  73446. * @returns the JSON object
  73447. */
  73448. serialize(): any;
  73449. /**
  73450. * Parse properties from a JSON object
  73451. * @param serializationObject defines the JSON object
  73452. */
  73453. parse(serializationObject: any): void;
  73454. }
  73455. }
  73456. declare module BABYLON {
  73457. /**
  73458. * Interface representing a particle system in Babylon.js.
  73459. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73460. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73461. */
  73462. export interface IParticleSystem {
  73463. /**
  73464. * List of animations used by the particle system.
  73465. */
  73466. animations: Animation[];
  73467. /**
  73468. * The id of the Particle system.
  73469. */
  73470. id: string;
  73471. /**
  73472. * The name of the Particle system.
  73473. */
  73474. name: string;
  73475. /**
  73476. * The emitter represents the Mesh or position we are attaching the particle system to.
  73477. */
  73478. emitter: Nullable<AbstractMesh | Vector3>;
  73479. /**
  73480. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73481. */
  73482. isBillboardBased: boolean;
  73483. /**
  73484. * The rendering group used by the Particle system to chose when to render.
  73485. */
  73486. renderingGroupId: number;
  73487. /**
  73488. * The layer mask we are rendering the particles through.
  73489. */
  73490. layerMask: number;
  73491. /**
  73492. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73493. */
  73494. updateSpeed: number;
  73495. /**
  73496. * The amount of time the particle system is running (depends of the overall update speed).
  73497. */
  73498. targetStopDuration: number;
  73499. /**
  73500. * The texture used to render each particle. (this can be a spritesheet)
  73501. */
  73502. particleTexture: Nullable<Texture>;
  73503. /**
  73504. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73505. */
  73506. blendMode: number;
  73507. /**
  73508. * Minimum life time of emitting particles.
  73509. */
  73510. minLifeTime: number;
  73511. /**
  73512. * Maximum life time of emitting particles.
  73513. */
  73514. maxLifeTime: number;
  73515. /**
  73516. * Minimum Size of emitting particles.
  73517. */
  73518. minSize: number;
  73519. /**
  73520. * Maximum Size of emitting particles.
  73521. */
  73522. maxSize: number;
  73523. /**
  73524. * Minimum scale of emitting particles on X axis.
  73525. */
  73526. minScaleX: number;
  73527. /**
  73528. * Maximum scale of emitting particles on X axis.
  73529. */
  73530. maxScaleX: number;
  73531. /**
  73532. * Minimum scale of emitting particles on Y axis.
  73533. */
  73534. minScaleY: number;
  73535. /**
  73536. * Maximum scale of emitting particles on Y axis.
  73537. */
  73538. maxScaleY: number;
  73539. /**
  73540. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73541. */
  73542. color1: Color4;
  73543. /**
  73544. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73545. */
  73546. color2: Color4;
  73547. /**
  73548. * Color the particle will have at the end of its lifetime.
  73549. */
  73550. colorDead: Color4;
  73551. /**
  73552. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73553. */
  73554. emitRate: number;
  73555. /**
  73556. * You can use gravity if you want to give an orientation to your particles.
  73557. */
  73558. gravity: Vector3;
  73559. /**
  73560. * Minimum power of emitting particles.
  73561. */
  73562. minEmitPower: number;
  73563. /**
  73564. * Maximum power of emitting particles.
  73565. */
  73566. maxEmitPower: number;
  73567. /**
  73568. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73569. */
  73570. minAngularSpeed: number;
  73571. /**
  73572. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73573. */
  73574. maxAngularSpeed: number;
  73575. /**
  73576. * Gets or sets the minimal initial rotation in radians.
  73577. */
  73578. minInitialRotation: number;
  73579. /**
  73580. * Gets or sets the maximal initial rotation in radians.
  73581. */
  73582. maxInitialRotation: number;
  73583. /**
  73584. * The particle emitter type defines the emitter used by the particle system.
  73585. * It can be for example box, sphere, or cone...
  73586. */
  73587. particleEmitterType: Nullable<IParticleEmitterType>;
  73588. /**
  73589. * Defines the delay in milliseconds before starting the system (0 by default)
  73590. */
  73591. startDelay: number;
  73592. /**
  73593. * 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
  73594. */
  73595. preWarmCycles: number;
  73596. /**
  73597. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73598. */
  73599. preWarmStepOffset: number;
  73600. /**
  73601. * 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)
  73602. */
  73603. spriteCellChangeSpeed: number;
  73604. /**
  73605. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73606. */
  73607. startSpriteCellID: number;
  73608. /**
  73609. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73610. */
  73611. endSpriteCellID: number;
  73612. /**
  73613. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73614. */
  73615. spriteCellWidth: number;
  73616. /**
  73617. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73618. */
  73619. spriteCellHeight: number;
  73620. /**
  73621. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73622. */
  73623. spriteRandomStartCell: boolean;
  73624. /**
  73625. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73626. */
  73627. isAnimationSheetEnabled: boolean;
  73628. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73629. translationPivot: Vector2;
  73630. /**
  73631. * Gets or sets a texture used to add random noise to particle positions
  73632. */
  73633. noiseTexture: Nullable<BaseTexture>;
  73634. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73635. noiseStrength: Vector3;
  73636. /**
  73637. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73638. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73639. */
  73640. billboardMode: number;
  73641. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73642. limitVelocityDamping: number;
  73643. /**
  73644. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73645. */
  73646. beginAnimationOnStart: boolean;
  73647. /**
  73648. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73649. */
  73650. beginAnimationFrom: number;
  73651. /**
  73652. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73653. */
  73654. beginAnimationTo: number;
  73655. /**
  73656. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73657. */
  73658. beginAnimationLoop: boolean;
  73659. /**
  73660. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73661. */
  73662. disposeOnStop: boolean;
  73663. /**
  73664. * Gets the maximum number of particles active at the same time.
  73665. * @returns The max number of active particles.
  73666. */
  73667. getCapacity(): number;
  73668. /**
  73669. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73670. * @returns True if it has been started, otherwise false.
  73671. */
  73672. isStarted(): boolean;
  73673. /**
  73674. * Animates the particle system for this frame.
  73675. */
  73676. animate(): void;
  73677. /**
  73678. * Renders the particle system in its current state.
  73679. * @returns the current number of particles
  73680. */
  73681. render(): number;
  73682. /**
  73683. * Dispose the particle system and frees its associated resources.
  73684. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73685. */
  73686. dispose(disposeTexture?: boolean): void;
  73687. /**
  73688. * Clones the particle system.
  73689. * @param name The name of the cloned object
  73690. * @param newEmitter The new emitter to use
  73691. * @returns the cloned particle system
  73692. */
  73693. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73694. /**
  73695. * Serializes the particle system to a JSON object.
  73696. * @returns the JSON object
  73697. */
  73698. serialize(): any;
  73699. /**
  73700. * Rebuild the particle system
  73701. */
  73702. rebuild(): void;
  73703. /**
  73704. * Starts the particle system and begins to emit
  73705. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73706. */
  73707. start(delay?: number): void;
  73708. /**
  73709. * Stops the particle system.
  73710. */
  73711. stop(): void;
  73712. /**
  73713. * Remove all active particles
  73714. */
  73715. reset(): void;
  73716. /**
  73717. * Is this system ready to be used/rendered
  73718. * @return true if the system is ready
  73719. */
  73720. isReady(): boolean;
  73721. /**
  73722. * Adds a new color gradient
  73723. * @param gradient defines the gradient to use (between 0 and 1)
  73724. * @param color1 defines the color to affect to the specified gradient
  73725. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73726. * @returns the current particle system
  73727. */
  73728. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73729. /**
  73730. * Remove a specific color gradient
  73731. * @param gradient defines the gradient to remove
  73732. * @returns the current particle system
  73733. */
  73734. removeColorGradient(gradient: number): IParticleSystem;
  73735. /**
  73736. * Adds a new size gradient
  73737. * @param gradient defines the gradient to use (between 0 and 1)
  73738. * @param factor defines the size factor to affect to the specified gradient
  73739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73740. * @returns the current particle system
  73741. */
  73742. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73743. /**
  73744. * Remove a specific size gradient
  73745. * @param gradient defines the gradient to remove
  73746. * @returns the current particle system
  73747. */
  73748. removeSizeGradient(gradient: number): IParticleSystem;
  73749. /**
  73750. * Gets the current list of color gradients.
  73751. * You must use addColorGradient and removeColorGradient to udpate this list
  73752. * @returns the list of color gradients
  73753. */
  73754. getColorGradients(): Nullable<Array<ColorGradient>>;
  73755. /**
  73756. * Gets the current list of size gradients.
  73757. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73758. * @returns the list of size gradients
  73759. */
  73760. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73761. /**
  73762. * Gets the current list of angular speed gradients.
  73763. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73764. * @returns the list of angular speed gradients
  73765. */
  73766. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73767. /**
  73768. * Adds a new angular speed gradient
  73769. * @param gradient defines the gradient to use (between 0 and 1)
  73770. * @param factor defines the angular speed to affect to the specified gradient
  73771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73772. * @returns the current particle system
  73773. */
  73774. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73775. /**
  73776. * Remove a specific angular speed gradient
  73777. * @param gradient defines the gradient to remove
  73778. * @returns the current particle system
  73779. */
  73780. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73781. /**
  73782. * Gets the current list of velocity gradients.
  73783. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73784. * @returns the list of velocity gradients
  73785. */
  73786. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73787. /**
  73788. * Adds a new velocity gradient
  73789. * @param gradient defines the gradient to use (between 0 and 1)
  73790. * @param factor defines the velocity to affect to the specified gradient
  73791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73792. * @returns the current particle system
  73793. */
  73794. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73795. /**
  73796. * Remove a specific velocity gradient
  73797. * @param gradient defines the gradient to remove
  73798. * @returns the current particle system
  73799. */
  73800. removeVelocityGradient(gradient: number): IParticleSystem;
  73801. /**
  73802. * Gets the current list of limit velocity gradients.
  73803. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73804. * @returns the list of limit velocity gradients
  73805. */
  73806. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73807. /**
  73808. * Adds a new limit velocity gradient
  73809. * @param gradient defines the gradient to use (between 0 and 1)
  73810. * @param factor defines the limit velocity to affect to the specified gradient
  73811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73812. * @returns the current particle system
  73813. */
  73814. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73815. /**
  73816. * Remove a specific limit velocity gradient
  73817. * @param gradient defines the gradient to remove
  73818. * @returns the current particle system
  73819. */
  73820. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73821. /**
  73822. * Adds a new drag gradient
  73823. * @param gradient defines the gradient to use (between 0 and 1)
  73824. * @param factor defines the drag to affect to the specified gradient
  73825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73826. * @returns the current particle system
  73827. */
  73828. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73829. /**
  73830. * Remove a specific drag gradient
  73831. * @param gradient defines the gradient to remove
  73832. * @returns the current particle system
  73833. */
  73834. removeDragGradient(gradient: number): IParticleSystem;
  73835. /**
  73836. * Gets the current list of drag gradients.
  73837. * You must use addDragGradient and removeDragGradient to udpate this list
  73838. * @returns the list of drag gradients
  73839. */
  73840. getDragGradients(): Nullable<Array<FactorGradient>>;
  73841. /**
  73842. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73843. * @param gradient defines the gradient to use (between 0 and 1)
  73844. * @param factor defines the emit rate to affect to the specified gradient
  73845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73846. * @returns the current particle system
  73847. */
  73848. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73849. /**
  73850. * Remove a specific emit rate gradient
  73851. * @param gradient defines the gradient to remove
  73852. * @returns the current particle system
  73853. */
  73854. removeEmitRateGradient(gradient: number): IParticleSystem;
  73855. /**
  73856. * Gets the current list of emit rate gradients.
  73857. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73858. * @returns the list of emit rate gradients
  73859. */
  73860. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73861. /**
  73862. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73863. * @param gradient defines the gradient to use (between 0 and 1)
  73864. * @param factor defines the start size to affect to the specified gradient
  73865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73866. * @returns the current particle system
  73867. */
  73868. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73869. /**
  73870. * Remove a specific start size gradient
  73871. * @param gradient defines the gradient to remove
  73872. * @returns the current particle system
  73873. */
  73874. removeStartSizeGradient(gradient: number): IParticleSystem;
  73875. /**
  73876. * Gets the current list of start size gradients.
  73877. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73878. * @returns the list of start size gradients
  73879. */
  73880. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73881. /**
  73882. * Adds a new life time gradient
  73883. * @param gradient defines the gradient to use (between 0 and 1)
  73884. * @param factor defines the life time factor to affect to the specified gradient
  73885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73886. * @returns the current particle system
  73887. */
  73888. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73889. /**
  73890. * Remove a specific life time gradient
  73891. * @param gradient defines the gradient to remove
  73892. * @returns the current particle system
  73893. */
  73894. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73895. /**
  73896. * Gets the current list of life time gradients.
  73897. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73898. * @returns the list of life time gradients
  73899. */
  73900. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73901. /**
  73902. * Gets the current list of color gradients.
  73903. * You must use addColorGradient and removeColorGradient to udpate this list
  73904. * @returns the list of color gradients
  73905. */
  73906. getColorGradients(): Nullable<Array<ColorGradient>>;
  73907. /**
  73908. * Adds a new ramp gradient used to remap particle colors
  73909. * @param gradient defines the gradient to use (between 0 and 1)
  73910. * @param color defines the color to affect to the specified gradient
  73911. * @returns the current particle system
  73912. */
  73913. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73914. /**
  73915. * Gets the current list of ramp gradients.
  73916. * You must use addRampGradient and removeRampGradient to udpate this list
  73917. * @returns the list of ramp gradients
  73918. */
  73919. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73920. /** Gets or sets a boolean indicating that ramp gradients must be used
  73921. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73922. */
  73923. useRampGradients: boolean;
  73924. /**
  73925. * Adds a new color remap gradient
  73926. * @param gradient defines the gradient to use (between 0 and 1)
  73927. * @param min defines the color remap minimal range
  73928. * @param max defines the color remap maximal range
  73929. * @returns the current particle system
  73930. */
  73931. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73932. /**
  73933. * Gets the current list of color remap gradients.
  73934. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73935. * @returns the list of color remap gradients
  73936. */
  73937. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73938. /**
  73939. * Adds a new alpha remap gradient
  73940. * @param gradient defines the gradient to use (between 0 and 1)
  73941. * @param min defines the alpha remap minimal range
  73942. * @param max defines the alpha remap maximal range
  73943. * @returns the current particle system
  73944. */
  73945. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73946. /**
  73947. * Gets the current list of alpha remap gradients.
  73948. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73949. * @returns the list of alpha remap gradients
  73950. */
  73951. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73952. /**
  73953. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73954. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73955. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73956. * @returns the emitter
  73957. */
  73958. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73959. /**
  73960. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73961. * @param radius The radius of the hemisphere to emit from
  73962. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73963. * @returns the emitter
  73964. */
  73965. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73966. /**
  73967. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73968. * @param radius The radius of the sphere to emit from
  73969. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73970. * @returns the emitter
  73971. */
  73972. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73973. /**
  73974. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73975. * @param radius The radius of the sphere to emit from
  73976. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73977. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73978. * @returns the emitter
  73979. */
  73980. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73981. /**
  73982. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73983. * @param radius The radius of the emission cylinder
  73984. * @param height The height of the emission cylinder
  73985. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73986. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73987. * @returns the emitter
  73988. */
  73989. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73990. /**
  73991. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73992. * @param radius The radius of the cylinder to emit from
  73993. * @param height The height of the emission cylinder
  73994. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73995. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73996. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73997. * @returns the emitter
  73998. */
  73999. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74000. /**
  74001. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74002. * @param radius The radius of the cone to emit from
  74003. * @param angle The base angle of the cone
  74004. * @returns the emitter
  74005. */
  74006. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74007. /**
  74008. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74009. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74010. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74011. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74012. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74013. * @returns the emitter
  74014. */
  74015. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74016. /**
  74017. * Get hosting scene
  74018. * @returns the scene
  74019. */
  74020. getScene(): Scene;
  74021. }
  74022. }
  74023. declare module BABYLON {
  74024. /**
  74025. * Creates an instance based on a source mesh.
  74026. */
  74027. export class InstancedMesh extends AbstractMesh {
  74028. private _sourceMesh;
  74029. private _currentLOD;
  74030. /** @hidden */
  74031. _indexInSourceMeshInstanceArray: number;
  74032. constructor(name: string, source: Mesh);
  74033. /**
  74034. * Returns the string "InstancedMesh".
  74035. */
  74036. getClassName(): string;
  74037. /**
  74038. * If the source mesh receives shadows
  74039. */
  74040. readonly receiveShadows: boolean;
  74041. /**
  74042. * The material of the source mesh
  74043. */
  74044. readonly material: Nullable<Material>;
  74045. /**
  74046. * Visibility of the source mesh
  74047. */
  74048. readonly visibility: number;
  74049. /**
  74050. * Skeleton of the source mesh
  74051. */
  74052. readonly skeleton: Nullable<Skeleton>;
  74053. /**
  74054. * Rendering ground id of the source mesh
  74055. */
  74056. renderingGroupId: number;
  74057. /**
  74058. * Returns the total number of vertices (integer).
  74059. */
  74060. getTotalVertices(): number;
  74061. /**
  74062. * Returns a positive integer : the total number of indices in this mesh geometry.
  74063. * @returns the numner of indices or zero if the mesh has no geometry.
  74064. */
  74065. getTotalIndices(): number;
  74066. /**
  74067. * The source mesh of the instance
  74068. */
  74069. readonly sourceMesh: Mesh;
  74070. /**
  74071. * Is this node ready to be used/rendered
  74072. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74073. * @return {boolean} is it ready
  74074. */
  74075. isReady(completeCheck?: boolean): boolean;
  74076. /**
  74077. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74078. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74079. * @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.
  74080. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74081. */
  74082. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74083. /**
  74084. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74085. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74086. * The `data` are either a numeric array either a Float32Array.
  74087. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74088. * 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).
  74089. * Note that a new underlying VertexBuffer object is created each call.
  74090. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74091. *
  74092. * Possible `kind` values :
  74093. * - VertexBuffer.PositionKind
  74094. * - VertexBuffer.UVKind
  74095. * - VertexBuffer.UV2Kind
  74096. * - VertexBuffer.UV3Kind
  74097. * - VertexBuffer.UV4Kind
  74098. * - VertexBuffer.UV5Kind
  74099. * - VertexBuffer.UV6Kind
  74100. * - VertexBuffer.ColorKind
  74101. * - VertexBuffer.MatricesIndicesKind
  74102. * - VertexBuffer.MatricesIndicesExtraKind
  74103. * - VertexBuffer.MatricesWeightsKind
  74104. * - VertexBuffer.MatricesWeightsExtraKind
  74105. *
  74106. * Returns the Mesh.
  74107. */
  74108. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74109. /**
  74110. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74111. * If the mesh has no geometry, it is simply returned as it is.
  74112. * The `data` are either a numeric array either a Float32Array.
  74113. * No new underlying VertexBuffer object is created.
  74114. * 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.
  74115. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74116. *
  74117. * Possible `kind` values :
  74118. * - VertexBuffer.PositionKind
  74119. * - VertexBuffer.UVKind
  74120. * - VertexBuffer.UV2Kind
  74121. * - VertexBuffer.UV3Kind
  74122. * - VertexBuffer.UV4Kind
  74123. * - VertexBuffer.UV5Kind
  74124. * - VertexBuffer.UV6Kind
  74125. * - VertexBuffer.ColorKind
  74126. * - VertexBuffer.MatricesIndicesKind
  74127. * - VertexBuffer.MatricesIndicesExtraKind
  74128. * - VertexBuffer.MatricesWeightsKind
  74129. * - VertexBuffer.MatricesWeightsExtraKind
  74130. *
  74131. * Returns the Mesh.
  74132. */
  74133. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74134. /**
  74135. * Sets the mesh indices.
  74136. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74137. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74138. * This method creates a new index buffer each call.
  74139. * Returns the Mesh.
  74140. */
  74141. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74142. /**
  74143. * Boolean : True if the mesh owns the requested kind of data.
  74144. */
  74145. isVerticesDataPresent(kind: string): boolean;
  74146. /**
  74147. * Returns an array of indices (IndicesArray).
  74148. */
  74149. getIndices(): Nullable<IndicesArray>;
  74150. readonly _positions: Nullable<Vector3[]>;
  74151. /**
  74152. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74153. * This means the mesh underlying bounding box and sphere are recomputed.
  74154. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74155. * @returns the current mesh
  74156. */
  74157. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74158. /** @hidden */
  74159. _preActivate(): InstancedMesh;
  74160. /** @hidden */
  74161. _activate(renderId: number): InstancedMesh;
  74162. /**
  74163. * Returns the current associated LOD AbstractMesh.
  74164. */
  74165. getLOD(camera: Camera): AbstractMesh;
  74166. /** @hidden */
  74167. _syncSubMeshes(): InstancedMesh;
  74168. /** @hidden */
  74169. _generatePointsArray(): boolean;
  74170. /**
  74171. * Creates a new InstancedMesh from the current mesh.
  74172. * - name (string) : the cloned mesh name
  74173. * - newParent (optional Node) : the optional Node to parent the clone to.
  74174. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74175. *
  74176. * Returns the clone.
  74177. */
  74178. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74179. /**
  74180. * Disposes the InstancedMesh.
  74181. * Returns nothing.
  74182. */
  74183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74184. }
  74185. }
  74186. declare module BABYLON {
  74187. /**
  74188. * Defines the options associated with the creation of a shader material.
  74189. */
  74190. export interface IShaderMaterialOptions {
  74191. /**
  74192. * Does the material work in alpha blend mode
  74193. */
  74194. needAlphaBlending: boolean;
  74195. /**
  74196. * Does the material work in alpha test mode
  74197. */
  74198. needAlphaTesting: boolean;
  74199. /**
  74200. * The list of attribute names used in the shader
  74201. */
  74202. attributes: string[];
  74203. /**
  74204. * The list of unifrom names used in the shader
  74205. */
  74206. uniforms: string[];
  74207. /**
  74208. * The list of UBO names used in the shader
  74209. */
  74210. uniformBuffers: string[];
  74211. /**
  74212. * The list of sampler names used in the shader
  74213. */
  74214. samplers: string[];
  74215. /**
  74216. * The list of defines used in the shader
  74217. */
  74218. defines: string[];
  74219. }
  74220. /**
  74221. * 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.
  74222. *
  74223. * This returned material effects how the mesh will look based on the code in the shaders.
  74224. *
  74225. * @see http://doc.babylonjs.com/how_to/shader_material
  74226. */
  74227. export class ShaderMaterial extends Material {
  74228. private _shaderPath;
  74229. private _options;
  74230. private _textures;
  74231. private _textureArrays;
  74232. private _floats;
  74233. private _ints;
  74234. private _floatsArrays;
  74235. private _colors3;
  74236. private _colors3Arrays;
  74237. private _colors4;
  74238. private _vectors2;
  74239. private _vectors3;
  74240. private _vectors4;
  74241. private _matrices;
  74242. private _matrices3x3;
  74243. private _matrices2x2;
  74244. private _vectors2Arrays;
  74245. private _vectors3Arrays;
  74246. private _cachedWorldViewMatrix;
  74247. private _renderId;
  74248. /**
  74249. * Instantiate a new shader material.
  74250. * 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.
  74251. * This returned material effects how the mesh will look based on the code in the shaders.
  74252. * @see http://doc.babylonjs.com/how_to/shader_material
  74253. * @param name Define the name of the material in the scene
  74254. * @param scene Define the scene the material belongs to
  74255. * @param shaderPath Defines the route to the shader code in one of three ways:
  74256. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74257. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74258. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74259. * @param options Define the options used to create the shader
  74260. */
  74261. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74262. /**
  74263. * Gets the options used to compile the shader.
  74264. * They can be modified to trigger a new compilation
  74265. */
  74266. readonly options: IShaderMaterialOptions;
  74267. /**
  74268. * Gets the current class name of the material e.g. "ShaderMaterial"
  74269. * Mainly use in serialization.
  74270. * @returns the class name
  74271. */
  74272. getClassName(): string;
  74273. /**
  74274. * Specifies if the material will require alpha blending
  74275. * @returns a boolean specifying if alpha blending is needed
  74276. */
  74277. needAlphaBlending(): boolean;
  74278. /**
  74279. * Specifies if this material should be rendered in alpha test mode
  74280. * @returns a boolean specifying if an alpha test is needed.
  74281. */
  74282. needAlphaTesting(): boolean;
  74283. private _checkUniform;
  74284. /**
  74285. * Set a texture in the shader.
  74286. * @param name Define the name of the uniform samplers as defined in the shader
  74287. * @param texture Define the texture to bind to this sampler
  74288. * @return the material itself allowing "fluent" like uniform updates
  74289. */
  74290. setTexture(name: string, texture: Texture): ShaderMaterial;
  74291. /**
  74292. * Set a texture array in the shader.
  74293. * @param name Define the name of the uniform sampler array as defined in the shader
  74294. * @param textures Define the list of textures to bind to this sampler
  74295. * @return the material itself allowing "fluent" like uniform updates
  74296. */
  74297. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74298. /**
  74299. * Set a float in the shader.
  74300. * @param name Define the name of the uniform as defined in the shader
  74301. * @param value Define the value to give to the uniform
  74302. * @return the material itself allowing "fluent" like uniform updates
  74303. */
  74304. setFloat(name: string, value: number): ShaderMaterial;
  74305. /**
  74306. * Set a int in the shader.
  74307. * @param name Define the name of the uniform as defined in the shader
  74308. * @param value Define the value to give to the uniform
  74309. * @return the material itself allowing "fluent" like uniform updates
  74310. */
  74311. setInt(name: string, value: number): ShaderMaterial;
  74312. /**
  74313. * Set an array of floats in the shader.
  74314. * @param name Define the name of the uniform as defined in the shader
  74315. * @param value Define the value to give to the uniform
  74316. * @return the material itself allowing "fluent" like uniform updates
  74317. */
  74318. setFloats(name: string, value: number[]): ShaderMaterial;
  74319. /**
  74320. * Set a vec3 in the shader from a Color3.
  74321. * @param name Define the name of the uniform as defined in the shader
  74322. * @param value Define the value to give to the uniform
  74323. * @return the material itself allowing "fluent" like uniform updates
  74324. */
  74325. setColor3(name: string, value: Color3): ShaderMaterial;
  74326. /**
  74327. * Set a vec3 array in the shader from a Color3 array.
  74328. * @param name Define the name of the uniform as defined in the shader
  74329. * @param value Define the value to give to the uniform
  74330. * @return the material itself allowing "fluent" like uniform updates
  74331. */
  74332. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74333. /**
  74334. * Set a vec4 in the shader from a Color4.
  74335. * @param name Define the name of the uniform as defined in the shader
  74336. * @param value Define the value to give to the uniform
  74337. * @return the material itself allowing "fluent" like uniform updates
  74338. */
  74339. setColor4(name: string, value: Color4): ShaderMaterial;
  74340. /**
  74341. * Set a vec2 in the shader from a Vector2.
  74342. * @param name Define the name of the uniform as defined in the shader
  74343. * @param value Define the value to give to the uniform
  74344. * @return the material itself allowing "fluent" like uniform updates
  74345. */
  74346. setVector2(name: string, value: Vector2): ShaderMaterial;
  74347. /**
  74348. * Set a vec3 in the shader from a Vector3.
  74349. * @param name Define the name of the uniform as defined in the shader
  74350. * @param value Define the value to give to the uniform
  74351. * @return the material itself allowing "fluent" like uniform updates
  74352. */
  74353. setVector3(name: string, value: Vector3): ShaderMaterial;
  74354. /**
  74355. * Set a vec4 in the shader from a Vector4.
  74356. * @param name Define the name of the uniform as defined in the shader
  74357. * @param value Define the value to give to the uniform
  74358. * @return the material itself allowing "fluent" like uniform updates
  74359. */
  74360. setVector4(name: string, value: Vector4): ShaderMaterial;
  74361. /**
  74362. * Set a mat4 in the shader from a Matrix.
  74363. * @param name Define the name of the uniform as defined in the shader
  74364. * @param value Define the value to give to the uniform
  74365. * @return the material itself allowing "fluent" like uniform updates
  74366. */
  74367. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74368. /**
  74369. * Set a mat3 in the shader from a Float32Array.
  74370. * @param name Define the name of the uniform as defined in the shader
  74371. * @param value Define the value to give to the uniform
  74372. * @return the material itself allowing "fluent" like uniform updates
  74373. */
  74374. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74375. /**
  74376. * Set a mat2 in the shader from a Float32Array.
  74377. * @param name Define the name of the uniform as defined in the shader
  74378. * @param value Define the value to give to the uniform
  74379. * @return the material itself allowing "fluent" like uniform updates
  74380. */
  74381. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74382. /**
  74383. * Set a vec2 array in the shader from a number array.
  74384. * @param name Define the name of the uniform as defined in the shader
  74385. * @param value Define the value to give to the uniform
  74386. * @return the material itself allowing "fluent" like uniform updates
  74387. */
  74388. setArray2(name: string, value: number[]): ShaderMaterial;
  74389. /**
  74390. * Set a vec3 array in the shader from a number array.
  74391. * @param name Define the name of the uniform as defined in the shader
  74392. * @param value Define the value to give to the uniform
  74393. * @return the material itself allowing "fluent" like uniform updates
  74394. */
  74395. setArray3(name: string, value: number[]): ShaderMaterial;
  74396. private _checkCache;
  74397. /**
  74398. * Checks if the material is ready to render the requested mesh
  74399. * @param mesh Define the mesh to render
  74400. * @param useInstances Define whether or not the material is used with instances
  74401. * @returns true if ready, otherwise false
  74402. */
  74403. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74404. /**
  74405. * Binds the world matrix to the material
  74406. * @param world defines the world transformation matrix
  74407. */
  74408. bindOnlyWorldMatrix(world: Matrix): void;
  74409. /**
  74410. * Binds the material to the mesh
  74411. * @param world defines the world transformation matrix
  74412. * @param mesh defines the mesh to bind the material to
  74413. */
  74414. bind(world: Matrix, mesh?: Mesh): void;
  74415. /**
  74416. * Gets the active textures from the material
  74417. * @returns an array of textures
  74418. */
  74419. getActiveTextures(): BaseTexture[];
  74420. /**
  74421. * Specifies if the material uses a texture
  74422. * @param texture defines the texture to check against the material
  74423. * @returns a boolean specifying if the material uses the texture
  74424. */
  74425. hasTexture(texture: BaseTexture): boolean;
  74426. /**
  74427. * Makes a duplicate of the material, and gives it a new name
  74428. * @param name defines the new name for the duplicated material
  74429. * @returns the cloned material
  74430. */
  74431. clone(name: string): ShaderMaterial;
  74432. /**
  74433. * Disposes the material
  74434. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74435. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74436. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74437. */
  74438. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74439. /**
  74440. * Serializes this material in a JSON representation
  74441. * @returns the serialized material object
  74442. */
  74443. serialize(): any;
  74444. /**
  74445. * Creates a shader material from parsed shader material data
  74446. * @param source defines the JSON represnetation of the material
  74447. * @param scene defines the hosting scene
  74448. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74449. * @returns a new material
  74450. */
  74451. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74452. }
  74453. }
  74454. declare module BABYLON {
  74455. /** @hidden */
  74456. export var colorPixelShader: {
  74457. name: string;
  74458. shader: string;
  74459. };
  74460. }
  74461. declare module BABYLON {
  74462. /** @hidden */
  74463. export var colorVertexShader: {
  74464. name: string;
  74465. shader: string;
  74466. };
  74467. }
  74468. declare module BABYLON {
  74469. /**
  74470. * Line mesh
  74471. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74472. */
  74473. export class LinesMesh extends Mesh {
  74474. /**
  74475. * If vertex color should be applied to the mesh
  74476. */
  74477. useVertexColor?: boolean | undefined;
  74478. /**
  74479. * If vertex alpha should be applied to the mesh
  74480. */
  74481. useVertexAlpha?: boolean | undefined;
  74482. /**
  74483. * Color of the line (Default: White)
  74484. */
  74485. color: Color3;
  74486. /**
  74487. * Alpha of the line (Default: 1)
  74488. */
  74489. alpha: number;
  74490. /**
  74491. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74492. * This margin is expressed in world space coordinates, so its value may vary.
  74493. * Default value is 0.1
  74494. */
  74495. intersectionThreshold: number;
  74496. private _colorShader;
  74497. /**
  74498. * Creates a new LinesMesh
  74499. * @param name defines the name
  74500. * @param scene defines the hosting scene
  74501. * @param parent defines the parent mesh if any
  74502. * @param source defines the optional source LinesMesh used to clone data from
  74503. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74504. * When false, achieved by calling a clone(), also passing False.
  74505. * This will make creation of children, recursive.
  74506. * @param useVertexColor defines if this LinesMesh supports vertex color
  74507. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74508. */
  74509. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74510. /**
  74511. * If vertex color should be applied to the mesh
  74512. */
  74513. useVertexColor?: boolean | undefined,
  74514. /**
  74515. * If vertex alpha should be applied to the mesh
  74516. */
  74517. useVertexAlpha?: boolean | undefined);
  74518. private _addClipPlaneDefine;
  74519. private _removeClipPlaneDefine;
  74520. isReady(): boolean;
  74521. /**
  74522. * Returns the string "LineMesh"
  74523. */
  74524. getClassName(): string;
  74525. /**
  74526. * @hidden
  74527. */
  74528. /**
  74529. * @hidden
  74530. */
  74531. material: Material;
  74532. /**
  74533. * @hidden
  74534. */
  74535. readonly checkCollisions: boolean;
  74536. /** @hidden */
  74537. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74538. /** @hidden */
  74539. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74540. /**
  74541. * Disposes of the line mesh
  74542. * @param doNotRecurse If children should be disposed
  74543. */
  74544. dispose(doNotRecurse?: boolean): void;
  74545. /**
  74546. * Returns a new LineMesh object cloned from the current one.
  74547. */
  74548. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74549. /**
  74550. * Creates a new InstancedLinesMesh object from the mesh model.
  74551. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74552. * @param name defines the name of the new instance
  74553. * @returns a new InstancedLinesMesh
  74554. */
  74555. createInstance(name: string): InstancedLinesMesh;
  74556. }
  74557. /**
  74558. * Creates an instance based on a source LinesMesh
  74559. */
  74560. export class InstancedLinesMesh extends InstancedMesh {
  74561. /**
  74562. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74563. * This margin is expressed in world space coordinates, so its value may vary.
  74564. * Initilized with the intersectionThreshold value of the source LinesMesh
  74565. */
  74566. intersectionThreshold: number;
  74567. constructor(name: string, source: LinesMesh);
  74568. /**
  74569. * Returns the string "InstancedLinesMesh".
  74570. */
  74571. getClassName(): string;
  74572. }
  74573. }
  74574. declare module BABYLON {
  74575. /** @hidden */
  74576. export var linePixelShader: {
  74577. name: string;
  74578. shader: string;
  74579. };
  74580. }
  74581. declare module BABYLON {
  74582. /** @hidden */
  74583. export var lineVertexShader: {
  74584. name: string;
  74585. shader: string;
  74586. };
  74587. }
  74588. declare module BABYLON {
  74589. interface AbstractMesh {
  74590. /**
  74591. * Disables the mesh edge rendering mode
  74592. * @returns the currentAbstractMesh
  74593. */
  74594. disableEdgesRendering(): AbstractMesh;
  74595. /**
  74596. * Enables the edge rendering mode on the mesh.
  74597. * This mode makes the mesh edges visible
  74598. * @param epsilon defines the maximal distance between two angles to detect a face
  74599. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74600. * @returns the currentAbstractMesh
  74601. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74602. */
  74603. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74604. /**
  74605. * Gets the edgesRenderer associated with the mesh
  74606. */
  74607. edgesRenderer: Nullable<EdgesRenderer>;
  74608. }
  74609. interface LinesMesh {
  74610. /**
  74611. * Enables the edge rendering mode on the mesh.
  74612. * This mode makes the mesh edges visible
  74613. * @param epsilon defines the maximal distance between two angles to detect a face
  74614. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74615. * @returns the currentAbstractMesh
  74616. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74617. */
  74618. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74619. }
  74620. interface InstancedLinesMesh {
  74621. /**
  74622. * Enables the edge rendering mode on the mesh.
  74623. * This mode makes the mesh edges visible
  74624. * @param epsilon defines the maximal distance between two angles to detect a face
  74625. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74626. * @returns the current InstancedLinesMesh
  74627. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74628. */
  74629. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74630. }
  74631. /**
  74632. * Defines the minimum contract an Edges renderer should follow.
  74633. */
  74634. export interface IEdgesRenderer extends IDisposable {
  74635. /**
  74636. * Gets or sets a boolean indicating if the edgesRenderer is active
  74637. */
  74638. isEnabled: boolean;
  74639. /**
  74640. * Renders the edges of the attached mesh,
  74641. */
  74642. render(): void;
  74643. /**
  74644. * Checks wether or not the edges renderer is ready to render.
  74645. * @return true if ready, otherwise false.
  74646. */
  74647. isReady(): boolean;
  74648. }
  74649. /**
  74650. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74651. */
  74652. export class EdgesRenderer implements IEdgesRenderer {
  74653. /**
  74654. * Define the size of the edges with an orthographic camera
  74655. */
  74656. edgesWidthScalerForOrthographic: number;
  74657. /**
  74658. * Define the size of the edges with a perspective camera
  74659. */
  74660. edgesWidthScalerForPerspective: number;
  74661. protected _source: AbstractMesh;
  74662. protected _linesPositions: number[];
  74663. protected _linesNormals: number[];
  74664. protected _linesIndices: number[];
  74665. protected _epsilon: number;
  74666. protected _indicesCount: number;
  74667. protected _lineShader: ShaderMaterial;
  74668. protected _ib: WebGLBuffer;
  74669. protected _buffers: {
  74670. [key: string]: Nullable<VertexBuffer>;
  74671. };
  74672. protected _checkVerticesInsteadOfIndices: boolean;
  74673. private _meshRebuildObserver;
  74674. private _meshDisposeObserver;
  74675. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74676. isEnabled: boolean;
  74677. /**
  74678. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74679. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74680. * @param source Mesh used to create edges
  74681. * @param epsilon sum of angles in adjacency to check for edge
  74682. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74683. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74684. */
  74685. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74686. protected _prepareRessources(): void;
  74687. /** @hidden */
  74688. _rebuild(): void;
  74689. /**
  74690. * Releases the required resources for the edges renderer
  74691. */
  74692. dispose(): void;
  74693. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74694. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74695. /**
  74696. * Checks if the pair of p0 and p1 is en edge
  74697. * @param faceIndex
  74698. * @param edge
  74699. * @param faceNormals
  74700. * @param p0
  74701. * @param p1
  74702. * @private
  74703. */
  74704. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74705. /**
  74706. * push line into the position, normal and index buffer
  74707. * @protected
  74708. */
  74709. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74710. /**
  74711. * Generates lines edges from adjacencjes
  74712. * @private
  74713. */
  74714. _generateEdgesLines(): void;
  74715. /**
  74716. * Checks wether or not the edges renderer is ready to render.
  74717. * @return true if ready, otherwise false.
  74718. */
  74719. isReady(): boolean;
  74720. /**
  74721. * Renders the edges of the attached mesh,
  74722. */
  74723. render(): void;
  74724. }
  74725. /**
  74726. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74727. */
  74728. export class LineEdgesRenderer extends EdgesRenderer {
  74729. /**
  74730. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74731. * @param source LineMesh used to generate edges
  74732. * @param epsilon not important (specified angle for edge detection)
  74733. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74734. */
  74735. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74736. /**
  74737. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74738. */
  74739. _generateEdgesLines(): void;
  74740. }
  74741. }
  74742. declare module BABYLON {
  74743. /**
  74744. * This represents the object necessary to create a rendering group.
  74745. * This is exclusively used and created by the rendering manager.
  74746. * To modify the behavior, you use the available helpers in your scene or meshes.
  74747. * @hidden
  74748. */
  74749. export class RenderingGroup {
  74750. index: number;
  74751. private _scene;
  74752. private _opaqueSubMeshes;
  74753. private _transparentSubMeshes;
  74754. private _alphaTestSubMeshes;
  74755. private _depthOnlySubMeshes;
  74756. private _particleSystems;
  74757. private _spriteManagers;
  74758. private _opaqueSortCompareFn;
  74759. private _alphaTestSortCompareFn;
  74760. private _transparentSortCompareFn;
  74761. private _renderOpaque;
  74762. private _renderAlphaTest;
  74763. private _renderTransparent;
  74764. private _edgesRenderers;
  74765. onBeforeTransparentRendering: () => void;
  74766. /**
  74767. * Set the opaque sort comparison function.
  74768. * If null the sub meshes will be render in the order they were created
  74769. */
  74770. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74771. /**
  74772. * Set the alpha test sort comparison function.
  74773. * If null the sub meshes will be render in the order they were created
  74774. */
  74775. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74776. /**
  74777. * Set the transparent sort comparison function.
  74778. * If null the sub meshes will be render in the order they were created
  74779. */
  74780. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74781. /**
  74782. * Creates a new rendering group.
  74783. * @param index The rendering group index
  74784. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74785. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74786. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74787. */
  74788. 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>);
  74789. /**
  74790. * Render all the sub meshes contained in the group.
  74791. * @param customRenderFunction Used to override the default render behaviour of the group.
  74792. * @returns true if rendered some submeshes.
  74793. */
  74794. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74795. /**
  74796. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74797. * @param subMeshes The submeshes to render
  74798. */
  74799. private renderOpaqueSorted;
  74800. /**
  74801. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74802. * @param subMeshes The submeshes to render
  74803. */
  74804. private renderAlphaTestSorted;
  74805. /**
  74806. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74807. * @param subMeshes The submeshes to render
  74808. */
  74809. private renderTransparentSorted;
  74810. /**
  74811. * Renders the submeshes in a specified order.
  74812. * @param subMeshes The submeshes to sort before render
  74813. * @param sortCompareFn The comparison function use to sort
  74814. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74815. * @param transparent Specifies to activate blending if true
  74816. */
  74817. private static renderSorted;
  74818. /**
  74819. * Renders the submeshes in the order they were dispatched (no sort applied).
  74820. * @param subMeshes The submeshes to render
  74821. */
  74822. private static renderUnsorted;
  74823. /**
  74824. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74825. * are rendered back to front if in the same alpha index.
  74826. *
  74827. * @param a The first submesh
  74828. * @param b The second submesh
  74829. * @returns The result of the comparison
  74830. */
  74831. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74832. /**
  74833. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74834. * are rendered back to front.
  74835. *
  74836. * @param a The first submesh
  74837. * @param b The second submesh
  74838. * @returns The result of the comparison
  74839. */
  74840. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74841. /**
  74842. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74843. * are rendered front to back (prevent overdraw).
  74844. *
  74845. * @param a The first submesh
  74846. * @param b The second submesh
  74847. * @returns The result of the comparison
  74848. */
  74849. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74850. /**
  74851. * Resets the different lists of submeshes to prepare a new frame.
  74852. */
  74853. prepare(): void;
  74854. dispose(): void;
  74855. /**
  74856. * Inserts the submesh in its correct queue depending on its material.
  74857. * @param subMesh The submesh to dispatch
  74858. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74859. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74860. */
  74861. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74862. dispatchSprites(spriteManager: ISpriteManager): void;
  74863. dispatchParticles(particleSystem: IParticleSystem): void;
  74864. private _renderParticles;
  74865. private _renderSprites;
  74866. }
  74867. }
  74868. declare module BABYLON {
  74869. /**
  74870. * Interface describing the different options available in the rendering manager
  74871. * regarding Auto Clear between groups.
  74872. */
  74873. export interface IRenderingManagerAutoClearSetup {
  74874. /**
  74875. * Defines whether or not autoclear is enable.
  74876. */
  74877. autoClear: boolean;
  74878. /**
  74879. * Defines whether or not to autoclear the depth buffer.
  74880. */
  74881. depth: boolean;
  74882. /**
  74883. * Defines whether or not to autoclear the stencil buffer.
  74884. */
  74885. stencil: boolean;
  74886. }
  74887. /**
  74888. * This class is used by the onRenderingGroupObservable
  74889. */
  74890. export class RenderingGroupInfo {
  74891. /**
  74892. * The Scene that being rendered
  74893. */
  74894. scene: Scene;
  74895. /**
  74896. * The camera currently used for the rendering pass
  74897. */
  74898. camera: Nullable<Camera>;
  74899. /**
  74900. * The ID of the renderingGroup being processed
  74901. */
  74902. renderingGroupId: number;
  74903. }
  74904. /**
  74905. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74906. * It is enable to manage the different groups as well as the different necessary sort functions.
  74907. * This should not be used directly aside of the few static configurations
  74908. */
  74909. export class RenderingManager {
  74910. /**
  74911. * The max id used for rendering groups (not included)
  74912. */
  74913. static MAX_RENDERINGGROUPS: number;
  74914. /**
  74915. * The min id used for rendering groups (included)
  74916. */
  74917. static MIN_RENDERINGGROUPS: number;
  74918. /**
  74919. * Used to globally prevent autoclearing scenes.
  74920. */
  74921. static AUTOCLEAR: boolean;
  74922. /**
  74923. * @hidden
  74924. */
  74925. _useSceneAutoClearSetup: boolean;
  74926. private _scene;
  74927. private _renderingGroups;
  74928. private _depthStencilBufferAlreadyCleaned;
  74929. private _autoClearDepthStencil;
  74930. private _customOpaqueSortCompareFn;
  74931. private _customAlphaTestSortCompareFn;
  74932. private _customTransparentSortCompareFn;
  74933. private _renderingGroupInfo;
  74934. /**
  74935. * Instantiates a new rendering group for a particular scene
  74936. * @param scene Defines the scene the groups belongs to
  74937. */
  74938. constructor(scene: Scene);
  74939. private _clearDepthStencilBuffer;
  74940. /**
  74941. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74942. * @hidden
  74943. */
  74944. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74945. /**
  74946. * Resets the different information of the group to prepare a new frame
  74947. * @hidden
  74948. */
  74949. reset(): void;
  74950. /**
  74951. * Dispose and release the group and its associated resources.
  74952. * @hidden
  74953. */
  74954. dispose(): void;
  74955. /**
  74956. * Clear the info related to rendering groups preventing retention points during dispose.
  74957. */
  74958. freeRenderingGroups(): void;
  74959. private _prepareRenderingGroup;
  74960. /**
  74961. * Add a sprite manager to the rendering manager in order to render it this frame.
  74962. * @param spriteManager Define the sprite manager to render
  74963. */
  74964. dispatchSprites(spriteManager: ISpriteManager): void;
  74965. /**
  74966. * Add a particle system to the rendering manager in order to render it this frame.
  74967. * @param particleSystem Define the particle system to render
  74968. */
  74969. dispatchParticles(particleSystem: IParticleSystem): void;
  74970. /**
  74971. * Add a submesh to the manager in order to render it this frame
  74972. * @param subMesh The submesh to dispatch
  74973. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74974. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74975. */
  74976. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74977. /**
  74978. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74979. * This allowed control for front to back rendering or reversly depending of the special needs.
  74980. *
  74981. * @param renderingGroupId The rendering group id corresponding to its index
  74982. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74983. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74984. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74985. */
  74986. 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;
  74987. /**
  74988. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74989. *
  74990. * @param renderingGroupId The rendering group id corresponding to its index
  74991. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74992. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74993. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74994. */
  74995. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74996. /**
  74997. * Gets the current auto clear configuration for one rendering group of the rendering
  74998. * manager.
  74999. * @param index the rendering group index to get the information for
  75000. * @returns The auto clear setup for the requested rendering group
  75001. */
  75002. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75003. }
  75004. }
  75005. declare module BABYLON {
  75006. /**
  75007. * This Helps creating a texture that will be created from a camera in your scene.
  75008. * It is basically a dynamic texture that could be used to create special effects for instance.
  75009. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75010. */
  75011. export class RenderTargetTexture extends Texture {
  75012. isCube: boolean;
  75013. /**
  75014. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75015. */
  75016. static readonly REFRESHRATE_RENDER_ONCE: number;
  75017. /**
  75018. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75019. */
  75020. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75021. /**
  75022. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75023. * the central point of your effect and can save a lot of performances.
  75024. */
  75025. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75026. /**
  75027. * Use this predicate to dynamically define the list of mesh you want to render.
  75028. * If set, the renderList property will be overwritten.
  75029. */
  75030. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75031. private _renderList;
  75032. /**
  75033. * Use this list to define the list of mesh you want to render.
  75034. */
  75035. renderList: Nullable<Array<AbstractMesh>>;
  75036. private _hookArray;
  75037. /**
  75038. * Define if particles should be rendered in your texture.
  75039. */
  75040. renderParticles: boolean;
  75041. /**
  75042. * Define if sprites should be rendered in your texture.
  75043. */
  75044. renderSprites: boolean;
  75045. /**
  75046. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75047. */
  75048. coordinatesMode: number;
  75049. /**
  75050. * Define the camera used to render the texture.
  75051. */
  75052. activeCamera: Nullable<Camera>;
  75053. /**
  75054. * Override the render function of the texture with your own one.
  75055. */
  75056. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75057. /**
  75058. * Define if camera post processes should be use while rendering the texture.
  75059. */
  75060. useCameraPostProcesses: boolean;
  75061. /**
  75062. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75063. */
  75064. ignoreCameraViewport: boolean;
  75065. private _postProcessManager;
  75066. private _postProcesses;
  75067. private _resizeObserver;
  75068. /**
  75069. * An event triggered when the texture is unbind.
  75070. */
  75071. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75072. /**
  75073. * An event triggered when the texture is unbind.
  75074. */
  75075. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75076. private _onAfterUnbindObserver;
  75077. /**
  75078. * Set a after unbind callback in the texture.
  75079. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75080. */
  75081. onAfterUnbind: () => void;
  75082. /**
  75083. * An event triggered before rendering the texture
  75084. */
  75085. onBeforeRenderObservable: Observable<number>;
  75086. private _onBeforeRenderObserver;
  75087. /**
  75088. * Set a before render callback in the texture.
  75089. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75090. */
  75091. onBeforeRender: (faceIndex: number) => void;
  75092. /**
  75093. * An event triggered after rendering the texture
  75094. */
  75095. onAfterRenderObservable: Observable<number>;
  75096. private _onAfterRenderObserver;
  75097. /**
  75098. * Set a after render callback in the texture.
  75099. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75100. */
  75101. onAfterRender: (faceIndex: number) => void;
  75102. /**
  75103. * An event triggered after the texture clear
  75104. */
  75105. onClearObservable: Observable<Engine>;
  75106. private _onClearObserver;
  75107. /**
  75108. * Set a clear callback in the texture.
  75109. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75110. */
  75111. onClear: (Engine: Engine) => void;
  75112. /**
  75113. * Define the clear color of the Render Target if it should be different from the scene.
  75114. */
  75115. clearColor: Color4;
  75116. protected _size: number | {
  75117. width: number;
  75118. height: number;
  75119. };
  75120. protected _initialSizeParameter: number | {
  75121. width: number;
  75122. height: number;
  75123. } | {
  75124. ratio: number;
  75125. };
  75126. protected _sizeRatio: Nullable<number>;
  75127. /** @hidden */
  75128. _generateMipMaps: boolean;
  75129. protected _renderingManager: RenderingManager;
  75130. /** @hidden */
  75131. _waitingRenderList: string[];
  75132. protected _doNotChangeAspectRatio: boolean;
  75133. protected _currentRefreshId: number;
  75134. protected _refreshRate: number;
  75135. protected _textureMatrix: Matrix;
  75136. protected _samples: number;
  75137. protected _renderTargetOptions: RenderTargetCreationOptions;
  75138. /**
  75139. * Gets render target creation options that were used.
  75140. */
  75141. readonly renderTargetOptions: RenderTargetCreationOptions;
  75142. protected _engine: Engine;
  75143. protected _onRatioRescale(): void;
  75144. /**
  75145. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75146. * It must define where the camera used to render the texture is set
  75147. */
  75148. boundingBoxPosition: Vector3;
  75149. private _boundingBoxSize;
  75150. /**
  75151. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75152. * When defined, the cubemap will switch to local mode
  75153. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75154. * @example https://www.babylonjs-playground.com/#RNASML
  75155. */
  75156. boundingBoxSize: Vector3;
  75157. /**
  75158. * In case the RTT has been created with a depth texture, get the associated
  75159. * depth texture.
  75160. * Otherwise, return null.
  75161. */
  75162. depthStencilTexture: Nullable<InternalTexture>;
  75163. /**
  75164. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75165. * or used a shadow, depth texture...
  75166. * @param name The friendly name of the texture
  75167. * @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)
  75168. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75169. * @param generateMipMaps True if mip maps need to be generated after render.
  75170. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75171. * @param type The type of the buffer in the RTT (int, half float, float...)
  75172. * @param isCube True if a cube texture needs to be created
  75173. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75174. * @param generateDepthBuffer True to generate a depth buffer
  75175. * @param generateStencilBuffer True to generate a stencil buffer
  75176. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75177. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75178. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75179. */
  75180. constructor(name: string, size: number | {
  75181. width: number;
  75182. height: number;
  75183. } | {
  75184. ratio: number;
  75185. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75186. /**
  75187. * Creates a depth stencil texture.
  75188. * This is only available in WebGL 2 or with the depth texture extension available.
  75189. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75190. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75191. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75192. */
  75193. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75194. private _processSizeParameter;
  75195. /**
  75196. * Define the number of samples to use in case of MSAA.
  75197. * It defaults to one meaning no MSAA has been enabled.
  75198. */
  75199. samples: number;
  75200. /**
  75201. * Resets the refresh counter of the texture and start bak from scratch.
  75202. * Could be useful to regenerate the texture if it is setup to render only once.
  75203. */
  75204. resetRefreshCounter(): void;
  75205. /**
  75206. * Define the refresh rate of the texture or the rendering frequency.
  75207. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75208. */
  75209. refreshRate: number;
  75210. /**
  75211. * Adds a post process to the render target rendering passes.
  75212. * @param postProcess define the post process to add
  75213. */
  75214. addPostProcess(postProcess: PostProcess): void;
  75215. /**
  75216. * Clear all the post processes attached to the render target
  75217. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75218. */
  75219. clearPostProcesses(dispose?: boolean): void;
  75220. /**
  75221. * Remove one of the post process from the list of attached post processes to the texture
  75222. * @param postProcess define the post process to remove from the list
  75223. */
  75224. removePostProcess(postProcess: PostProcess): void;
  75225. /** @hidden */
  75226. _shouldRender(): boolean;
  75227. /**
  75228. * Gets the actual render size of the texture.
  75229. * @returns the width of the render size
  75230. */
  75231. getRenderSize(): number;
  75232. /**
  75233. * Gets the actual render width of the texture.
  75234. * @returns the width of the render size
  75235. */
  75236. getRenderWidth(): number;
  75237. /**
  75238. * Gets the actual render height of the texture.
  75239. * @returns the height of the render size
  75240. */
  75241. getRenderHeight(): number;
  75242. /**
  75243. * Get if the texture can be rescaled or not.
  75244. */
  75245. readonly canRescale: boolean;
  75246. /**
  75247. * Resize the texture using a ratio.
  75248. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75249. */
  75250. scale(ratio: number): void;
  75251. /**
  75252. * Get the texture reflection matrix used to rotate/transform the reflection.
  75253. * @returns the reflection matrix
  75254. */
  75255. getReflectionTextureMatrix(): Matrix;
  75256. /**
  75257. * Resize the texture to a new desired size.
  75258. * Be carrefull as it will recreate all the data in the new texture.
  75259. * @param size Define the new size. It can be:
  75260. * - a number for squared texture,
  75261. * - an object containing { width: number, height: number }
  75262. * - or an object containing a ratio { ratio: number }
  75263. */
  75264. resize(size: number | {
  75265. width: number;
  75266. height: number;
  75267. } | {
  75268. ratio: number;
  75269. }): void;
  75270. /**
  75271. * Renders all the objects from the render list into the texture.
  75272. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75273. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75274. */
  75275. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75276. private _bestReflectionRenderTargetDimension;
  75277. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75278. private renderToTarget;
  75279. /**
  75280. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75281. * This allowed control for front to back rendering or reversly depending of the special needs.
  75282. *
  75283. * @param renderingGroupId The rendering group id corresponding to its index
  75284. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75285. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75286. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75287. */
  75288. 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;
  75289. /**
  75290. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75291. *
  75292. * @param renderingGroupId The rendering group id corresponding to its index
  75293. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75294. */
  75295. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75296. /**
  75297. * Clones the texture.
  75298. * @returns the cloned texture
  75299. */
  75300. clone(): RenderTargetTexture;
  75301. /**
  75302. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75303. * @returns The JSON representation of the texture
  75304. */
  75305. serialize(): any;
  75306. /**
  75307. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75308. */
  75309. disposeFramebufferObjects(): void;
  75310. /**
  75311. * Dispose the texture and release its associated resources.
  75312. */
  75313. dispose(): void;
  75314. /** @hidden */
  75315. _rebuild(): void;
  75316. /**
  75317. * Clear the info related to rendering groups preventing retention point in material dispose.
  75318. */
  75319. freeRenderingGroups(): void;
  75320. }
  75321. }
  75322. declare module BABYLON {
  75323. /**
  75324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75326. * You can then easily use it as a reflectionTexture on a flat surface.
  75327. * In case the surface is not a plane, please consider relying on reflection probes.
  75328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75329. */
  75330. export class MirrorTexture extends RenderTargetTexture {
  75331. private scene;
  75332. /**
  75333. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75334. * 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.
  75335. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75336. */
  75337. mirrorPlane: Plane;
  75338. /**
  75339. * Define the blur ratio used to blur the reflection if needed.
  75340. */
  75341. blurRatio: number;
  75342. /**
  75343. * Define the adaptive blur kernel used to blur the reflection if needed.
  75344. * This will autocompute the closest best match for the `blurKernel`
  75345. */
  75346. adaptiveBlurKernel: number;
  75347. /**
  75348. * Define the blur kernel used to blur the reflection if needed.
  75349. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75350. */
  75351. blurKernel: number;
  75352. /**
  75353. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75354. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75355. */
  75356. blurKernelX: number;
  75357. /**
  75358. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75359. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75360. */
  75361. blurKernelY: number;
  75362. private _autoComputeBlurKernel;
  75363. protected _onRatioRescale(): void;
  75364. private _updateGammaSpace;
  75365. private _imageProcessingConfigChangeObserver;
  75366. private _transformMatrix;
  75367. private _mirrorMatrix;
  75368. private _savedViewMatrix;
  75369. private _blurX;
  75370. private _blurY;
  75371. private _adaptiveBlurKernel;
  75372. private _blurKernelX;
  75373. private _blurKernelY;
  75374. private _blurRatio;
  75375. /**
  75376. * Instantiates a Mirror Texture.
  75377. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75378. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75379. * You can then easily use it as a reflectionTexture on a flat surface.
  75380. * In case the surface is not a plane, please consider relying on reflection probes.
  75381. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75382. * @param name
  75383. * @param size
  75384. * @param scene
  75385. * @param generateMipMaps
  75386. * @param type
  75387. * @param samplingMode
  75388. * @param generateDepthBuffer
  75389. */
  75390. constructor(name: string, size: number | {
  75391. width: number;
  75392. height: number;
  75393. } | {
  75394. ratio: number;
  75395. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75396. private _preparePostProcesses;
  75397. /**
  75398. * Clone the mirror texture.
  75399. * @returns the cloned texture
  75400. */
  75401. clone(): MirrorTexture;
  75402. /**
  75403. * Serialize the texture to a JSON representation you could use in Parse later on
  75404. * @returns the serialized JSON representation
  75405. */
  75406. serialize(): any;
  75407. /**
  75408. * Dispose the texture and release its associated resources.
  75409. */
  75410. dispose(): void;
  75411. }
  75412. }
  75413. declare module BABYLON {
  75414. /**
  75415. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75416. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75417. */
  75418. export class Texture extends BaseTexture {
  75419. /** @hidden */
  75420. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75421. /** @hidden */
  75422. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75423. /** @hidden */
  75424. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75425. /** nearest is mag = nearest and min = nearest and mip = linear */
  75426. static readonly NEAREST_SAMPLINGMODE: number;
  75427. /** nearest is mag = nearest and min = nearest and mip = linear */
  75428. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75429. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75430. static readonly BILINEAR_SAMPLINGMODE: number;
  75431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75432. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75433. /** Trilinear is mag = linear and min = linear and mip = linear */
  75434. static readonly TRILINEAR_SAMPLINGMODE: number;
  75435. /** Trilinear is mag = linear and min = linear and mip = linear */
  75436. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75437. /** mag = nearest and min = nearest and mip = nearest */
  75438. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75439. /** mag = nearest and min = linear and mip = nearest */
  75440. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75441. /** mag = nearest and min = linear and mip = linear */
  75442. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75443. /** mag = nearest and min = linear and mip = none */
  75444. static readonly NEAREST_LINEAR: number;
  75445. /** mag = nearest and min = nearest and mip = none */
  75446. static readonly NEAREST_NEAREST: number;
  75447. /** mag = linear and min = nearest and mip = nearest */
  75448. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75449. /** mag = linear and min = nearest and mip = linear */
  75450. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75451. /** mag = linear and min = linear and mip = none */
  75452. static readonly LINEAR_LINEAR: number;
  75453. /** mag = linear and min = nearest and mip = none */
  75454. static readonly LINEAR_NEAREST: number;
  75455. /** Explicit coordinates mode */
  75456. static readonly EXPLICIT_MODE: number;
  75457. /** Spherical coordinates mode */
  75458. static readonly SPHERICAL_MODE: number;
  75459. /** Planar coordinates mode */
  75460. static readonly PLANAR_MODE: number;
  75461. /** Cubic coordinates mode */
  75462. static readonly CUBIC_MODE: number;
  75463. /** Projection coordinates mode */
  75464. static readonly PROJECTION_MODE: number;
  75465. /** Inverse Cubic coordinates mode */
  75466. static readonly SKYBOX_MODE: number;
  75467. /** Inverse Cubic coordinates mode */
  75468. static readonly INVCUBIC_MODE: number;
  75469. /** Equirectangular coordinates mode */
  75470. static readonly EQUIRECTANGULAR_MODE: number;
  75471. /** Equirectangular Fixed coordinates mode */
  75472. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75473. /** Equirectangular Fixed Mirrored coordinates mode */
  75474. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75475. /** Texture is not repeating outside of 0..1 UVs */
  75476. static readonly CLAMP_ADDRESSMODE: number;
  75477. /** Texture is repeating outside of 0..1 UVs */
  75478. static readonly WRAP_ADDRESSMODE: number;
  75479. /** Texture is repeating and mirrored */
  75480. static readonly MIRROR_ADDRESSMODE: number;
  75481. /**
  75482. * 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
  75483. */
  75484. static UseSerializedUrlIfAny: boolean;
  75485. /**
  75486. * Define the url of the texture.
  75487. */
  75488. url: Nullable<string>;
  75489. /**
  75490. * Define an offset on the texture to offset the u coordinates of the UVs
  75491. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75492. */
  75493. uOffset: number;
  75494. /**
  75495. * Define an offset on the texture to offset the v coordinates of the UVs
  75496. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75497. */
  75498. vOffset: number;
  75499. /**
  75500. * Define an offset on the texture to scale the u coordinates of the UVs
  75501. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75502. */
  75503. uScale: number;
  75504. /**
  75505. * Define an offset on the texture to scale the v coordinates of the UVs
  75506. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75507. */
  75508. vScale: number;
  75509. /**
  75510. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75511. * @see http://doc.babylonjs.com/how_to/more_materials
  75512. */
  75513. uAng: number;
  75514. /**
  75515. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75516. * @see http://doc.babylonjs.com/how_to/more_materials
  75517. */
  75518. vAng: number;
  75519. /**
  75520. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75521. * @see http://doc.babylonjs.com/how_to/more_materials
  75522. */
  75523. wAng: number;
  75524. /**
  75525. * Defines the center of rotation (U)
  75526. */
  75527. uRotationCenter: number;
  75528. /**
  75529. * Defines the center of rotation (V)
  75530. */
  75531. vRotationCenter: number;
  75532. /**
  75533. * Defines the center of rotation (W)
  75534. */
  75535. wRotationCenter: number;
  75536. /**
  75537. * Are mip maps generated for this texture or not.
  75538. */
  75539. readonly noMipmap: boolean;
  75540. private _noMipmap;
  75541. /** @hidden */
  75542. _invertY: boolean;
  75543. private _rowGenerationMatrix;
  75544. private _cachedTextureMatrix;
  75545. private _projectionModeMatrix;
  75546. private _t0;
  75547. private _t1;
  75548. private _t2;
  75549. private _cachedUOffset;
  75550. private _cachedVOffset;
  75551. private _cachedUScale;
  75552. private _cachedVScale;
  75553. private _cachedUAng;
  75554. private _cachedVAng;
  75555. private _cachedWAng;
  75556. private _cachedProjectionMatrixId;
  75557. private _cachedCoordinatesMode;
  75558. /** @hidden */
  75559. protected _initialSamplingMode: number;
  75560. /** @hidden */
  75561. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75562. private _deleteBuffer;
  75563. protected _format: Nullable<number>;
  75564. private _delayedOnLoad;
  75565. private _delayedOnError;
  75566. /**
  75567. * Observable triggered once the texture has been loaded.
  75568. */
  75569. onLoadObservable: Observable<Texture>;
  75570. protected _isBlocking: boolean;
  75571. /**
  75572. * Is the texture preventing material to render while loading.
  75573. * If false, a default texture will be used instead of the loading one during the preparation step.
  75574. */
  75575. isBlocking: boolean;
  75576. /**
  75577. * Get the current sampling mode associated with the texture.
  75578. */
  75579. readonly samplingMode: number;
  75580. /**
  75581. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75582. */
  75583. readonly invertY: boolean;
  75584. /**
  75585. * Instantiates a new texture.
  75586. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75587. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75588. * @param url define the url of the picture to load as a texture
  75589. * @param scene define the scene the texture will belong to
  75590. * @param noMipmap define if the texture will require mip maps or not
  75591. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75592. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75593. * @param onLoad define a callback triggered when the texture has been loaded
  75594. * @param onError define a callback triggered when an error occurred during the loading session
  75595. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75596. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75597. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75598. */
  75599. 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);
  75600. /**
  75601. * Update the url (and optional buffer) of this texture if url was null during construction.
  75602. * @param url the url of the texture
  75603. * @param buffer the buffer of the texture (defaults to null)
  75604. * @param onLoad callback called when the texture is loaded (defaults to null)
  75605. */
  75606. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75607. /**
  75608. * Finish the loading sequence of a texture flagged as delayed load.
  75609. * @hidden
  75610. */
  75611. delayLoad(): void;
  75612. private _prepareRowForTextureGeneration;
  75613. /**
  75614. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75615. * @returns the transform matrix of the texture.
  75616. */
  75617. getTextureMatrix(): Matrix;
  75618. /**
  75619. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75620. * @returns The reflection texture transform
  75621. */
  75622. getReflectionTextureMatrix(): Matrix;
  75623. /**
  75624. * Clones the texture.
  75625. * @returns the cloned texture
  75626. */
  75627. clone(): Texture;
  75628. /**
  75629. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75630. * @returns The JSON representation of the texture
  75631. */
  75632. serialize(): any;
  75633. /**
  75634. * Get the current class name of the texture useful for serialization or dynamic coding.
  75635. * @returns "Texture"
  75636. */
  75637. getClassName(): string;
  75638. /**
  75639. * Dispose the texture and release its associated resources.
  75640. */
  75641. dispose(): void;
  75642. /**
  75643. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75644. * @param parsedTexture Define the JSON representation of the texture
  75645. * @param scene Define the scene the parsed texture should be instantiated in
  75646. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75647. * @returns The parsed texture if successful
  75648. */
  75649. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75650. /**
  75651. * Creates a texture from its base 64 representation.
  75652. * @param data Define the base64 payload without the data: prefix
  75653. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75654. * @param scene Define the scene the texture should belong to
  75655. * @param noMipmap Forces the texture to not create mip map information if true
  75656. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75657. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75658. * @param onLoad define a callback triggered when the texture has been loaded
  75659. * @param onError define a callback triggered when an error occurred during the loading session
  75660. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75661. * @returns the created texture
  75662. */
  75663. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75664. /**
  75665. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75666. * @param data Define the base64 payload without the data: prefix
  75667. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75668. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75669. * @param scene Define the scene the texture should belong to
  75670. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75671. * @param noMipmap Forces the texture to not create mip map information if true
  75672. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75673. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75674. * @param onLoad define a callback triggered when the texture has been loaded
  75675. * @param onError define a callback triggered when an error occurred during the loading session
  75676. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75677. * @returns the created texture
  75678. */
  75679. 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;
  75680. }
  75681. }
  75682. declare module BABYLON {
  75683. /**
  75684. * Raw texture can help creating a texture directly from an array of data.
  75685. * This can be super useful if you either get the data from an uncompressed source or
  75686. * if you wish to create your texture pixel by pixel.
  75687. */
  75688. export class RawTexture extends Texture {
  75689. /**
  75690. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75691. */
  75692. format: number;
  75693. private _engine;
  75694. /**
  75695. * Instantiates a new RawTexture.
  75696. * Raw texture can help creating a texture directly from an array of data.
  75697. * This can be super useful if you either get the data from an uncompressed source or
  75698. * if you wish to create your texture pixel by pixel.
  75699. * @param data define the array of data to use to create the texture
  75700. * @param width define the width of the texture
  75701. * @param height define the height of the texture
  75702. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75703. * @param scene define the scene the texture belongs to
  75704. * @param generateMipMaps define whether mip maps should be generated or not
  75705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75707. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75708. */
  75709. constructor(data: ArrayBufferView, width: number, height: number,
  75710. /**
  75711. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75712. */
  75713. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75714. /**
  75715. * Updates the texture underlying data.
  75716. * @param data Define the new data of the texture
  75717. */
  75718. update(data: ArrayBufferView): void;
  75719. /**
  75720. * Creates a luminance texture from some data.
  75721. * @param data Define the texture data
  75722. * @param width Define the width of the texture
  75723. * @param height Define the height of the texture
  75724. * @param scene Define the scene the texture belongs to
  75725. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75726. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75727. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75728. * @returns the luminance texture
  75729. */
  75730. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75731. /**
  75732. * Creates a luminance alpha texture from some data.
  75733. * @param data Define the texture data
  75734. * @param width Define the width of the texture
  75735. * @param height Define the height of the texture
  75736. * @param scene Define the scene the texture belongs to
  75737. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75738. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75739. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75740. * @returns the luminance alpha texture
  75741. */
  75742. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75743. /**
  75744. * Creates an alpha texture from some data.
  75745. * @param data Define the texture data
  75746. * @param width Define the width of the texture
  75747. * @param height Define the height of the texture
  75748. * @param scene Define the scene the texture belongs to
  75749. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75750. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75751. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75752. * @returns the alpha texture
  75753. */
  75754. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75755. /**
  75756. * Creates a RGB texture from some data.
  75757. * @param data Define the texture data
  75758. * @param width Define the width of the texture
  75759. * @param height Define the height of the texture
  75760. * @param scene Define the scene the texture belongs to
  75761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75765. * @returns the RGB alpha texture
  75766. */
  75767. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75768. /**
  75769. * Creates a RGBA texture from some data.
  75770. * @param data Define the texture data
  75771. * @param width Define the width of the texture
  75772. * @param height Define the height of the texture
  75773. * @param scene Define the scene the texture belongs to
  75774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75778. * @returns the RGBA texture
  75779. */
  75780. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75781. /**
  75782. * Creates a R texture from some data.
  75783. * @param data Define the texture data
  75784. * @param width Define the width of the texture
  75785. * @param height Define the height of the texture
  75786. * @param scene Define the scene the texture belongs to
  75787. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75788. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75789. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75790. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75791. * @returns the R texture
  75792. */
  75793. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75794. }
  75795. }
  75796. declare module BABYLON {
  75797. /**
  75798. * Defines a runtime animation
  75799. */
  75800. export class RuntimeAnimation {
  75801. private _events;
  75802. /**
  75803. * The current frame of the runtime animation
  75804. */
  75805. private _currentFrame;
  75806. /**
  75807. * The animation used by the runtime animation
  75808. */
  75809. private _animation;
  75810. /**
  75811. * The target of the runtime animation
  75812. */
  75813. private _target;
  75814. /**
  75815. * The initiating animatable
  75816. */
  75817. private _host;
  75818. /**
  75819. * The original value of the runtime animation
  75820. */
  75821. private _originalValue;
  75822. /**
  75823. * The original blend value of the runtime animation
  75824. */
  75825. private _originalBlendValue;
  75826. /**
  75827. * The offsets cache of the runtime animation
  75828. */
  75829. private _offsetsCache;
  75830. /**
  75831. * The high limits cache of the runtime animation
  75832. */
  75833. private _highLimitsCache;
  75834. /**
  75835. * Specifies if the runtime animation has been stopped
  75836. */
  75837. private _stopped;
  75838. /**
  75839. * The blending factor of the runtime animation
  75840. */
  75841. private _blendingFactor;
  75842. /**
  75843. * The BabylonJS scene
  75844. */
  75845. private _scene;
  75846. /**
  75847. * The current value of the runtime animation
  75848. */
  75849. private _currentValue;
  75850. /** @hidden */
  75851. _workValue: any;
  75852. /**
  75853. * The active target of the runtime animation
  75854. */
  75855. private _activeTarget;
  75856. /**
  75857. * The target path of the runtime animation
  75858. */
  75859. private _targetPath;
  75860. /**
  75861. * The weight of the runtime animation
  75862. */
  75863. private _weight;
  75864. /**
  75865. * The ratio offset of the runtime animation
  75866. */
  75867. private _ratioOffset;
  75868. /**
  75869. * The previous delay of the runtime animation
  75870. */
  75871. private _previousDelay;
  75872. /**
  75873. * The previous ratio of the runtime animation
  75874. */
  75875. private _previousRatio;
  75876. /**
  75877. * Gets the current frame of the runtime animation
  75878. */
  75879. readonly currentFrame: number;
  75880. /**
  75881. * Gets the weight of the runtime animation
  75882. */
  75883. readonly weight: number;
  75884. /**
  75885. * Gets the current value of the runtime animation
  75886. */
  75887. readonly currentValue: any;
  75888. /**
  75889. * Gets the target path of the runtime animation
  75890. */
  75891. readonly targetPath: string;
  75892. /**
  75893. * Gets the actual target of the runtime animation
  75894. */
  75895. readonly target: any;
  75896. /**
  75897. * Create a new RuntimeAnimation object
  75898. * @param target defines the target of the animation
  75899. * @param animation defines the source animation object
  75900. * @param scene defines the hosting scene
  75901. * @param host defines the initiating Animatable
  75902. */
  75903. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75904. /**
  75905. * Gets the animation from the runtime animation
  75906. */
  75907. readonly animation: Animation;
  75908. /**
  75909. * Resets the runtime animation to the beginning
  75910. * @param restoreOriginal defines whether to restore the target property to the original value
  75911. */
  75912. reset(restoreOriginal?: boolean): void;
  75913. /**
  75914. * Specifies if the runtime animation is stopped
  75915. * @returns Boolean specifying if the runtime animation is stopped
  75916. */
  75917. isStopped(): boolean;
  75918. /**
  75919. * Disposes of the runtime animation
  75920. */
  75921. dispose(): void;
  75922. /**
  75923. * Interpolates the animation from the current frame
  75924. * @param currentFrame The frame to interpolate the animation to
  75925. * @param repeatCount The number of times that the animation should loop
  75926. * @param loopMode The type of looping mode to use
  75927. * @param offsetValue Animation offset value
  75928. * @param highLimitValue The high limit value
  75929. * @returns The interpolated value
  75930. */
  75931. private _interpolate;
  75932. /**
  75933. * Apply the interpolated value to the target
  75934. * @param currentValue defines the value computed by the animation
  75935. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75936. */
  75937. setValue(currentValue: any, weight?: number): void;
  75938. private _setValue;
  75939. /**
  75940. * Gets the loop pmode of the runtime animation
  75941. * @returns Loop Mode
  75942. */
  75943. private _getCorrectLoopMode;
  75944. /**
  75945. * Move the current animation to a given frame
  75946. * @param frame defines the frame to move to
  75947. */
  75948. goToFrame(frame: number): void;
  75949. /**
  75950. * @hidden Internal use only
  75951. */
  75952. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75953. /**
  75954. * Execute the current animation
  75955. * @param delay defines the delay to add to the current frame
  75956. * @param from defines the lower bound of the animation range
  75957. * @param to defines the upper bound of the animation range
  75958. * @param loop defines if the current animation must loop
  75959. * @param speedRatio defines the current speed ratio
  75960. * @param weight defines the weight of the animation (default is -1 so no weight)
  75961. * @param onLoop optional callback called when animation loops
  75962. * @returns a boolean indicating if the animation is running
  75963. */
  75964. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75965. }
  75966. }
  75967. declare module BABYLON {
  75968. /**
  75969. * Class used to store an actual running animation
  75970. */
  75971. export class Animatable {
  75972. /** defines the target object */
  75973. target: any;
  75974. /** defines the starting frame number (default is 0) */
  75975. fromFrame: number;
  75976. /** defines the ending frame number (default is 100) */
  75977. toFrame: number;
  75978. /** defines if the animation must loop (default is false) */
  75979. loopAnimation: boolean;
  75980. /** defines a callback to call when animation ends if it is not looping */
  75981. onAnimationEnd?: (() => void) | null | undefined;
  75982. /** defines a callback to call when animation loops */
  75983. onAnimationLoop?: (() => void) | null | undefined;
  75984. private _localDelayOffset;
  75985. private _pausedDelay;
  75986. private _runtimeAnimations;
  75987. private _paused;
  75988. private _scene;
  75989. private _speedRatio;
  75990. private _weight;
  75991. private _syncRoot;
  75992. /**
  75993. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75994. * This will only apply for non looping animation (default is true)
  75995. */
  75996. disposeOnEnd: boolean;
  75997. /**
  75998. * Gets a boolean indicating if the animation has started
  75999. */
  76000. animationStarted: boolean;
  76001. /**
  76002. * Observer raised when the animation ends
  76003. */
  76004. onAnimationEndObservable: Observable<Animatable>;
  76005. /**
  76006. * Observer raised when the animation loops
  76007. */
  76008. onAnimationLoopObservable: Observable<Animatable>;
  76009. /**
  76010. * Gets the root Animatable used to synchronize and normalize animations
  76011. */
  76012. readonly syncRoot: Animatable;
  76013. /**
  76014. * Gets the current frame of the first RuntimeAnimation
  76015. * Used to synchronize Animatables
  76016. */
  76017. readonly masterFrame: number;
  76018. /**
  76019. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76020. */
  76021. weight: number;
  76022. /**
  76023. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76024. */
  76025. speedRatio: number;
  76026. /**
  76027. * Creates a new Animatable
  76028. * @param scene defines the hosting scene
  76029. * @param target defines the target object
  76030. * @param fromFrame defines the starting frame number (default is 0)
  76031. * @param toFrame defines the ending frame number (default is 100)
  76032. * @param loopAnimation defines if the animation must loop (default is false)
  76033. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76034. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76035. * @param animations defines a group of animation to add to the new Animatable
  76036. * @param onAnimationLoop defines a callback to call when animation loops
  76037. */
  76038. constructor(scene: Scene,
  76039. /** defines the target object */
  76040. target: any,
  76041. /** defines the starting frame number (default is 0) */
  76042. fromFrame?: number,
  76043. /** defines the ending frame number (default is 100) */
  76044. toFrame?: number,
  76045. /** defines if the animation must loop (default is false) */
  76046. loopAnimation?: boolean, speedRatio?: number,
  76047. /** defines a callback to call when animation ends if it is not looping */
  76048. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76049. /** defines a callback to call when animation loops */
  76050. onAnimationLoop?: (() => void) | null | undefined);
  76051. /**
  76052. * Synchronize and normalize current Animatable with a source Animatable
  76053. * This is useful when using animation weights and when animations are not of the same length
  76054. * @param root defines the root Animatable to synchronize with
  76055. * @returns the current Animatable
  76056. */
  76057. syncWith(root: Animatable): Animatable;
  76058. /**
  76059. * Gets the list of runtime animations
  76060. * @returns an array of RuntimeAnimation
  76061. */
  76062. getAnimations(): RuntimeAnimation[];
  76063. /**
  76064. * Adds more animations to the current animatable
  76065. * @param target defines the target of the animations
  76066. * @param animations defines the new animations to add
  76067. */
  76068. appendAnimations(target: any, animations: Animation[]): void;
  76069. /**
  76070. * Gets the source animation for a specific property
  76071. * @param property defines the propertyu to look for
  76072. * @returns null or the source animation for the given property
  76073. */
  76074. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76075. /**
  76076. * Gets the runtime animation for a specific property
  76077. * @param property defines the propertyu to look for
  76078. * @returns null or the runtime animation for the given property
  76079. */
  76080. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76081. /**
  76082. * Resets the animatable to its original state
  76083. */
  76084. reset(): void;
  76085. /**
  76086. * Allows the animatable to blend with current running animations
  76087. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76088. * @param blendingSpeed defines the blending speed to use
  76089. */
  76090. enableBlending(blendingSpeed: number): void;
  76091. /**
  76092. * Disable animation blending
  76093. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76094. */
  76095. disableBlending(): void;
  76096. /**
  76097. * Jump directly to a given frame
  76098. * @param frame defines the frame to jump to
  76099. */
  76100. goToFrame(frame: number): void;
  76101. /**
  76102. * Pause the animation
  76103. */
  76104. pause(): void;
  76105. /**
  76106. * Restart the animation
  76107. */
  76108. restart(): void;
  76109. private _raiseOnAnimationEnd;
  76110. /**
  76111. * Stop and delete the current animation
  76112. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76113. * @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)
  76114. */
  76115. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76116. /**
  76117. * Wait asynchronously for the animation to end
  76118. * @returns a promise which will be fullfilled when the animation ends
  76119. */
  76120. waitAsync(): Promise<Animatable>;
  76121. /** @hidden */
  76122. _animate(delay: number): boolean;
  76123. }
  76124. interface Scene {
  76125. /** @hidden */
  76126. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76127. /** @hidden */
  76128. _processLateAnimationBindingsForMatrices(holder: {
  76129. totalWeight: number;
  76130. animations: RuntimeAnimation[];
  76131. originalValue: Matrix;
  76132. }): any;
  76133. /** @hidden */
  76134. _processLateAnimationBindingsForQuaternions(holder: {
  76135. totalWeight: number;
  76136. animations: RuntimeAnimation[];
  76137. originalValue: Quaternion;
  76138. }, refQuaternion: Quaternion): Quaternion;
  76139. /** @hidden */
  76140. _processLateAnimationBindings(): void;
  76141. /**
  76142. * Will start the animation sequence of a given target
  76143. * @param target defines the target
  76144. * @param from defines from which frame should animation start
  76145. * @param to defines until which frame should animation run.
  76146. * @param weight defines the weight to apply to the animation (1.0 by default)
  76147. * @param loop defines if the animation loops
  76148. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76149. * @param onAnimationEnd defines the function to be executed when the animation ends
  76150. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76151. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76152. * @param onAnimationLoop defines the callback to call when an animation loops
  76153. * @returns the animatable object created for this animation
  76154. */
  76155. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76156. /**
  76157. * Will start the animation sequence of a given target
  76158. * @param target defines the target
  76159. * @param from defines from which frame should animation start
  76160. * @param to defines until which frame should animation run.
  76161. * @param loop defines if the animation loops
  76162. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76163. * @param onAnimationEnd defines the function to be executed when the animation ends
  76164. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76165. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76166. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76167. * @param onAnimationLoop defines the callback to call when an animation loops
  76168. * @returns the animatable object created for this animation
  76169. */
  76170. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76171. /**
  76172. * Will start the animation sequence of a given target and its hierarchy
  76173. * @param target defines the target
  76174. * @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.
  76175. * @param from defines from which frame should animation start
  76176. * @param to defines until which frame should animation run.
  76177. * @param loop defines if the animation loops
  76178. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76179. * @param onAnimationEnd defines the function to be executed when the animation ends
  76180. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76181. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76182. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76183. * @param onAnimationLoop defines the callback to call when an animation loops
  76184. * @returns the list of created animatables
  76185. */
  76186. 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[];
  76187. /**
  76188. * Begin a new animation on a given node
  76189. * @param target defines the target where the animation will take place
  76190. * @param animations defines the list of animations to start
  76191. * @param from defines the initial value
  76192. * @param to defines the final value
  76193. * @param loop defines if you want animation to loop (off by default)
  76194. * @param speedRatio defines the speed ratio to apply to all animations
  76195. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76196. * @param onAnimationLoop defines the callback to call when an animation loops
  76197. * @returns the list of created animatables
  76198. */
  76199. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76200. /**
  76201. * Begin a new animation on a given node and its hierarchy
  76202. * @param target defines the root node where the animation will take place
  76203. * @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.
  76204. * @param animations defines the list of animations to start
  76205. * @param from defines the initial value
  76206. * @param to defines the final value
  76207. * @param loop defines if you want animation to loop (off by default)
  76208. * @param speedRatio defines the speed ratio to apply to all animations
  76209. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76210. * @param onAnimationLoop defines the callback to call when an animation loops
  76211. * @returns the list of animatables created for all nodes
  76212. */
  76213. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76214. /**
  76215. * Gets the animatable associated with a specific target
  76216. * @param target defines the target of the animatable
  76217. * @returns the required animatable if found
  76218. */
  76219. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76220. /**
  76221. * Gets all animatables associated with a given target
  76222. * @param target defines the target to look animatables for
  76223. * @returns an array of Animatables
  76224. */
  76225. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76226. /**
  76227. * Will stop the animation of the given target
  76228. * @param target - the target
  76229. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76230. * @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)
  76231. */
  76232. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76233. /**
  76234. * Stops and removes all animations that have been applied to the scene
  76235. */
  76236. stopAllAnimations(): void;
  76237. }
  76238. interface Bone {
  76239. /**
  76240. * Copy an animation range from another bone
  76241. * @param source defines the source bone
  76242. * @param rangeName defines the range name to copy
  76243. * @param frameOffset defines the frame offset
  76244. * @param rescaleAsRequired defines if rescaling must be applied if required
  76245. * @param skelDimensionsRatio defines the scaling ratio
  76246. * @returns true if operation was successful
  76247. */
  76248. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76249. }
  76250. }
  76251. declare module BABYLON {
  76252. /**
  76253. * Class used to handle skinning animations
  76254. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76255. */
  76256. export class Skeleton implements IAnimatable {
  76257. /** defines the skeleton name */
  76258. name: string;
  76259. /** defines the skeleton Id */
  76260. id: string;
  76261. /**
  76262. * Defines the list of child bones
  76263. */
  76264. bones: Bone[];
  76265. /**
  76266. * Defines an estimate of the dimension of the skeleton at rest
  76267. */
  76268. dimensionsAtRest: Vector3;
  76269. /**
  76270. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76271. */
  76272. needInitialSkinMatrix: boolean;
  76273. /**
  76274. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76275. */
  76276. overrideMesh: Nullable<AbstractMesh>;
  76277. /**
  76278. * Gets the list of animations attached to this skeleton
  76279. */
  76280. animations: Array<Animation>;
  76281. private _scene;
  76282. private _isDirty;
  76283. private _transformMatrices;
  76284. private _transformMatrixTexture;
  76285. private _meshesWithPoseMatrix;
  76286. private _animatables;
  76287. private _identity;
  76288. private _synchronizedWithMesh;
  76289. private _ranges;
  76290. private _lastAbsoluteTransformsUpdateId;
  76291. private _canUseTextureForBones;
  76292. /** @hidden */
  76293. _numBonesWithLinkedTransformNode: number;
  76294. /**
  76295. * Specifies if the skeleton should be serialized
  76296. */
  76297. doNotSerialize: boolean;
  76298. private _useTextureToStoreBoneMatrices;
  76299. /**
  76300. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76301. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76302. */
  76303. useTextureToStoreBoneMatrices: boolean;
  76304. private _animationPropertiesOverride;
  76305. /**
  76306. * Gets or sets the animation properties override
  76307. */
  76308. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76309. /**
  76310. * An observable triggered before computing the skeleton's matrices
  76311. */
  76312. onBeforeComputeObservable: Observable<Skeleton>;
  76313. /**
  76314. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76315. */
  76316. readonly isUsingTextureForMatrices: boolean;
  76317. /**
  76318. * Creates a new skeleton
  76319. * @param name defines the skeleton name
  76320. * @param id defines the skeleton Id
  76321. * @param scene defines the hosting scene
  76322. */
  76323. constructor(
  76324. /** defines the skeleton name */
  76325. name: string,
  76326. /** defines the skeleton Id */
  76327. id: string, scene: Scene);
  76328. /**
  76329. * Gets the current object class name.
  76330. * @return the class name
  76331. */
  76332. getClassName(): string;
  76333. /**
  76334. * Returns an array containing the root bones
  76335. * @returns an array containing the root bones
  76336. */
  76337. getChildren(): Array<Bone>;
  76338. /**
  76339. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76340. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76341. * @returns a Float32Array containing matrices data
  76342. */
  76343. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76344. /**
  76345. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76346. * @returns a raw texture containing the data
  76347. */
  76348. getTransformMatrixTexture(): Nullable<RawTexture>;
  76349. /**
  76350. * Gets the current hosting scene
  76351. * @returns a scene object
  76352. */
  76353. getScene(): Scene;
  76354. /**
  76355. * Gets a string representing the current skeleton data
  76356. * @param fullDetails defines a boolean indicating if we want a verbose version
  76357. * @returns a string representing the current skeleton data
  76358. */
  76359. toString(fullDetails?: boolean): string;
  76360. /**
  76361. * Get bone's index searching by name
  76362. * @param name defines bone's name to search for
  76363. * @return the indice of the bone. Returns -1 if not found
  76364. */
  76365. getBoneIndexByName(name: string): number;
  76366. /**
  76367. * Creater a new animation range
  76368. * @param name defines the name of the range
  76369. * @param from defines the start key
  76370. * @param to defines the end key
  76371. */
  76372. createAnimationRange(name: string, from: number, to: number): void;
  76373. /**
  76374. * Delete a specific animation range
  76375. * @param name defines the name of the range
  76376. * @param deleteFrames defines if frames must be removed as well
  76377. */
  76378. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76379. /**
  76380. * Gets a specific animation range
  76381. * @param name defines the name of the range to look for
  76382. * @returns the requested animation range or null if not found
  76383. */
  76384. getAnimationRange(name: string): Nullable<AnimationRange>;
  76385. /**
  76386. * Gets the list of all animation ranges defined on this skeleton
  76387. * @returns an array
  76388. */
  76389. getAnimationRanges(): Nullable<AnimationRange>[];
  76390. /**
  76391. * Copy animation range from a source skeleton.
  76392. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76393. * @param source defines the source skeleton
  76394. * @param name defines the name of the range to copy
  76395. * @param rescaleAsRequired defines if rescaling must be applied if required
  76396. * @returns true if operation was successful
  76397. */
  76398. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76399. /**
  76400. * Forces the skeleton to go to rest pose
  76401. */
  76402. returnToRest(): void;
  76403. private _getHighestAnimationFrame;
  76404. /**
  76405. * Begin a specific animation range
  76406. * @param name defines the name of the range to start
  76407. * @param loop defines if looping must be turned on (false by default)
  76408. * @param speedRatio defines the speed ratio to apply (1 by default)
  76409. * @param onAnimationEnd defines a callback which will be called when animation will end
  76410. * @returns a new animatable
  76411. */
  76412. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76413. /** @hidden */
  76414. _markAsDirty(): void;
  76415. /** @hidden */
  76416. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76417. /** @hidden */
  76418. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76419. private _computeTransformMatrices;
  76420. /**
  76421. * Build all resources required to render a skeleton
  76422. */
  76423. prepare(): void;
  76424. /**
  76425. * Gets the list of animatables currently running for this skeleton
  76426. * @returns an array of animatables
  76427. */
  76428. getAnimatables(): IAnimatable[];
  76429. /**
  76430. * Clone the current skeleton
  76431. * @param name defines the name of the new skeleton
  76432. * @param id defines the id of the enw skeleton
  76433. * @returns the new skeleton
  76434. */
  76435. clone(name: string, id: string): Skeleton;
  76436. /**
  76437. * Enable animation blending for this skeleton
  76438. * @param blendingSpeed defines the blending speed to apply
  76439. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76440. */
  76441. enableBlending(blendingSpeed?: number): void;
  76442. /**
  76443. * Releases all resources associated with the current skeleton
  76444. */
  76445. dispose(): void;
  76446. /**
  76447. * Serialize the skeleton in a JSON object
  76448. * @returns a JSON object
  76449. */
  76450. serialize(): any;
  76451. /**
  76452. * Creates a new skeleton from serialized data
  76453. * @param parsedSkeleton defines the serialized data
  76454. * @param scene defines the hosting scene
  76455. * @returns a new skeleton
  76456. */
  76457. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76458. /**
  76459. * Compute all node absolute transforms
  76460. * @param forceUpdate defines if computation must be done even if cache is up to date
  76461. */
  76462. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76463. /**
  76464. * Gets the root pose matrix
  76465. * @returns a matrix
  76466. */
  76467. getPoseMatrix(): Nullable<Matrix>;
  76468. /**
  76469. * Sorts bones per internal index
  76470. */
  76471. sortBones(): void;
  76472. private _sortBones;
  76473. }
  76474. }
  76475. declare module BABYLON {
  76476. /**
  76477. * Defines a target to use with MorphTargetManager
  76478. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76479. */
  76480. export class MorphTarget implements IAnimatable {
  76481. /** defines the name of the target */
  76482. name: string;
  76483. /**
  76484. * Gets or sets the list of animations
  76485. */
  76486. animations: Animation[];
  76487. private _scene;
  76488. private _positions;
  76489. private _normals;
  76490. private _tangents;
  76491. private _influence;
  76492. /**
  76493. * Observable raised when the influence changes
  76494. */
  76495. onInfluenceChanged: Observable<boolean>;
  76496. /** @hidden */
  76497. _onDataLayoutChanged: Observable<void>;
  76498. /**
  76499. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76500. */
  76501. influence: number;
  76502. /**
  76503. * Gets or sets the id of the morph Target
  76504. */
  76505. id: string;
  76506. private _animationPropertiesOverride;
  76507. /**
  76508. * Gets or sets the animation properties override
  76509. */
  76510. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76511. /**
  76512. * Creates a new MorphTarget
  76513. * @param name defines the name of the target
  76514. * @param influence defines the influence to use
  76515. * @param scene defines the scene the morphtarget belongs to
  76516. */
  76517. constructor(
  76518. /** defines the name of the target */
  76519. name: string, influence?: number, scene?: Nullable<Scene>);
  76520. /**
  76521. * Gets a boolean defining if the target contains position data
  76522. */
  76523. readonly hasPositions: boolean;
  76524. /**
  76525. * Gets a boolean defining if the target contains normal data
  76526. */
  76527. readonly hasNormals: boolean;
  76528. /**
  76529. * Gets a boolean defining if the target contains tangent data
  76530. */
  76531. readonly hasTangents: boolean;
  76532. /**
  76533. * Affects position data to this target
  76534. * @param data defines the position data to use
  76535. */
  76536. setPositions(data: Nullable<FloatArray>): void;
  76537. /**
  76538. * Gets the position data stored in this target
  76539. * @returns a FloatArray containing the position data (or null if not present)
  76540. */
  76541. getPositions(): Nullable<FloatArray>;
  76542. /**
  76543. * Affects normal data to this target
  76544. * @param data defines the normal data to use
  76545. */
  76546. setNormals(data: Nullable<FloatArray>): void;
  76547. /**
  76548. * Gets the normal data stored in this target
  76549. * @returns a FloatArray containing the normal data (or null if not present)
  76550. */
  76551. getNormals(): Nullable<FloatArray>;
  76552. /**
  76553. * Affects tangent data to this target
  76554. * @param data defines the tangent data to use
  76555. */
  76556. setTangents(data: Nullable<FloatArray>): void;
  76557. /**
  76558. * Gets the tangent data stored in this target
  76559. * @returns a FloatArray containing the tangent data (or null if not present)
  76560. */
  76561. getTangents(): Nullable<FloatArray>;
  76562. /**
  76563. * Serializes the current target into a Serialization object
  76564. * @returns the serialized object
  76565. */
  76566. serialize(): any;
  76567. /**
  76568. * Returns the string "MorphTarget"
  76569. * @returns "MorphTarget"
  76570. */
  76571. getClassName(): string;
  76572. /**
  76573. * Creates a new target from serialized data
  76574. * @param serializationObject defines the serialized data to use
  76575. * @returns a new MorphTarget
  76576. */
  76577. static Parse(serializationObject: any): MorphTarget;
  76578. /**
  76579. * Creates a MorphTarget from mesh data
  76580. * @param mesh defines the source mesh
  76581. * @param name defines the name to use for the new target
  76582. * @param influence defines the influence to attach to the target
  76583. * @returns a new MorphTarget
  76584. */
  76585. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76586. }
  76587. }
  76588. declare module BABYLON {
  76589. /**
  76590. * This class is used to deform meshes using morphing between different targets
  76591. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76592. */
  76593. export class MorphTargetManager {
  76594. private _targets;
  76595. private _targetInfluenceChangedObservers;
  76596. private _targetDataLayoutChangedObservers;
  76597. private _activeTargets;
  76598. private _scene;
  76599. private _influences;
  76600. private _supportsNormals;
  76601. private _supportsTangents;
  76602. private _vertexCount;
  76603. private _uniqueId;
  76604. private _tempInfluences;
  76605. /**
  76606. * Creates a new MorphTargetManager
  76607. * @param scene defines the current scene
  76608. */
  76609. constructor(scene?: Nullable<Scene>);
  76610. /**
  76611. * Gets the unique ID of this manager
  76612. */
  76613. readonly uniqueId: number;
  76614. /**
  76615. * Gets the number of vertices handled by this manager
  76616. */
  76617. readonly vertexCount: number;
  76618. /**
  76619. * Gets a boolean indicating if this manager supports morphing of normals
  76620. */
  76621. readonly supportsNormals: boolean;
  76622. /**
  76623. * Gets a boolean indicating if this manager supports morphing of tangents
  76624. */
  76625. readonly supportsTangents: boolean;
  76626. /**
  76627. * Gets the number of targets stored in this manager
  76628. */
  76629. readonly numTargets: number;
  76630. /**
  76631. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76632. */
  76633. readonly numInfluencers: number;
  76634. /**
  76635. * Gets the list of influences (one per target)
  76636. */
  76637. readonly influences: Float32Array;
  76638. /**
  76639. * Gets the active target at specified index. An active target is a target with an influence > 0
  76640. * @param index defines the index to check
  76641. * @returns the requested target
  76642. */
  76643. getActiveTarget(index: number): MorphTarget;
  76644. /**
  76645. * Gets the target at specified index
  76646. * @param index defines the index to check
  76647. * @returns the requested target
  76648. */
  76649. getTarget(index: number): MorphTarget;
  76650. /**
  76651. * Add a new target to this manager
  76652. * @param target defines the target to add
  76653. */
  76654. addTarget(target: MorphTarget): void;
  76655. /**
  76656. * Removes a target from the manager
  76657. * @param target defines the target to remove
  76658. */
  76659. removeTarget(target: MorphTarget): void;
  76660. /**
  76661. * Serializes the current manager into a Serialization object
  76662. * @returns the serialized object
  76663. */
  76664. serialize(): any;
  76665. private _syncActiveTargets;
  76666. /**
  76667. * Syncrhonize the targets with all the meshes using this morph target manager
  76668. */
  76669. synchronize(): void;
  76670. /**
  76671. * Creates a new MorphTargetManager from serialized data
  76672. * @param serializationObject defines the serialized data
  76673. * @param scene defines the hosting scene
  76674. * @returns the new MorphTargetManager
  76675. */
  76676. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76677. }
  76678. }
  76679. declare module BABYLON {
  76680. /**
  76681. * Mesh representing the gorund
  76682. */
  76683. export class GroundMesh extends Mesh {
  76684. /** If octree should be generated */
  76685. generateOctree: boolean;
  76686. private _heightQuads;
  76687. /** @hidden */
  76688. _subdivisionsX: number;
  76689. /** @hidden */
  76690. _subdivisionsY: number;
  76691. /** @hidden */
  76692. _width: number;
  76693. /** @hidden */
  76694. _height: number;
  76695. /** @hidden */
  76696. _minX: number;
  76697. /** @hidden */
  76698. _maxX: number;
  76699. /** @hidden */
  76700. _minZ: number;
  76701. /** @hidden */
  76702. _maxZ: number;
  76703. constructor(name: string, scene: Scene);
  76704. /**
  76705. * "GroundMesh"
  76706. * @returns "GroundMesh"
  76707. */
  76708. getClassName(): string;
  76709. /**
  76710. * The minimum of x and y subdivisions
  76711. */
  76712. readonly subdivisions: number;
  76713. /**
  76714. * X subdivisions
  76715. */
  76716. readonly subdivisionsX: number;
  76717. /**
  76718. * Y subdivisions
  76719. */
  76720. readonly subdivisionsY: number;
  76721. /**
  76722. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76723. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76724. * @param chunksCount the number of subdivisions for x and y
  76725. * @param octreeBlocksSize (Default: 32)
  76726. */
  76727. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76728. /**
  76729. * Returns a height (y) value in the Worl system :
  76730. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76731. * @param x x coordinate
  76732. * @param z z coordinate
  76733. * @returns the ground y position if (x, z) are outside the ground surface.
  76734. */
  76735. getHeightAtCoordinates(x: number, z: number): number;
  76736. /**
  76737. * Returns a normalized vector (Vector3) orthogonal to the ground
  76738. * at the ground coordinates (x, z) expressed in the World system.
  76739. * @param x x coordinate
  76740. * @param z z coordinate
  76741. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76742. */
  76743. getNormalAtCoordinates(x: number, z: number): Vector3;
  76744. /**
  76745. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76746. * at the ground coordinates (x, z) expressed in the World system.
  76747. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76748. * @param x x coordinate
  76749. * @param z z coordinate
  76750. * @param ref vector to store the result
  76751. * @returns the GroundMesh.
  76752. */
  76753. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76754. /**
  76755. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76756. * if the ground has been updated.
  76757. * This can be used in the render loop.
  76758. * @returns the GroundMesh.
  76759. */
  76760. updateCoordinateHeights(): GroundMesh;
  76761. private _getFacetAt;
  76762. private _initHeightQuads;
  76763. private _computeHeightQuads;
  76764. /**
  76765. * Serializes this ground mesh
  76766. * @param serializationObject object to write serialization to
  76767. */
  76768. serialize(serializationObject: any): void;
  76769. /**
  76770. * Parses a serialized ground mesh
  76771. * @param parsedMesh the serialized mesh
  76772. * @param scene the scene to create the ground mesh in
  76773. * @returns the created ground mesh
  76774. */
  76775. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76776. }
  76777. }
  76778. declare module BABYLON {
  76779. /**
  76780. * Interface for Physics-Joint data
  76781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76782. */
  76783. export interface PhysicsJointData {
  76784. /**
  76785. * The main pivot of the joint
  76786. */
  76787. mainPivot?: Vector3;
  76788. /**
  76789. * The connected pivot of the joint
  76790. */
  76791. connectedPivot?: Vector3;
  76792. /**
  76793. * The main axis of the joint
  76794. */
  76795. mainAxis?: Vector3;
  76796. /**
  76797. * The connected axis of the joint
  76798. */
  76799. connectedAxis?: Vector3;
  76800. /**
  76801. * The collision of the joint
  76802. */
  76803. collision?: boolean;
  76804. /**
  76805. * Native Oimo/Cannon/Energy data
  76806. */
  76807. nativeParams?: any;
  76808. }
  76809. /**
  76810. * This is a holder class for the physics joint created by the physics plugin
  76811. * It holds a set of functions to control the underlying joint
  76812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76813. */
  76814. export class PhysicsJoint {
  76815. /**
  76816. * The type of the physics joint
  76817. */
  76818. type: number;
  76819. /**
  76820. * The data for the physics joint
  76821. */
  76822. jointData: PhysicsJointData;
  76823. private _physicsJoint;
  76824. protected _physicsPlugin: IPhysicsEnginePlugin;
  76825. /**
  76826. * Initializes the physics joint
  76827. * @param type The type of the physics joint
  76828. * @param jointData The data for the physics joint
  76829. */
  76830. constructor(
  76831. /**
  76832. * The type of the physics joint
  76833. */
  76834. type: number,
  76835. /**
  76836. * The data for the physics joint
  76837. */
  76838. jointData: PhysicsJointData);
  76839. /**
  76840. * Gets the physics joint
  76841. */
  76842. /**
  76843. * Sets the physics joint
  76844. */
  76845. physicsJoint: any;
  76846. /**
  76847. * Sets the physics plugin
  76848. */
  76849. physicsPlugin: IPhysicsEnginePlugin;
  76850. /**
  76851. * Execute a function that is physics-plugin specific.
  76852. * @param {Function} func the function that will be executed.
  76853. * It accepts two parameters: the physics world and the physics joint
  76854. */
  76855. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76856. /**
  76857. * Distance-Joint type
  76858. */
  76859. static DistanceJoint: number;
  76860. /**
  76861. * Hinge-Joint type
  76862. */
  76863. static HingeJoint: number;
  76864. /**
  76865. * Ball-and-Socket joint type
  76866. */
  76867. static BallAndSocketJoint: number;
  76868. /**
  76869. * Wheel-Joint type
  76870. */
  76871. static WheelJoint: number;
  76872. /**
  76873. * Slider-Joint type
  76874. */
  76875. static SliderJoint: number;
  76876. /**
  76877. * Prismatic-Joint type
  76878. */
  76879. static PrismaticJoint: number;
  76880. /**
  76881. * Universal-Joint type
  76882. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76883. */
  76884. static UniversalJoint: number;
  76885. /**
  76886. * Hinge-Joint 2 type
  76887. */
  76888. static Hinge2Joint: number;
  76889. /**
  76890. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76891. */
  76892. static PointToPointJoint: number;
  76893. /**
  76894. * Spring-Joint type
  76895. */
  76896. static SpringJoint: number;
  76897. /**
  76898. * Lock-Joint type
  76899. */
  76900. static LockJoint: number;
  76901. }
  76902. /**
  76903. * A class representing a physics distance joint
  76904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76905. */
  76906. export class DistanceJoint extends PhysicsJoint {
  76907. /**
  76908. *
  76909. * @param jointData The data for the Distance-Joint
  76910. */
  76911. constructor(jointData: DistanceJointData);
  76912. /**
  76913. * Update the predefined distance.
  76914. * @param maxDistance The maximum preferred distance
  76915. * @param minDistance The minimum preferred distance
  76916. */
  76917. updateDistance(maxDistance: number, minDistance?: number): void;
  76918. }
  76919. /**
  76920. * Represents a Motor-Enabled Joint
  76921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76922. */
  76923. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76924. /**
  76925. * Initializes the Motor-Enabled Joint
  76926. * @param type The type of the joint
  76927. * @param jointData The physica joint data for the joint
  76928. */
  76929. constructor(type: number, jointData: PhysicsJointData);
  76930. /**
  76931. * Set the motor values.
  76932. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76933. * @param force the force to apply
  76934. * @param maxForce max force for this motor.
  76935. */
  76936. setMotor(force?: number, maxForce?: number): void;
  76937. /**
  76938. * Set the motor's limits.
  76939. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76940. * @param upperLimit The upper limit of the motor
  76941. * @param lowerLimit The lower limit of the motor
  76942. */
  76943. setLimit(upperLimit: number, lowerLimit?: number): void;
  76944. }
  76945. /**
  76946. * This class represents a single physics Hinge-Joint
  76947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76948. */
  76949. export class HingeJoint extends MotorEnabledJoint {
  76950. /**
  76951. * Initializes the Hinge-Joint
  76952. * @param jointData The joint data for the Hinge-Joint
  76953. */
  76954. constructor(jointData: PhysicsJointData);
  76955. /**
  76956. * Set the motor values.
  76957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76958. * @param {number} force the force to apply
  76959. * @param {number} maxForce max force for this motor.
  76960. */
  76961. setMotor(force?: number, maxForce?: number): void;
  76962. /**
  76963. * Set the motor's limits.
  76964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76965. * @param upperLimit The upper limit of the motor
  76966. * @param lowerLimit The lower limit of the motor
  76967. */
  76968. setLimit(upperLimit: number, lowerLimit?: number): void;
  76969. }
  76970. /**
  76971. * This class represents a dual hinge physics joint (same as wheel joint)
  76972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76973. */
  76974. export class Hinge2Joint extends MotorEnabledJoint {
  76975. /**
  76976. * Initializes the Hinge2-Joint
  76977. * @param jointData The joint data for the Hinge2-Joint
  76978. */
  76979. constructor(jointData: PhysicsJointData);
  76980. /**
  76981. * Set the motor values.
  76982. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76983. * @param {number} targetSpeed the speed the motor is to reach
  76984. * @param {number} maxForce max force for this motor.
  76985. * @param {motorIndex} the motor's index, 0 or 1.
  76986. */
  76987. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76988. /**
  76989. * Set the motor limits.
  76990. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76991. * @param {number} upperLimit the upper limit
  76992. * @param {number} lowerLimit lower limit
  76993. * @param {motorIndex} the motor's index, 0 or 1.
  76994. */
  76995. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76996. }
  76997. /**
  76998. * Interface for a motor enabled joint
  76999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77000. */
  77001. export interface IMotorEnabledJoint {
  77002. /**
  77003. * Physics joint
  77004. */
  77005. physicsJoint: any;
  77006. /**
  77007. * Sets the motor of the motor-enabled joint
  77008. * @param force The force of the motor
  77009. * @param maxForce The maximum force of the motor
  77010. * @param motorIndex The index of the motor
  77011. */
  77012. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77013. /**
  77014. * Sets the limit of the motor
  77015. * @param upperLimit The upper limit of the motor
  77016. * @param lowerLimit The lower limit of the motor
  77017. * @param motorIndex The index of the motor
  77018. */
  77019. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77020. }
  77021. /**
  77022. * Joint data for a Distance-Joint
  77023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77024. */
  77025. export interface DistanceJointData extends PhysicsJointData {
  77026. /**
  77027. * Max distance the 2 joint objects can be apart
  77028. */
  77029. maxDistance: number;
  77030. }
  77031. /**
  77032. * Joint data from a spring joint
  77033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77034. */
  77035. export interface SpringJointData extends PhysicsJointData {
  77036. /**
  77037. * Length of the spring
  77038. */
  77039. length: number;
  77040. /**
  77041. * Stiffness of the spring
  77042. */
  77043. stiffness: number;
  77044. /**
  77045. * Damping of the spring
  77046. */
  77047. damping: number;
  77048. /** this callback will be called when applying the force to the impostors. */
  77049. forceApplicationCallback: () => void;
  77050. }
  77051. }
  77052. declare module BABYLON {
  77053. /**
  77054. * Interface used to describe a physics joint
  77055. */
  77056. export interface PhysicsImpostorJoint {
  77057. /** Defines the main impostor to which the joint is linked */
  77058. mainImpostor: PhysicsImpostor;
  77059. /** Defines the impostor that is connected to the main impostor using this joint */
  77060. connectedImpostor: PhysicsImpostor;
  77061. /** Defines the joint itself */
  77062. joint: PhysicsJoint;
  77063. }
  77064. /** @hidden */
  77065. export interface IPhysicsEnginePlugin {
  77066. world: any;
  77067. name: string;
  77068. setGravity(gravity: Vector3): void;
  77069. setTimeStep(timeStep: number): void;
  77070. getTimeStep(): number;
  77071. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77072. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77073. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77074. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77075. removePhysicsBody(impostor: PhysicsImpostor): void;
  77076. generateJoint(joint: PhysicsImpostorJoint): void;
  77077. removeJoint(joint: PhysicsImpostorJoint): void;
  77078. isSupported(): boolean;
  77079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77080. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77081. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77082. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77083. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77084. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77085. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77086. getBodyMass(impostor: PhysicsImpostor): number;
  77087. getBodyFriction(impostor: PhysicsImpostor): number;
  77088. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77089. getBodyRestitution(impostor: PhysicsImpostor): number;
  77090. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77091. sleepBody(impostor: PhysicsImpostor): void;
  77092. wakeUpBody(impostor: PhysicsImpostor): void;
  77093. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  77094. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  77095. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77096. getRadius(impostor: PhysicsImpostor): number;
  77097. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  77098. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  77099. dispose(): void;
  77100. }
  77101. /**
  77102. * Interface used to define a physics engine
  77103. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  77104. */
  77105. export interface IPhysicsEngine {
  77106. /**
  77107. * Gets the gravity vector used by the simulation
  77108. */
  77109. gravity: Vector3;
  77110. /**
  77111. * Sets the gravity vector used by the simulation
  77112. * @param gravity defines the gravity vector to use
  77113. */
  77114. setGravity(gravity: Vector3): void;
  77115. /**
  77116. * Set the time step of the physics engine.
  77117. * Default is 1/60.
  77118. * To slow it down, enter 1/600 for example.
  77119. * To speed it up, 1/30
  77120. * @param newTimeStep the new timestep to apply to this world.
  77121. */
  77122. setTimeStep(newTimeStep: number): void;
  77123. /**
  77124. * Get the time step of the physics engine.
  77125. * @returns the current time step
  77126. */
  77127. getTimeStep(): number;
  77128. /**
  77129. * Release all resources
  77130. */
  77131. dispose(): void;
  77132. /**
  77133. * Gets the name of the current physics plugin
  77134. * @returns the name of the plugin
  77135. */
  77136. getPhysicsPluginName(): string;
  77137. /**
  77138. * Adding a new impostor for the impostor tracking.
  77139. * This will be done by the impostor itself.
  77140. * @param impostor the impostor to add
  77141. */
  77142. addImpostor(impostor: PhysicsImpostor): void;
  77143. /**
  77144. * Remove an impostor from the engine.
  77145. * This impostor and its mesh will not longer be updated by the physics engine.
  77146. * @param impostor the impostor to remove
  77147. */
  77148. removeImpostor(impostor: PhysicsImpostor): void;
  77149. /**
  77150. * Add a joint to the physics engine
  77151. * @param mainImpostor defines the main impostor to which the joint is added.
  77152. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  77153. * @param joint defines the joint that will connect both impostors.
  77154. */
  77155. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77156. /**
  77157. * Removes a joint from the simulation
  77158. * @param mainImpostor defines the impostor used with the joint
  77159. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  77160. * @param joint defines the joint to remove
  77161. */
  77162. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77163. /**
  77164. * Gets the current plugin used to run the simulation
  77165. * @returns current plugin
  77166. */
  77167. getPhysicsPlugin(): IPhysicsEnginePlugin;
  77168. /**
  77169. * Gets the list of physic impostors
  77170. * @returns an array of PhysicsImpostor
  77171. */
  77172. getImpostors(): Array<PhysicsImpostor>;
  77173. /**
  77174. * Gets the impostor for a physics enabled object
  77175. * @param object defines the object impersonated by the impostor
  77176. * @returns the PhysicsImpostor or null if not found
  77177. */
  77178. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77179. /**
  77180. * Gets the impostor for a physics body object
  77181. * @param body defines physics body used by the impostor
  77182. * @returns the PhysicsImpostor or null if not found
  77183. */
  77184. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  77185. /**
  77186. * Called by the scene. No need to call it.
  77187. * @param delta defines the timespam between frames
  77188. */
  77189. _step(delta: number): void;
  77190. }
  77191. }
  77192. declare module BABYLON {
  77193. /**
  77194. * The interface for the physics imposter parameters
  77195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77196. */
  77197. export interface PhysicsImpostorParameters {
  77198. /**
  77199. * The mass of the physics imposter
  77200. */
  77201. mass: number;
  77202. /**
  77203. * The friction of the physics imposter
  77204. */
  77205. friction?: number;
  77206. /**
  77207. * The coefficient of restitution of the physics imposter
  77208. */
  77209. restitution?: number;
  77210. /**
  77211. * The native options of the physics imposter
  77212. */
  77213. nativeOptions?: any;
  77214. /**
  77215. * Specifies if the parent should be ignored
  77216. */
  77217. ignoreParent?: boolean;
  77218. /**
  77219. * Specifies if bi-directional transformations should be disabled
  77220. */
  77221. disableBidirectionalTransformation?: boolean;
  77222. }
  77223. /**
  77224. * Interface for a physics-enabled object
  77225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77226. */
  77227. export interface IPhysicsEnabledObject {
  77228. /**
  77229. * The position of the physics-enabled object
  77230. */
  77231. position: Vector3;
  77232. /**
  77233. * The rotation of the physics-enabled object
  77234. */
  77235. rotationQuaternion: Nullable<Quaternion>;
  77236. /**
  77237. * The scale of the physics-enabled object
  77238. */
  77239. scaling: Vector3;
  77240. /**
  77241. * The rotation of the physics-enabled object
  77242. */
  77243. rotation?: Vector3;
  77244. /**
  77245. * The parent of the physics-enabled object
  77246. */
  77247. parent?: any;
  77248. /**
  77249. * The bounding info of the physics-enabled object
  77250. * @returns The bounding info of the physics-enabled object
  77251. */
  77252. getBoundingInfo(): BoundingInfo;
  77253. /**
  77254. * Computes the world matrix
  77255. * @param force Specifies if the world matrix should be computed by force
  77256. * @returns A world matrix
  77257. */
  77258. computeWorldMatrix(force: boolean): Matrix;
  77259. /**
  77260. * Gets the world matrix
  77261. * @returns A world matrix
  77262. */
  77263. getWorldMatrix?(): Matrix;
  77264. /**
  77265. * Gets the child meshes
  77266. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77267. * @returns An array of abstract meshes
  77268. */
  77269. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77270. /**
  77271. * Gets the vertex data
  77272. * @param kind The type of vertex data
  77273. * @returns A nullable array of numbers, or a float32 array
  77274. */
  77275. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77276. /**
  77277. * Gets the indices from the mesh
  77278. * @returns A nullable array of index arrays
  77279. */
  77280. getIndices?(): Nullable<IndicesArray>;
  77281. /**
  77282. * Gets the scene from the mesh
  77283. * @returns the indices array or null
  77284. */
  77285. getScene?(): Scene;
  77286. /**
  77287. * Gets the absolute position from the mesh
  77288. * @returns the absolute position
  77289. */
  77290. getAbsolutePosition(): Vector3;
  77291. /**
  77292. * Gets the absolute pivot point from the mesh
  77293. * @returns the absolute pivot point
  77294. */
  77295. getAbsolutePivotPoint(): Vector3;
  77296. /**
  77297. * Rotates the mesh
  77298. * @param axis The axis of rotation
  77299. * @param amount The amount of rotation
  77300. * @param space The space of the rotation
  77301. * @returns The rotation transform node
  77302. */
  77303. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77304. /**
  77305. * Translates the mesh
  77306. * @param axis The axis of translation
  77307. * @param distance The distance of translation
  77308. * @param space The space of the translation
  77309. * @returns The transform node
  77310. */
  77311. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77312. /**
  77313. * Sets the absolute position of the mesh
  77314. * @param absolutePosition The absolute position of the mesh
  77315. * @returns The transform node
  77316. */
  77317. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77318. /**
  77319. * Gets the class name of the mesh
  77320. * @returns The class name
  77321. */
  77322. getClassName(): string;
  77323. }
  77324. /**
  77325. * Represents a physics imposter
  77326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77327. */
  77328. export class PhysicsImpostor {
  77329. /**
  77330. * The physics-enabled object used as the physics imposter
  77331. */
  77332. object: IPhysicsEnabledObject;
  77333. /**
  77334. * The type of the physics imposter
  77335. */
  77336. type: number;
  77337. private _options;
  77338. private _scene?;
  77339. /**
  77340. * The default object size of the imposter
  77341. */
  77342. static DEFAULT_OBJECT_SIZE: Vector3;
  77343. /**
  77344. * The identity quaternion of the imposter
  77345. */
  77346. static IDENTITY_QUATERNION: Quaternion;
  77347. /** @hidden */
  77348. _pluginData: any;
  77349. private _physicsEngine;
  77350. private _physicsBody;
  77351. private _bodyUpdateRequired;
  77352. private _onBeforePhysicsStepCallbacks;
  77353. private _onAfterPhysicsStepCallbacks;
  77354. /** @hidden */
  77355. _onPhysicsCollideCallbacks: Array<{
  77356. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77357. otherImpostors: Array<PhysicsImpostor>;
  77358. }>;
  77359. private _deltaPosition;
  77360. private _deltaRotation;
  77361. private _deltaRotationConjugated;
  77362. private _parent;
  77363. private _isDisposed;
  77364. private static _tmpVecs;
  77365. private static _tmpQuat;
  77366. /**
  77367. * Specifies if the physics imposter is disposed
  77368. */
  77369. readonly isDisposed: boolean;
  77370. /**
  77371. * Gets the mass of the physics imposter
  77372. */
  77373. mass: number;
  77374. /**
  77375. * Gets the coefficient of friction
  77376. */
  77377. /**
  77378. * Sets the coefficient of friction
  77379. */
  77380. friction: number;
  77381. /**
  77382. * Gets the coefficient of restitution
  77383. */
  77384. /**
  77385. * Sets the coefficient of restitution
  77386. */
  77387. restitution: number;
  77388. /**
  77389. * The unique id of the physics imposter
  77390. * set by the physics engine when adding this impostor to the array
  77391. */
  77392. uniqueId: number;
  77393. private _joints;
  77394. /**
  77395. * Initializes the physics imposter
  77396. * @param object The physics-enabled object used as the physics imposter
  77397. * @param type The type of the physics imposter
  77398. * @param _options The options for the physics imposter
  77399. * @param _scene The Babylon scene
  77400. */
  77401. constructor(
  77402. /**
  77403. * The physics-enabled object used as the physics imposter
  77404. */
  77405. object: IPhysicsEnabledObject,
  77406. /**
  77407. * The type of the physics imposter
  77408. */
  77409. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77410. /**
  77411. * This function will completly initialize this impostor.
  77412. * It will create a new body - but only if this mesh has no parent.
  77413. * If it has, this impostor will not be used other than to define the impostor
  77414. * of the child mesh.
  77415. * @hidden
  77416. */
  77417. _init(): void;
  77418. private _getPhysicsParent;
  77419. /**
  77420. * Should a new body be generated.
  77421. * @returns boolean specifying if body initialization is required
  77422. */
  77423. isBodyInitRequired(): boolean;
  77424. /**
  77425. * Sets the updated scaling
  77426. * @param updated Specifies if the scaling is updated
  77427. */
  77428. setScalingUpdated(): void;
  77429. /**
  77430. * Force a regeneration of this or the parent's impostor's body.
  77431. * Use under cautious - This will remove all joints already implemented.
  77432. */
  77433. forceUpdate(): void;
  77434. /**
  77435. * Gets the body that holds this impostor. Either its own, or its parent.
  77436. */
  77437. /**
  77438. * Set the physics body. Used mainly by the physics engine/plugin
  77439. */
  77440. physicsBody: any;
  77441. /**
  77442. * Get the parent of the physics imposter
  77443. * @returns Physics imposter or null
  77444. */
  77445. /**
  77446. * Sets the parent of the physics imposter
  77447. */
  77448. parent: Nullable<PhysicsImpostor>;
  77449. /**
  77450. * Resets the update flags
  77451. */
  77452. resetUpdateFlags(): void;
  77453. /**
  77454. * Gets the object extend size
  77455. * @returns the object extend size
  77456. */
  77457. getObjectExtendSize(): Vector3;
  77458. /**
  77459. * Gets the object center
  77460. * @returns The object center
  77461. */
  77462. getObjectCenter(): Vector3;
  77463. /**
  77464. * Get a specific parametes from the options parameter
  77465. * @param paramName The object parameter name
  77466. * @returns The object parameter
  77467. */
  77468. getParam(paramName: string): any;
  77469. /**
  77470. * Sets a specific parameter in the options given to the physics plugin
  77471. * @param paramName The parameter name
  77472. * @param value The value of the parameter
  77473. */
  77474. setParam(paramName: string, value: number): void;
  77475. /**
  77476. * Specifically change the body's mass option. Won't recreate the physics body object
  77477. * @param mass The mass of the physics imposter
  77478. */
  77479. setMass(mass: number): void;
  77480. /**
  77481. * Gets the linear velocity
  77482. * @returns linear velocity or null
  77483. */
  77484. getLinearVelocity(): Nullable<Vector3>;
  77485. /**
  77486. * Sets the linear velocity
  77487. * @param velocity linear velocity or null
  77488. */
  77489. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77490. /**
  77491. * Gets the angular velocity
  77492. * @returns angular velocity or null
  77493. */
  77494. getAngularVelocity(): Nullable<Vector3>;
  77495. /**
  77496. * Sets the angular velocity
  77497. * @param velocity The velocity or null
  77498. */
  77499. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77500. /**
  77501. * Execute a function with the physics plugin native code
  77502. * Provide a function the will have two variables - the world object and the physics body object
  77503. * @param func The function to execute with the physics plugin native code
  77504. */
  77505. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77506. /**
  77507. * Register a function that will be executed before the physics world is stepping forward
  77508. * @param func The function to execute before the physics world is stepped forward
  77509. */
  77510. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77511. /**
  77512. * Unregister a function that will be executed before the physics world is stepping forward
  77513. * @param func The function to execute before the physics world is stepped forward
  77514. */
  77515. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77516. /**
  77517. * Register a function that will be executed after the physics step
  77518. * @param func The function to execute after physics step
  77519. */
  77520. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77521. /**
  77522. * Unregisters a function that will be executed after the physics step
  77523. * @param func The function to execute after physics step
  77524. */
  77525. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77526. /**
  77527. * register a function that will be executed when this impostor collides against a different body
  77528. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77529. * @param func Callback that is executed on collision
  77530. */
  77531. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77532. /**
  77533. * Unregisters the physics imposter on contact
  77534. * @param collideAgainst The physics object to collide against
  77535. * @param func Callback to execute on collision
  77536. */
  77537. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77538. private _tmpQuat;
  77539. private _tmpQuat2;
  77540. /**
  77541. * Get the parent rotation
  77542. * @returns The parent rotation
  77543. */
  77544. getParentsRotation(): Quaternion;
  77545. /**
  77546. * this function is executed by the physics engine.
  77547. */
  77548. beforeStep: () => void;
  77549. /**
  77550. * this function is executed by the physics engine
  77551. */
  77552. afterStep: () => void;
  77553. /**
  77554. * Legacy collision detection event support
  77555. */
  77556. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77557. /**
  77558. * event and body object due to cannon's event-based architecture.
  77559. */
  77560. onCollide: (e: {
  77561. body: any;
  77562. }) => void;
  77563. /**
  77564. * Apply a force
  77565. * @param force The force to apply
  77566. * @param contactPoint The contact point for the force
  77567. * @returns The physics imposter
  77568. */
  77569. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77570. /**
  77571. * Apply an impulse
  77572. * @param force The impulse force
  77573. * @param contactPoint The contact point for the impulse force
  77574. * @returns The physics imposter
  77575. */
  77576. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77577. /**
  77578. * A help function to create a joint
  77579. * @param otherImpostor A physics imposter used to create a joint
  77580. * @param jointType The type of joint
  77581. * @param jointData The data for the joint
  77582. * @returns The physics imposter
  77583. */
  77584. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77585. /**
  77586. * Add a joint to this impostor with a different impostor
  77587. * @param otherImpostor A physics imposter used to add a joint
  77588. * @param joint The joint to add
  77589. * @returns The physics imposter
  77590. */
  77591. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77592. /**
  77593. * Will keep this body still, in a sleep mode.
  77594. * @returns the physics imposter
  77595. */
  77596. sleep(): PhysicsImpostor;
  77597. /**
  77598. * Wake the body up.
  77599. * @returns The physics imposter
  77600. */
  77601. wakeUp(): PhysicsImpostor;
  77602. /**
  77603. * Clones the physics imposter
  77604. * @param newObject The physics imposter clones to this physics-enabled object
  77605. * @returns A nullable physics imposter
  77606. */
  77607. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77608. /**
  77609. * Disposes the physics imposter
  77610. */
  77611. dispose(): void;
  77612. /**
  77613. * Sets the delta position
  77614. * @param position The delta position amount
  77615. */
  77616. setDeltaPosition(position: Vector3): void;
  77617. /**
  77618. * Sets the delta rotation
  77619. * @param rotation The delta rotation amount
  77620. */
  77621. setDeltaRotation(rotation: Quaternion): void;
  77622. /**
  77623. * Gets the box size of the physics imposter and stores the result in the input parameter
  77624. * @param result Stores the box size
  77625. * @returns The physics imposter
  77626. */
  77627. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77628. /**
  77629. * Gets the radius of the physics imposter
  77630. * @returns Radius of the physics imposter
  77631. */
  77632. getRadius(): number;
  77633. /**
  77634. * Sync a bone with this impostor
  77635. * @param bone The bone to sync to the impostor.
  77636. * @param boneMesh The mesh that the bone is influencing.
  77637. * @param jointPivot The pivot of the joint / bone in local space.
  77638. * @param distToJoint Optional distance from the impostor to the joint.
  77639. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77640. */
  77641. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77642. /**
  77643. * Sync impostor to a bone
  77644. * @param bone The bone that the impostor will be synced to.
  77645. * @param boneMesh The mesh that the bone is influencing.
  77646. * @param jointPivot The pivot of the joint / bone in local space.
  77647. * @param distToJoint Optional distance from the impostor to the joint.
  77648. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77649. * @param boneAxis Optional vector3 axis the bone is aligned with
  77650. */
  77651. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77652. /**
  77653. * No-Imposter type
  77654. */
  77655. static NoImpostor: number;
  77656. /**
  77657. * Sphere-Imposter type
  77658. */
  77659. static SphereImpostor: number;
  77660. /**
  77661. * Box-Imposter type
  77662. */
  77663. static BoxImpostor: number;
  77664. /**
  77665. * Plane-Imposter type
  77666. */
  77667. static PlaneImpostor: number;
  77668. /**
  77669. * Mesh-imposter type
  77670. */
  77671. static MeshImpostor: number;
  77672. /**
  77673. * Cylinder-Imposter type
  77674. */
  77675. static CylinderImpostor: number;
  77676. /**
  77677. * Particle-Imposter type
  77678. */
  77679. static ParticleImpostor: number;
  77680. /**
  77681. * Heightmap-Imposter type
  77682. */
  77683. static HeightmapImpostor: number;
  77684. }
  77685. }
  77686. declare module BABYLON {
  77687. /**
  77688. * Class used to represent a specific level of detail of a mesh
  77689. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77690. */
  77691. export class MeshLODLevel {
  77692. /** Defines the distance where this level should star being displayed */
  77693. distance: number;
  77694. /** Defines the mesh to use to render this level */
  77695. mesh: Nullable<Mesh>;
  77696. /**
  77697. * Creates a new LOD level
  77698. * @param distance defines the distance where this level should star being displayed
  77699. * @param mesh defines the mesh to use to render this level
  77700. */
  77701. constructor(
  77702. /** Defines the distance where this level should star being displayed */
  77703. distance: number,
  77704. /** Defines the mesh to use to render this level */
  77705. mesh: Nullable<Mesh>);
  77706. }
  77707. /**
  77708. * @hidden
  77709. **/
  77710. export class _CreationDataStorage {
  77711. closePath?: boolean;
  77712. closeArray?: boolean;
  77713. idx: number[];
  77714. dashSize: number;
  77715. gapSize: number;
  77716. path3D: Path3D;
  77717. pathArray: Vector3[][];
  77718. arc: number;
  77719. radius: number;
  77720. cap: number;
  77721. tessellation: number;
  77722. }
  77723. /**
  77724. * @hidden
  77725. **/
  77726. class _InstanceDataStorage {
  77727. visibleInstances: any;
  77728. renderIdForInstances: number[];
  77729. batchCache: _InstancesBatch;
  77730. instancesBufferSize: number;
  77731. instancesBuffer: Nullable<Buffer>;
  77732. instancesData: Float32Array;
  77733. overridenInstanceCount: number;
  77734. }
  77735. /**
  77736. * @hidden
  77737. **/
  77738. export class _InstancesBatch {
  77739. mustReturn: boolean;
  77740. visibleInstances: Nullable<InstancedMesh[]>[];
  77741. renderSelf: boolean[];
  77742. }
  77743. /**
  77744. * Class used to represent renderable models
  77745. */
  77746. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77747. /**
  77748. * Mesh side orientation : usually the external or front surface
  77749. */
  77750. static readonly FRONTSIDE: number;
  77751. /**
  77752. * Mesh side orientation : usually the internal or back surface
  77753. */
  77754. static readonly BACKSIDE: number;
  77755. /**
  77756. * Mesh side orientation : both internal and external or front and back surfaces
  77757. */
  77758. static readonly DOUBLESIDE: number;
  77759. /**
  77760. * Mesh side orientation : by default, `FRONTSIDE`
  77761. */
  77762. static readonly DEFAULTSIDE: number;
  77763. /**
  77764. * Mesh cap setting : no cap
  77765. */
  77766. static readonly NO_CAP: number;
  77767. /**
  77768. * Mesh cap setting : one cap at the beginning of the mesh
  77769. */
  77770. static readonly CAP_START: number;
  77771. /**
  77772. * Mesh cap setting : one cap at the end of the mesh
  77773. */
  77774. static readonly CAP_END: number;
  77775. /**
  77776. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77777. */
  77778. static readonly CAP_ALL: number;
  77779. /**
  77780. * Gets the default side orientation.
  77781. * @param orientation the orientation to value to attempt to get
  77782. * @returns the default orientation
  77783. * @hidden
  77784. */
  77785. static _GetDefaultSideOrientation(orientation?: number): number;
  77786. private _onBeforeRenderObservable;
  77787. private _onBeforeBindObservable;
  77788. private _onAfterRenderObservable;
  77789. private _onBeforeDrawObservable;
  77790. /**
  77791. * An event triggered before rendering the mesh
  77792. */
  77793. readonly onBeforeRenderObservable: Observable<Mesh>;
  77794. /**
  77795. * An event triggered before binding the mesh
  77796. */
  77797. readonly onBeforeBindObservable: Observable<Mesh>;
  77798. /**
  77799. * An event triggered after rendering the mesh
  77800. */
  77801. readonly onAfterRenderObservable: Observable<Mesh>;
  77802. /**
  77803. * An event triggered before drawing the mesh
  77804. */
  77805. readonly onBeforeDrawObservable: Observable<Mesh>;
  77806. private _onBeforeDrawObserver;
  77807. /**
  77808. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77809. */
  77810. onBeforeDraw: () => void;
  77811. /**
  77812. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77813. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77814. */
  77815. delayLoadState: number;
  77816. /**
  77817. * Gets the list of instances created from this mesh
  77818. * it is not supposed to be modified manually.
  77819. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77820. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77821. */
  77822. instances: InstancedMesh[];
  77823. /**
  77824. * Gets the file containing delay loading data for this mesh
  77825. */
  77826. delayLoadingFile: string;
  77827. /** @hidden */
  77828. _binaryInfo: any;
  77829. private _LODLevels;
  77830. /**
  77831. * User defined function used to change how LOD level selection is done
  77832. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77833. */
  77834. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77835. private _morphTargetManager;
  77836. /**
  77837. * Gets or sets the morph target manager
  77838. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77839. */
  77840. morphTargetManager: Nullable<MorphTargetManager>;
  77841. /** @hidden */
  77842. _creationDataStorage: Nullable<_CreationDataStorage>;
  77843. /** @hidden */
  77844. _geometry: Nullable<Geometry>;
  77845. /** @hidden */
  77846. _delayInfo: Array<string>;
  77847. /** @hidden */
  77848. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77849. /** @hidden */
  77850. _instanceDataStorage: _InstanceDataStorage;
  77851. private _effectiveMaterial;
  77852. /** @hidden */
  77853. _shouldGenerateFlatShading: boolean;
  77854. private _preActivateId;
  77855. /** @hidden */
  77856. _originalBuilderSideOrientation: number;
  77857. /**
  77858. * Use this property to change the original side orientation defined at construction time
  77859. */
  77860. overrideMaterialSideOrientation: Nullable<number>;
  77861. private _areNormalsFrozen;
  77862. private _sourcePositions;
  77863. private _sourceNormals;
  77864. private _source;
  77865. private meshMap;
  77866. /**
  77867. * Gets the source mesh (the one used to clone this one from)
  77868. */
  77869. readonly source: Nullable<Mesh>;
  77870. /**
  77871. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77872. */
  77873. isUnIndexed: boolean;
  77874. /**
  77875. * @constructor
  77876. * @param name The value used by scene.getMeshByName() to do a lookup.
  77877. * @param scene The scene to add this mesh to.
  77878. * @param parent The parent of this mesh, if it has one
  77879. * @param source An optional Mesh from which geometry is shared, cloned.
  77880. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77881. * When false, achieved by calling a clone(), also passing False.
  77882. * This will make creation of children, recursive.
  77883. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77884. */
  77885. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77886. /**
  77887. * Gets the class name
  77888. * @returns the string "Mesh".
  77889. */
  77890. getClassName(): string;
  77891. /** @hidden */
  77892. readonly _isMesh: boolean;
  77893. /**
  77894. * Returns a description of this mesh
  77895. * @param fullDetails define if full details about this mesh must be used
  77896. * @returns a descriptive string representing this mesh
  77897. */
  77898. toString(fullDetails?: boolean): string;
  77899. /** @hidden */
  77900. _unBindEffect(): void;
  77901. /**
  77902. * Gets a boolean indicating if this mesh has LOD
  77903. */
  77904. readonly hasLODLevels: boolean;
  77905. /**
  77906. * Gets the list of MeshLODLevel associated with the current mesh
  77907. * @returns an array of MeshLODLevel
  77908. */
  77909. getLODLevels(): MeshLODLevel[];
  77910. private _sortLODLevels;
  77911. /**
  77912. * Add a mesh as LOD level triggered at the given distance.
  77913. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77914. * @param distance The distance from the center of the object to show this level
  77915. * @param mesh The mesh to be added as LOD level (can be null)
  77916. * @return This mesh (for chaining)
  77917. */
  77918. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77919. /**
  77920. * Returns the LOD level mesh at the passed distance or null if not found.
  77921. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77922. * @param distance The distance from the center of the object to show this level
  77923. * @returns a Mesh or `null`
  77924. */
  77925. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77926. /**
  77927. * Remove a mesh from the LOD array
  77928. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77929. * @param mesh defines the mesh to be removed
  77930. * @return This mesh (for chaining)
  77931. */
  77932. removeLODLevel(mesh: Mesh): Mesh;
  77933. /**
  77934. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77935. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77936. * @param camera defines the camera to use to compute distance
  77937. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77938. * @return This mesh (for chaining)
  77939. */
  77940. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77941. /**
  77942. * Gets the mesh internal Geometry object
  77943. */
  77944. readonly geometry: Nullable<Geometry>;
  77945. /**
  77946. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77947. * @returns the total number of vertices
  77948. */
  77949. getTotalVertices(): number;
  77950. /**
  77951. * Returns the content of an associated vertex buffer
  77952. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77953. * - VertexBuffer.PositionKind
  77954. * - VertexBuffer.UVKind
  77955. * - VertexBuffer.UV2Kind
  77956. * - VertexBuffer.UV3Kind
  77957. * - VertexBuffer.UV4Kind
  77958. * - VertexBuffer.UV5Kind
  77959. * - VertexBuffer.UV6Kind
  77960. * - VertexBuffer.ColorKind
  77961. * - VertexBuffer.MatricesIndicesKind
  77962. * - VertexBuffer.MatricesIndicesExtraKind
  77963. * - VertexBuffer.MatricesWeightsKind
  77964. * - VertexBuffer.MatricesWeightsExtraKind
  77965. * @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
  77966. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77967. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77968. */
  77969. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77970. /**
  77971. * Returns the mesh VertexBuffer object from the requested `kind`
  77972. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77973. * - VertexBuffer.PositionKind
  77974. * - VertexBuffer.UVKind
  77975. * - VertexBuffer.UV2Kind
  77976. * - VertexBuffer.UV3Kind
  77977. * - VertexBuffer.UV4Kind
  77978. * - VertexBuffer.UV5Kind
  77979. * - VertexBuffer.UV6Kind
  77980. * - VertexBuffer.ColorKind
  77981. * - VertexBuffer.MatricesIndicesKind
  77982. * - VertexBuffer.MatricesIndicesExtraKind
  77983. * - VertexBuffer.MatricesWeightsKind
  77984. * - VertexBuffer.MatricesWeightsExtraKind
  77985. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77986. */
  77987. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77988. /**
  77989. * Tests if a specific vertex buffer is associated with this mesh
  77990. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77991. * - VertexBuffer.PositionKind
  77992. * - VertexBuffer.UVKind
  77993. * - VertexBuffer.UV2Kind
  77994. * - VertexBuffer.UV3Kind
  77995. * - VertexBuffer.UV4Kind
  77996. * - VertexBuffer.UV5Kind
  77997. * - VertexBuffer.UV6Kind
  77998. * - VertexBuffer.ColorKind
  77999. * - VertexBuffer.MatricesIndicesKind
  78000. * - VertexBuffer.MatricesIndicesExtraKind
  78001. * - VertexBuffer.MatricesWeightsKind
  78002. * - VertexBuffer.MatricesWeightsExtraKind
  78003. * @returns a boolean
  78004. */
  78005. isVerticesDataPresent(kind: string): boolean;
  78006. /**
  78007. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  78008. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78009. * - VertexBuffer.PositionKind
  78010. * - VertexBuffer.UVKind
  78011. * - VertexBuffer.UV2Kind
  78012. * - VertexBuffer.UV3Kind
  78013. * - VertexBuffer.UV4Kind
  78014. * - VertexBuffer.UV5Kind
  78015. * - VertexBuffer.UV6Kind
  78016. * - VertexBuffer.ColorKind
  78017. * - VertexBuffer.MatricesIndicesKind
  78018. * - VertexBuffer.MatricesIndicesExtraKind
  78019. * - VertexBuffer.MatricesWeightsKind
  78020. * - VertexBuffer.MatricesWeightsExtraKind
  78021. * @returns a boolean
  78022. */
  78023. isVertexBufferUpdatable(kind: string): boolean;
  78024. /**
  78025. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  78026. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78027. * - VertexBuffer.PositionKind
  78028. * - VertexBuffer.UVKind
  78029. * - VertexBuffer.UV2Kind
  78030. * - VertexBuffer.UV3Kind
  78031. * - VertexBuffer.UV4Kind
  78032. * - VertexBuffer.UV5Kind
  78033. * - VertexBuffer.UV6Kind
  78034. * - VertexBuffer.ColorKind
  78035. * - VertexBuffer.MatricesIndicesKind
  78036. * - VertexBuffer.MatricesIndicesExtraKind
  78037. * - VertexBuffer.MatricesWeightsKind
  78038. * - VertexBuffer.MatricesWeightsExtraKind
  78039. * @returns an array of strings
  78040. */
  78041. getVerticesDataKinds(): string[];
  78042. /**
  78043. * Returns a positive integer : the total number of indices in this mesh geometry.
  78044. * @returns the numner of indices or zero if the mesh has no geometry.
  78045. */
  78046. getTotalIndices(): number;
  78047. /**
  78048. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78049. * @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.
  78050. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78051. * @returns the indices array or an empty array if the mesh has no geometry
  78052. */
  78053. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78054. readonly isBlocked: boolean;
  78055. /**
  78056. * Determine if the current mesh is ready to be rendered
  78057. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78058. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  78059. * @returns true if all associated assets are ready (material, textures, shaders)
  78060. */
  78061. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  78062. /**
  78063. * 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.
  78064. */
  78065. readonly areNormalsFrozen: boolean;
  78066. /**
  78067. * 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.
  78068. * @returns the current mesh
  78069. */
  78070. freezeNormals(): Mesh;
  78071. /**
  78072. * 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
  78073. * @returns the current mesh
  78074. */
  78075. unfreezeNormals(): Mesh;
  78076. /**
  78077. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  78078. */
  78079. overridenInstanceCount: number;
  78080. /** @hidden */
  78081. _preActivate(): Mesh;
  78082. /** @hidden */
  78083. _preActivateForIntermediateRendering(renderId: number): Mesh;
  78084. /** @hidden */
  78085. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  78086. /**
  78087. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  78088. * This means the mesh underlying bounding box and sphere are recomputed.
  78089. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  78090. * @returns the current mesh
  78091. */
  78092. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  78093. /** @hidden */
  78094. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  78095. /**
  78096. * This function will subdivide the mesh into multiple submeshes
  78097. * @param count defines the expected number of submeshes
  78098. */
  78099. subdivide(count: number): void;
  78100. /**
  78101. * Copy a FloatArray into a specific associated vertex buffer
  78102. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78103. * - VertexBuffer.PositionKind
  78104. * - VertexBuffer.UVKind
  78105. * - VertexBuffer.UV2Kind
  78106. * - VertexBuffer.UV3Kind
  78107. * - VertexBuffer.UV4Kind
  78108. * - VertexBuffer.UV5Kind
  78109. * - VertexBuffer.UV6Kind
  78110. * - VertexBuffer.ColorKind
  78111. * - VertexBuffer.MatricesIndicesKind
  78112. * - VertexBuffer.MatricesIndicesExtraKind
  78113. * - VertexBuffer.MatricesWeightsKind
  78114. * - VertexBuffer.MatricesWeightsExtraKind
  78115. * @param data defines the data source
  78116. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78117. * @param stride defines the data stride size (can be null)
  78118. * @returns the current mesh
  78119. */
  78120. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  78121. /**
  78122. * Flags an associated vertex buffer as updatable
  78123. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  78124. * - VertexBuffer.PositionKind
  78125. * - VertexBuffer.UVKind
  78126. * - VertexBuffer.UV2Kind
  78127. * - VertexBuffer.UV3Kind
  78128. * - VertexBuffer.UV4Kind
  78129. * - VertexBuffer.UV5Kind
  78130. * - VertexBuffer.UV6Kind
  78131. * - VertexBuffer.ColorKind
  78132. * - VertexBuffer.MatricesIndicesKind
  78133. * - VertexBuffer.MatricesIndicesExtraKind
  78134. * - VertexBuffer.MatricesWeightsKind
  78135. * - VertexBuffer.MatricesWeightsExtraKind
  78136. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78137. */
  78138. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  78139. /**
  78140. * Sets the mesh global Vertex Buffer
  78141. * @param buffer defines the buffer to use
  78142. * @returns the current mesh
  78143. */
  78144. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  78145. /**
  78146. * Update a specific associated vertex buffer
  78147. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78148. * - VertexBuffer.PositionKind
  78149. * - VertexBuffer.UVKind
  78150. * - VertexBuffer.UV2Kind
  78151. * - VertexBuffer.UV3Kind
  78152. * - VertexBuffer.UV4Kind
  78153. * - VertexBuffer.UV5Kind
  78154. * - VertexBuffer.UV6Kind
  78155. * - VertexBuffer.ColorKind
  78156. * - VertexBuffer.MatricesIndicesKind
  78157. * - VertexBuffer.MatricesIndicesExtraKind
  78158. * - VertexBuffer.MatricesWeightsKind
  78159. * - VertexBuffer.MatricesWeightsExtraKind
  78160. * @param data defines the data source
  78161. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78162. * @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)
  78163. * @returns the current mesh
  78164. */
  78165. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  78166. /**
  78167. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  78168. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  78169. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  78170. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  78171. * @returns the current mesh
  78172. */
  78173. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  78174. /**
  78175. * Creates a un-shared specific occurence of the geometry for the mesh.
  78176. * @returns the current mesh
  78177. */
  78178. makeGeometryUnique(): Mesh;
  78179. /**
  78180. * Set the index buffer of this mesh
  78181. * @param indices defines the source data
  78182. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  78183. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  78184. * @returns the current mesh
  78185. */
  78186. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  78187. /**
  78188. * Update the current index buffer
  78189. * @param indices defines the source data
  78190. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  78191. * @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)
  78192. * @returns the current mesh
  78193. */
  78194. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  78195. /**
  78196. * Invert the geometry to move from a right handed system to a left handed one.
  78197. * @returns the current mesh
  78198. */
  78199. toLeftHanded(): Mesh;
  78200. /** @hidden */
  78201. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  78202. /** @hidden */
  78203. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  78204. /**
  78205. * Registers for this mesh a javascript function called just before the rendering process
  78206. * @param func defines the function to call before rendering this mesh
  78207. * @returns the current mesh
  78208. */
  78209. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78210. /**
  78211. * Disposes a previously registered javascript function called before the rendering
  78212. * @param func defines the function to remove
  78213. * @returns the current mesh
  78214. */
  78215. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78216. /**
  78217. * Registers for this mesh a javascript function called just after the rendering is complete
  78218. * @param func defines the function to call after rendering this mesh
  78219. * @returns the current mesh
  78220. */
  78221. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78222. /**
  78223. * Disposes a previously registered javascript function called after the rendering.
  78224. * @param func defines the function to remove
  78225. * @returns the current mesh
  78226. */
  78227. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78228. /** @hidden */
  78229. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78230. /** @hidden */
  78231. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78232. /** @hidden */
  78233. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78234. /**
  78235. * 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
  78236. * @param subMesh defines the subMesh to render
  78237. * @param enableAlphaMode defines if alpha mode can be changed
  78238. * @returns the current mesh
  78239. */
  78240. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78241. private _onBeforeDraw;
  78242. /**
  78243. * Renormalize the mesh and patch it up if there are no weights
  78244. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78245. * However in the case of zero weights then we set just a single influence to 1.
  78246. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78247. */
  78248. cleanMatrixWeights(): void;
  78249. private normalizeSkinFourWeights;
  78250. private normalizeSkinWeightsAndExtra;
  78251. /**
  78252. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78253. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78254. * the user know there was an issue with importing the mesh
  78255. * @returns a validation object with skinned, valid and report string
  78256. */
  78257. validateSkinning(): {
  78258. skinned: boolean;
  78259. valid: boolean;
  78260. report: string;
  78261. };
  78262. /** @hidden */
  78263. _checkDelayState(): Mesh;
  78264. private _queueLoad;
  78265. /**
  78266. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78267. * A mesh is in the frustum if its bounding box intersects the frustum
  78268. * @param frustumPlanes defines the frustum to test
  78269. * @returns true if the mesh is in the frustum planes
  78270. */
  78271. isInFrustum(frustumPlanes: Plane[]): boolean;
  78272. /**
  78273. * Sets the mesh material by the material or multiMaterial `id` property
  78274. * @param id is a string identifying the material or the multiMaterial
  78275. * @returns the current mesh
  78276. */
  78277. setMaterialByID(id: string): Mesh;
  78278. /**
  78279. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78280. * @returns an array of IAnimatable
  78281. */
  78282. getAnimatables(): IAnimatable[];
  78283. /**
  78284. * Modifies the mesh geometry according to the passed transformation matrix.
  78285. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78286. * The mesh normals are modified using the same transformation.
  78287. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78288. * @param transform defines the transform matrix to use
  78289. * @see http://doc.babylonjs.com/resources/baking_transformations
  78290. * @returns the current mesh
  78291. */
  78292. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78293. /**
  78294. * Modifies the mesh geometry according to its own current World Matrix.
  78295. * The mesh World Matrix is then reset.
  78296. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78297. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78298. * @see http://doc.babylonjs.com/resources/baking_transformations
  78299. * @returns the current mesh
  78300. */
  78301. bakeCurrentTransformIntoVertices(): Mesh;
  78302. /** @hidden */
  78303. readonly _positions: Nullable<Vector3[]>;
  78304. /** @hidden */
  78305. _resetPointsArrayCache(): Mesh;
  78306. /** @hidden */
  78307. _generatePointsArray(): boolean;
  78308. /**
  78309. * Returns a new Mesh object generated from the current mesh properties.
  78310. * This method must not get confused with createInstance()
  78311. * @param name is a string, the name given to the new mesh
  78312. * @param newParent can be any Node object (default `null`)
  78313. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78314. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78315. * @returns a new mesh
  78316. */
  78317. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78318. /**
  78319. * Releases resources associated with this mesh.
  78320. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78321. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78322. */
  78323. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78324. /**
  78325. * Modifies the mesh geometry according to a displacement map.
  78326. * 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.
  78327. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78328. * @param url is a string, the URL from the image file is to be downloaded.
  78329. * @param minHeight is the lower limit of the displacement.
  78330. * @param maxHeight is the upper limit of the displacement.
  78331. * @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.
  78332. * @param uvOffset is an optional vector2 used to offset UV.
  78333. * @param uvScale is an optional vector2 used to scale UV.
  78334. * @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.
  78335. * @returns the Mesh.
  78336. */
  78337. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78338. /**
  78339. * Modifies the mesh geometry according to a displacementMap buffer.
  78340. * 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.
  78341. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78342. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78343. * @param heightMapWidth is the width of the buffer image.
  78344. * @param heightMapHeight is the height of the buffer image.
  78345. * @param minHeight is the lower limit of the displacement.
  78346. * @param maxHeight is the upper limit of the displacement.
  78347. * @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.
  78348. * @param uvOffset is an optional vector2 used to offset UV.
  78349. * @param uvScale is an optional vector2 used to scale UV.
  78350. * @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.
  78351. * @returns the Mesh.
  78352. */
  78353. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78354. /**
  78355. * Modify the mesh to get a flat shading rendering.
  78356. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78357. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78358. * @returns current mesh
  78359. */
  78360. convertToFlatShadedMesh(): Mesh;
  78361. /**
  78362. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78363. * In other words, more vertices, no more indices and a single bigger VBO.
  78364. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78365. * @returns current mesh
  78366. */
  78367. convertToUnIndexedMesh(): Mesh;
  78368. /**
  78369. * Inverses facet orientations.
  78370. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78371. * @param flipNormals will also inverts the normals
  78372. * @returns current mesh
  78373. */
  78374. flipFaces(flipNormals?: boolean): Mesh;
  78375. /** @hidden */
  78376. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78377. /** @hidden */
  78378. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78379. /**
  78380. * Creates a new InstancedMesh object from the mesh model.
  78381. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78382. * @param name defines the name of the new instance
  78383. * @returns a new InstancedMesh
  78384. */
  78385. createInstance(name: string): InstancedMesh;
  78386. /**
  78387. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78388. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78389. * @returns the current mesh
  78390. */
  78391. synchronizeInstances(): Mesh;
  78392. /**
  78393. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78394. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78395. * This should be used together with the simplification to avoid disappearing triangles.
  78396. * @param successCallback an optional success callback to be called after the optimization finished.
  78397. * @returns the current mesh
  78398. */
  78399. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78400. /**
  78401. * Serialize current mesh
  78402. * @param serializationObject defines the object which will receive the serialization data
  78403. */
  78404. serialize(serializationObject: any): void;
  78405. /** @hidden */
  78406. _syncGeometryWithMorphTargetManager(): void;
  78407. /** @hidden */
  78408. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78409. /**
  78410. * Returns a new Mesh object parsed from the source provided.
  78411. * @param parsedMesh is the source
  78412. * @param scene defines the hosting scene
  78413. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78414. * @returns a new Mesh
  78415. */
  78416. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78417. /**
  78418. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78419. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78420. * @param name defines the name of the mesh to create
  78421. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78422. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78423. * @param closePath creates a seam between the first and the last points of each path of the path array
  78424. * @param offset is taken in account only if the `pathArray` is containing a single path
  78425. * @param scene defines the hosting scene
  78426. * @param updatable defines if the mesh must be flagged as updatable
  78427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78428. * @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)
  78429. * @returns a new Mesh
  78430. */
  78431. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78432. /**
  78433. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78434. * @param name defines the name of the mesh to create
  78435. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78436. * @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
  78437. * @param scene defines the hosting scene
  78438. * @param updatable defines if the mesh must be flagged as updatable
  78439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78440. * @returns a new Mesh
  78441. */
  78442. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78443. /**
  78444. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78445. * @param name defines the name of the mesh to create
  78446. * @param size sets the size (float) of each box side (default 1)
  78447. * @param scene defines the hosting scene
  78448. * @param updatable defines if the mesh must be flagged as updatable
  78449. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78450. * @returns a new Mesh
  78451. */
  78452. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78453. /**
  78454. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78455. * @param name defines the name of the mesh to create
  78456. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78457. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78458. * @param scene defines the hosting scene
  78459. * @param updatable defines if the mesh must be flagged as updatable
  78460. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78461. * @returns a new Mesh
  78462. */
  78463. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78464. /**
  78465. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78466. * @param name defines the name of the mesh to create
  78467. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78468. * @param diameterTop set the top cap diameter (floats, default 1)
  78469. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78470. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78471. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78472. * @param scene defines the hosting scene
  78473. * @param updatable defines if the mesh must be flagged as updatable
  78474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78475. * @returns a new Mesh
  78476. */
  78477. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78478. /**
  78479. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78480. * @param name defines the name of the mesh to create
  78481. * @param diameter sets the diameter size (float) of the torus (default 1)
  78482. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78483. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78484. * @param scene defines the hosting scene
  78485. * @param updatable defines if the mesh must be flagged as updatable
  78486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78487. * @returns a new Mesh
  78488. */
  78489. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78490. /**
  78491. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78492. * @param name defines the name of the mesh to create
  78493. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78494. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78495. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78496. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78497. * @param p the number of windings on X axis (positive integers, default 2)
  78498. * @param q the number of windings on Y axis (positive integers, default 3)
  78499. * @param scene defines the hosting scene
  78500. * @param updatable defines if the mesh must be flagged as updatable
  78501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78502. * @returns a new Mesh
  78503. */
  78504. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78505. /**
  78506. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78507. * @param name defines the name of the mesh to create
  78508. * @param points is an array successive Vector3
  78509. * @param scene defines the hosting scene
  78510. * @param updatable defines if the mesh must be flagged as updatable
  78511. * @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).
  78512. * @returns a new Mesh
  78513. */
  78514. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78515. /**
  78516. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78517. * @param name defines the name of the mesh to create
  78518. * @param points is an array successive Vector3
  78519. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78520. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78521. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78522. * @param scene defines the hosting scene
  78523. * @param updatable defines if the mesh must be flagged as updatable
  78524. * @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)
  78525. * @returns a new Mesh
  78526. */
  78527. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78528. /**
  78529. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78530. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78531. * 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.
  78532. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78533. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78534. * Remember you can only change the shape positions, not their number when updating a polygon.
  78535. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78536. * @param name defines the name of the mesh to create
  78537. * @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
  78538. * @param scene defines the hosting scene
  78539. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78540. * @param updatable defines if the mesh must be flagged as updatable
  78541. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78542. * @param earcutInjection can be used to inject your own earcut reference
  78543. * @returns a new Mesh
  78544. */
  78545. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78546. /**
  78547. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78548. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78549. * @param name defines the name of the mesh to create
  78550. * @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
  78551. * @param depth defines the height of extrusion
  78552. * @param scene defines the hosting scene
  78553. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78554. * @param updatable defines if the mesh must be flagged as updatable
  78555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78556. * @param earcutInjection can be used to inject your own earcut reference
  78557. * @returns a new Mesh
  78558. */
  78559. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78560. /**
  78561. * Creates an extruded shape mesh.
  78562. * 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
  78563. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78564. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78565. * @param name defines the name of the mesh to create
  78566. * @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
  78567. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78568. * @param scale is the value to scale the shape
  78569. * @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
  78570. * @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
  78571. * @param scene defines the hosting scene
  78572. * @param updatable defines if the mesh must be flagged as updatable
  78573. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78574. * @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)
  78575. * @returns a new Mesh
  78576. */
  78577. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78578. /**
  78579. * Creates an custom extruded shape mesh.
  78580. * The custom extrusion is a parametric shape.
  78581. * It has no predefined shape. Its final shape will depend on the input parameters.
  78582. * Please consider using the same method from the MeshBuilder class instead
  78583. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78584. * @param name defines the name of the mesh to create
  78585. * @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
  78586. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78587. * @param scaleFunction is a custom Javascript function called on each path point
  78588. * @param rotationFunction is a custom Javascript function called on each path point
  78589. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78590. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78591. * @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
  78592. * @param scene defines the hosting scene
  78593. * @param updatable defines if the mesh must be flagged as updatable
  78594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78595. * @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)
  78596. * @returns a new Mesh
  78597. */
  78598. 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;
  78599. /**
  78600. * Creates lathe mesh.
  78601. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78602. * Please consider using the same method from the MeshBuilder class instead
  78603. * @param name defines the name of the mesh to create
  78604. * @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
  78605. * @param radius is the radius value of the lathe
  78606. * @param tessellation is the side number of the lathe.
  78607. * @param scene defines the hosting scene
  78608. * @param updatable defines if the mesh must be flagged as updatable
  78609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78610. * @returns a new Mesh
  78611. */
  78612. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78613. /**
  78614. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78615. * @param name defines the name of the mesh to create
  78616. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78617. * @param scene defines the hosting scene
  78618. * @param updatable defines if the mesh must be flagged as updatable
  78619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78620. * @returns a new Mesh
  78621. */
  78622. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78623. /**
  78624. * Creates a ground mesh.
  78625. * Please consider using the same method from the MeshBuilder class instead
  78626. * @param name defines the name of the mesh to create
  78627. * @param width set the width of the ground
  78628. * @param height set the height of the ground
  78629. * @param subdivisions sets the number of subdivisions per side
  78630. * @param scene defines the hosting scene
  78631. * @param updatable defines if the mesh must be flagged as updatable
  78632. * @returns a new Mesh
  78633. */
  78634. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78635. /**
  78636. * Creates a tiled ground mesh.
  78637. * Please consider using the same method from the MeshBuilder class instead
  78638. * @param name defines the name of the mesh to create
  78639. * @param xmin set the ground minimum X coordinate
  78640. * @param zmin set the ground minimum Y coordinate
  78641. * @param xmax set the ground maximum X coordinate
  78642. * @param zmax set the ground maximum Z coordinate
  78643. * @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
  78644. * @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
  78645. * @param scene defines the hosting scene
  78646. * @param updatable defines if the mesh must be flagged as updatable
  78647. * @returns a new Mesh
  78648. */
  78649. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78650. w: number;
  78651. h: number;
  78652. }, precision: {
  78653. w: number;
  78654. h: number;
  78655. }, scene: Scene, updatable?: boolean): Mesh;
  78656. /**
  78657. * Creates a ground mesh from a height map.
  78658. * Please consider using the same method from the MeshBuilder class instead
  78659. * @see http://doc.babylonjs.com/babylon101/height_map
  78660. * @param name defines the name of the mesh to create
  78661. * @param url sets the URL of the height map image resource
  78662. * @param width set the ground width size
  78663. * @param height set the ground height size
  78664. * @param subdivisions sets the number of subdivision per side
  78665. * @param minHeight is the minimum altitude on the ground
  78666. * @param maxHeight is the maximum altitude on the ground
  78667. * @param scene defines the hosting scene
  78668. * @param updatable defines if the mesh must be flagged as updatable
  78669. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78670. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78671. * @returns a new Mesh
  78672. */
  78673. 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;
  78674. /**
  78675. * Creates a tube mesh.
  78676. * The tube is a parametric shape.
  78677. * It has no predefined shape. Its final shape will depend on the input parameters.
  78678. * Please consider using the same method from the MeshBuilder class instead
  78679. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78680. * @param name defines the name of the mesh to create
  78681. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78682. * @param radius sets the tube radius size
  78683. * @param tessellation is the number of sides on the tubular surface
  78684. * @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
  78685. * @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
  78686. * @param scene defines the hosting scene
  78687. * @param updatable defines if the mesh must be flagged as updatable
  78688. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78689. * @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)
  78690. * @returns a new Mesh
  78691. */
  78692. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78693. (i: number, distance: number): number;
  78694. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78695. /**
  78696. * Creates a polyhedron mesh.
  78697. * Please consider using the same method from the MeshBuilder class instead.
  78698. * * 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
  78699. * * The parameter `size` (positive float, default 1) sets the polygon size
  78700. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78701. * * 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`
  78702. * * 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
  78703. * * 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)`)
  78704. * * 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
  78705. * * 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
  78706. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78707. * * If you create a double-sided mesh, you can choose what parts of 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
  78708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78709. * @param name defines the name of the mesh to create
  78710. * @param options defines the options used to create the mesh
  78711. * @param scene defines the hosting scene
  78712. * @returns a new Mesh
  78713. */
  78714. static CreatePolyhedron(name: string, options: {
  78715. type?: number;
  78716. size?: number;
  78717. sizeX?: number;
  78718. sizeY?: number;
  78719. sizeZ?: number;
  78720. custom?: any;
  78721. faceUV?: Vector4[];
  78722. faceColors?: Color4[];
  78723. updatable?: boolean;
  78724. sideOrientation?: number;
  78725. }, scene: Scene): Mesh;
  78726. /**
  78727. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78728. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78729. * * 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`)
  78730. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78731. * * 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
  78732. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78733. * * If you create a double-sided mesh, you can choose what parts of 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
  78734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78735. * @param name defines the name of the mesh
  78736. * @param options defines the options used to create the mesh
  78737. * @param scene defines the hosting scene
  78738. * @returns a new Mesh
  78739. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78740. */
  78741. static CreateIcoSphere(name: string, options: {
  78742. radius?: number;
  78743. flat?: boolean;
  78744. subdivisions?: number;
  78745. sideOrientation?: number;
  78746. updatable?: boolean;
  78747. }, scene: Scene): Mesh;
  78748. /**
  78749. * Creates a decal mesh.
  78750. * Please consider using the same method from the MeshBuilder class instead.
  78751. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78752. * @param name defines the name of the mesh
  78753. * @param sourceMesh defines the mesh receiving the decal
  78754. * @param position sets the position of the decal in world coordinates
  78755. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78756. * @param size sets the decal scaling
  78757. * @param angle sets the angle to rotate the decal
  78758. * @returns a new Mesh
  78759. */
  78760. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78761. /**
  78762. * Prepare internal position array for software CPU skinning
  78763. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78764. */
  78765. setPositionsForCPUSkinning(): Float32Array;
  78766. /**
  78767. * Prepare internal normal array for software CPU skinning
  78768. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78769. */
  78770. setNormalsForCPUSkinning(): Float32Array;
  78771. /**
  78772. * Updates the vertex buffer by applying transformation from the bones
  78773. * @param skeleton defines the skeleton to apply to current mesh
  78774. * @returns the current mesh
  78775. */
  78776. applySkeleton(skeleton: Skeleton): Mesh;
  78777. /**
  78778. * 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
  78779. * @param meshes defines the list of meshes to scan
  78780. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78781. */
  78782. static MinMax(meshes: AbstractMesh[]): {
  78783. min: Vector3;
  78784. max: Vector3;
  78785. };
  78786. /**
  78787. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78788. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78789. * @returns a vector3
  78790. */
  78791. static Center(meshesOrMinMaxVector: {
  78792. min: Vector3;
  78793. max: Vector3;
  78794. } | AbstractMesh[]): Vector3;
  78795. /**
  78796. * Merge the array of meshes into a single mesh for performance reasons.
  78797. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78798. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78799. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78800. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78801. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78802. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78803. * @returns a new mesh
  78804. */
  78805. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78806. /** @hidden */
  78807. addInstance(instance: InstancedMesh): void;
  78808. /** @hidden */
  78809. removeInstance(instance: InstancedMesh): void;
  78810. }
  78811. }
  78812. declare module BABYLON {
  78813. /**
  78814. * Base class for the main features of a material in Babylon.js
  78815. */
  78816. export class Material implements IAnimatable {
  78817. /**
  78818. * Returns the triangle fill mode
  78819. */
  78820. static readonly TriangleFillMode: number;
  78821. /**
  78822. * Returns the wireframe mode
  78823. */
  78824. static readonly WireFrameFillMode: number;
  78825. /**
  78826. * Returns the point fill mode
  78827. */
  78828. static readonly PointFillMode: number;
  78829. /**
  78830. * Returns the point list draw mode
  78831. */
  78832. static readonly PointListDrawMode: number;
  78833. /**
  78834. * Returns the line list draw mode
  78835. */
  78836. static readonly LineListDrawMode: number;
  78837. /**
  78838. * Returns the line loop draw mode
  78839. */
  78840. static readonly LineLoopDrawMode: number;
  78841. /**
  78842. * Returns the line strip draw mode
  78843. */
  78844. static readonly LineStripDrawMode: number;
  78845. /**
  78846. * Returns the triangle strip draw mode
  78847. */
  78848. static readonly TriangleStripDrawMode: number;
  78849. /**
  78850. * Returns the triangle fan draw mode
  78851. */
  78852. static readonly TriangleFanDrawMode: number;
  78853. /**
  78854. * Stores the clock-wise side orientation
  78855. */
  78856. static readonly ClockWiseSideOrientation: number;
  78857. /**
  78858. * Stores the counter clock-wise side orientation
  78859. */
  78860. static readonly CounterClockWiseSideOrientation: number;
  78861. /**
  78862. * The dirty texture flag value
  78863. */
  78864. static readonly TextureDirtyFlag: number;
  78865. /**
  78866. * The dirty light flag value
  78867. */
  78868. static readonly LightDirtyFlag: number;
  78869. /**
  78870. * The dirty fresnel flag value
  78871. */
  78872. static readonly FresnelDirtyFlag: number;
  78873. /**
  78874. * The dirty attribute flag value
  78875. */
  78876. static readonly AttributesDirtyFlag: number;
  78877. /**
  78878. * The dirty misc flag value
  78879. */
  78880. static readonly MiscDirtyFlag: number;
  78881. /**
  78882. * The all dirty flag value
  78883. */
  78884. static readonly AllDirtyFlag: number;
  78885. /**
  78886. * The ID of the material
  78887. */
  78888. id: string;
  78889. /**
  78890. * Gets or sets the unique id of the material
  78891. */
  78892. uniqueId: number;
  78893. /**
  78894. * The name of the material
  78895. */
  78896. name: string;
  78897. /**
  78898. * Gets or sets user defined metadata
  78899. */
  78900. metadata: any;
  78901. /**
  78902. * For internal use only. Please do not use.
  78903. */
  78904. reservedDataStore: any;
  78905. /**
  78906. * Specifies if the ready state should be checked on each call
  78907. */
  78908. checkReadyOnEveryCall: boolean;
  78909. /**
  78910. * Specifies if the ready state should be checked once
  78911. */
  78912. checkReadyOnlyOnce: boolean;
  78913. /**
  78914. * The state of the material
  78915. */
  78916. state: string;
  78917. /**
  78918. * The alpha value of the material
  78919. */
  78920. protected _alpha: number;
  78921. /**
  78922. * Sets the alpha value of the material
  78923. */
  78924. /**
  78925. * Gets the alpha value of the material
  78926. */
  78927. alpha: number;
  78928. /**
  78929. * Specifies if back face culling is enabled
  78930. */
  78931. protected _backFaceCulling: boolean;
  78932. /**
  78933. * Sets the back-face culling state
  78934. */
  78935. /**
  78936. * Gets the back-face culling state
  78937. */
  78938. backFaceCulling: boolean;
  78939. /**
  78940. * Stores the value for side orientation
  78941. */
  78942. sideOrientation: number;
  78943. /**
  78944. * Callback triggered when the material is compiled
  78945. */
  78946. onCompiled: (effect: Effect) => void;
  78947. /**
  78948. * Callback triggered when an error occurs
  78949. */
  78950. onError: (effect: Effect, errors: string) => void;
  78951. /**
  78952. * Callback triggered to get the render target textures
  78953. */
  78954. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78955. /**
  78956. * Gets a boolean indicating that current material needs to register RTT
  78957. */
  78958. readonly hasRenderTargetTextures: boolean;
  78959. /**
  78960. * Specifies if the material should be serialized
  78961. */
  78962. doNotSerialize: boolean;
  78963. /**
  78964. * @hidden
  78965. */
  78966. _storeEffectOnSubMeshes: boolean;
  78967. /**
  78968. * Stores the animations for the material
  78969. */
  78970. animations: Array<Animation>;
  78971. /**
  78972. * An event triggered when the material is disposed
  78973. */
  78974. onDisposeObservable: Observable<Material>;
  78975. /**
  78976. * An observer which watches for dispose events
  78977. */
  78978. private _onDisposeObserver;
  78979. private _onUnBindObservable;
  78980. /**
  78981. * Called during a dispose event
  78982. */
  78983. onDispose: () => void;
  78984. private _onBindObservable;
  78985. /**
  78986. * An event triggered when the material is bound
  78987. */
  78988. readonly onBindObservable: Observable<AbstractMesh>;
  78989. /**
  78990. * An observer which watches for bind events
  78991. */
  78992. private _onBindObserver;
  78993. /**
  78994. * Called during a bind event
  78995. */
  78996. onBind: (Mesh: AbstractMesh) => void;
  78997. /**
  78998. * An event triggered when the material is unbound
  78999. */
  79000. readonly onUnBindObservable: Observable<Material>;
  79001. /**
  79002. * Stores the value of the alpha mode
  79003. */
  79004. private _alphaMode;
  79005. /**
  79006. * Sets the value of the alpha mode.
  79007. *
  79008. * | Value | Type | Description |
  79009. * | --- | --- | --- |
  79010. * | 0 | ALPHA_DISABLE | |
  79011. * | 1 | ALPHA_ADD | |
  79012. * | 2 | ALPHA_COMBINE | |
  79013. * | 3 | ALPHA_SUBTRACT | |
  79014. * | 4 | ALPHA_MULTIPLY | |
  79015. * | 5 | ALPHA_MAXIMIZED | |
  79016. * | 6 | ALPHA_ONEONE | |
  79017. * | 7 | ALPHA_PREMULTIPLIED | |
  79018. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  79019. * | 9 | ALPHA_INTERPOLATE | |
  79020. * | 10 | ALPHA_SCREENMODE | |
  79021. *
  79022. */
  79023. /**
  79024. * Gets the value of the alpha mode
  79025. */
  79026. alphaMode: number;
  79027. /**
  79028. * Stores the state of the need depth pre-pass value
  79029. */
  79030. private _needDepthPrePass;
  79031. /**
  79032. * Sets the need depth pre-pass value
  79033. */
  79034. /**
  79035. * Gets the depth pre-pass value
  79036. */
  79037. needDepthPrePass: boolean;
  79038. /**
  79039. * Specifies if depth writing should be disabled
  79040. */
  79041. disableDepthWrite: boolean;
  79042. /**
  79043. * Specifies if depth writing should be forced
  79044. */
  79045. forceDepthWrite: boolean;
  79046. /**
  79047. * Specifies if there should be a separate pass for culling
  79048. */
  79049. separateCullingPass: boolean;
  79050. /**
  79051. * Stores the state specifing if fog should be enabled
  79052. */
  79053. private _fogEnabled;
  79054. /**
  79055. * Sets the state for enabling fog
  79056. */
  79057. /**
  79058. * Gets the value of the fog enabled state
  79059. */
  79060. fogEnabled: boolean;
  79061. /**
  79062. * Stores the size of points
  79063. */
  79064. pointSize: number;
  79065. /**
  79066. * Stores the z offset value
  79067. */
  79068. zOffset: number;
  79069. /**
  79070. * Gets a value specifying if wireframe mode is enabled
  79071. */
  79072. /**
  79073. * Sets the state of wireframe mode
  79074. */
  79075. wireframe: boolean;
  79076. /**
  79077. * Gets the value specifying if point clouds are enabled
  79078. */
  79079. /**
  79080. * Sets the state of point cloud mode
  79081. */
  79082. pointsCloud: boolean;
  79083. /**
  79084. * Gets the material fill mode
  79085. */
  79086. /**
  79087. * Sets the material fill mode
  79088. */
  79089. fillMode: number;
  79090. /**
  79091. * @hidden
  79092. * Stores the effects for the material
  79093. */
  79094. _effect: Nullable<Effect>;
  79095. /**
  79096. * @hidden
  79097. * Specifies if the material was previously ready
  79098. */
  79099. _wasPreviouslyReady: boolean;
  79100. /**
  79101. * Specifies if uniform buffers should be used
  79102. */
  79103. private _useUBO;
  79104. /**
  79105. * Stores a reference to the scene
  79106. */
  79107. private _scene;
  79108. /**
  79109. * Stores the fill mode state
  79110. */
  79111. private _fillMode;
  79112. /**
  79113. * Specifies if the depth write state should be cached
  79114. */
  79115. private _cachedDepthWriteState;
  79116. /**
  79117. * Stores the uniform buffer
  79118. */
  79119. protected _uniformBuffer: UniformBuffer;
  79120. /** @hidden */
  79121. _indexInSceneMaterialArray: number;
  79122. /** @hidden */
  79123. meshMap: Nullable<{
  79124. [id: string]: AbstractMesh | undefined;
  79125. }>;
  79126. /**
  79127. * Creates a material instance
  79128. * @param name defines the name of the material
  79129. * @param scene defines the scene to reference
  79130. * @param doNotAdd specifies if the material should be added to the scene
  79131. */
  79132. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  79133. /**
  79134. * Returns a string representation of the current material
  79135. * @param fullDetails defines a boolean indicating which levels of logging is desired
  79136. * @returns a string with material information
  79137. */
  79138. toString(fullDetails?: boolean): string;
  79139. /**
  79140. * Gets the class name of the material
  79141. * @returns a string with the class name of the material
  79142. */
  79143. getClassName(): string;
  79144. /**
  79145. * Specifies if updates for the material been locked
  79146. */
  79147. readonly isFrozen: boolean;
  79148. /**
  79149. * Locks updates for the material
  79150. */
  79151. freeze(): void;
  79152. /**
  79153. * Unlocks updates for the material
  79154. */
  79155. unfreeze(): void;
  79156. /**
  79157. * Specifies if the material is ready to be used
  79158. * @param mesh defines the mesh to check
  79159. * @param useInstances specifies if instances should be used
  79160. * @returns a boolean indicating if the material is ready to be used
  79161. */
  79162. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79163. /**
  79164. * Specifies that the submesh is ready to be used
  79165. * @param mesh defines the mesh to check
  79166. * @param subMesh defines which submesh to check
  79167. * @param useInstances specifies that instances should be used
  79168. * @returns a boolean indicating that the submesh is ready or not
  79169. */
  79170. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79171. /**
  79172. * Returns the material effect
  79173. * @returns the effect associated with the material
  79174. */
  79175. getEffect(): Nullable<Effect>;
  79176. /**
  79177. * Returns the current scene
  79178. * @returns a Scene
  79179. */
  79180. getScene(): Scene;
  79181. /**
  79182. * Specifies if the material will require alpha blending
  79183. * @returns a boolean specifying if alpha blending is needed
  79184. */
  79185. needAlphaBlending(): boolean;
  79186. /**
  79187. * Specifies if the mesh will require alpha blending
  79188. * @param mesh defines the mesh to check
  79189. * @returns a boolean specifying if alpha blending is needed for the mesh
  79190. */
  79191. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  79192. /**
  79193. * Specifies if this material should be rendered in alpha test mode
  79194. * @returns a boolean specifying if an alpha test is needed.
  79195. */
  79196. needAlphaTesting(): boolean;
  79197. /**
  79198. * Gets the texture used for the alpha test
  79199. * @returns the texture to use for alpha testing
  79200. */
  79201. getAlphaTestTexture(): Nullable<BaseTexture>;
  79202. /**
  79203. * Marks the material to indicate that it needs to be re-calculated
  79204. */
  79205. markDirty(): void;
  79206. /** @hidden */
  79207. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  79208. /**
  79209. * Binds the material to the mesh
  79210. * @param world defines the world transformation matrix
  79211. * @param mesh defines the mesh to bind the material to
  79212. */
  79213. bind(world: Matrix, mesh?: Mesh): void;
  79214. /**
  79215. * Binds the submesh to the material
  79216. * @param world defines the world transformation matrix
  79217. * @param mesh defines the mesh containing the submesh
  79218. * @param subMesh defines the submesh to bind the material to
  79219. */
  79220. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79221. /**
  79222. * Binds the world matrix to the material
  79223. * @param world defines the world transformation matrix
  79224. */
  79225. bindOnlyWorldMatrix(world: Matrix): void;
  79226. /**
  79227. * Binds the scene's uniform buffer to the effect.
  79228. * @param effect defines the effect to bind to the scene uniform buffer
  79229. * @param sceneUbo defines the uniform buffer storing scene data
  79230. */
  79231. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79232. /**
  79233. * Binds the view matrix to the effect
  79234. * @param effect defines the effect to bind the view matrix to
  79235. */
  79236. bindView(effect: Effect): void;
  79237. /**
  79238. * Binds the view projection matrix to the effect
  79239. * @param effect defines the effect to bind the view projection matrix to
  79240. */
  79241. bindViewProjection(effect: Effect): void;
  79242. /**
  79243. * Specifies if material alpha testing should be turned on for the mesh
  79244. * @param mesh defines the mesh to check
  79245. */
  79246. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79247. /**
  79248. * Processes to execute after binding the material to a mesh
  79249. * @param mesh defines the rendered mesh
  79250. */
  79251. protected _afterBind(mesh?: Mesh): void;
  79252. /**
  79253. * Unbinds the material from the mesh
  79254. */
  79255. unbind(): void;
  79256. /**
  79257. * Gets the active textures from the material
  79258. * @returns an array of textures
  79259. */
  79260. getActiveTextures(): BaseTexture[];
  79261. /**
  79262. * Specifies if the material uses a texture
  79263. * @param texture defines the texture to check against the material
  79264. * @returns a boolean specifying if the material uses the texture
  79265. */
  79266. hasTexture(texture: BaseTexture): boolean;
  79267. /**
  79268. * Makes a duplicate of the material, and gives it a new name
  79269. * @param name defines the new name for the duplicated material
  79270. * @returns the cloned material
  79271. */
  79272. clone(name: string): Nullable<Material>;
  79273. /**
  79274. * Gets the meshes bound to the material
  79275. * @returns an array of meshes bound to the material
  79276. */
  79277. getBindedMeshes(): AbstractMesh[];
  79278. /**
  79279. * Force shader compilation
  79280. * @param mesh defines the mesh associated with this material
  79281. * @param onCompiled defines a function to execute once the material is compiled
  79282. * @param options defines the options to configure the compilation
  79283. */
  79284. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79285. clipPlane: boolean;
  79286. }>): void;
  79287. /**
  79288. * Force shader compilation
  79289. * @param mesh defines the mesh that will use this material
  79290. * @param options defines additional options for compiling the shaders
  79291. * @returns a promise that resolves when the compilation completes
  79292. */
  79293. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79294. clipPlane: boolean;
  79295. }>): Promise<void>;
  79296. private static readonly _ImageProcessingDirtyCallBack;
  79297. private static readonly _TextureDirtyCallBack;
  79298. private static readonly _FresnelDirtyCallBack;
  79299. private static readonly _MiscDirtyCallBack;
  79300. private static readonly _LightsDirtyCallBack;
  79301. private static readonly _AttributeDirtyCallBack;
  79302. private static _FresnelAndMiscDirtyCallBack;
  79303. private static _TextureAndMiscDirtyCallBack;
  79304. private static readonly _DirtyCallbackArray;
  79305. private static readonly _RunDirtyCallBacks;
  79306. /**
  79307. * Marks a define in the material to indicate that it needs to be re-computed
  79308. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79309. */
  79310. markAsDirty(flag: number): void;
  79311. /**
  79312. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79313. * @param func defines a function which checks material defines against the submeshes
  79314. */
  79315. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79316. /**
  79317. * Indicates that image processing needs to be re-calculated for all submeshes
  79318. */
  79319. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79320. /**
  79321. * Indicates that textures need to be re-calculated for all submeshes
  79322. */
  79323. protected _markAllSubMeshesAsTexturesDirty(): void;
  79324. /**
  79325. * Indicates that fresnel needs to be re-calculated for all submeshes
  79326. */
  79327. protected _markAllSubMeshesAsFresnelDirty(): void;
  79328. /**
  79329. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79330. */
  79331. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79332. /**
  79333. * Indicates that lights need to be re-calculated for all submeshes
  79334. */
  79335. protected _markAllSubMeshesAsLightsDirty(): void;
  79336. /**
  79337. * Indicates that attributes need to be re-calculated for all submeshes
  79338. */
  79339. protected _markAllSubMeshesAsAttributesDirty(): void;
  79340. /**
  79341. * Indicates that misc needs to be re-calculated for all submeshes
  79342. */
  79343. protected _markAllSubMeshesAsMiscDirty(): void;
  79344. /**
  79345. * Indicates that textures and misc need to be re-calculated for all submeshes
  79346. */
  79347. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79348. /**
  79349. * Disposes the material
  79350. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79351. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79352. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79353. */
  79354. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79355. /** @hidden */
  79356. private releaseVertexArrayObject;
  79357. /**
  79358. * Serializes this material
  79359. * @returns the serialized material object
  79360. */
  79361. serialize(): any;
  79362. /**
  79363. * Creates a material from parsed material data
  79364. * @param parsedMaterial defines parsed material data
  79365. * @param scene defines the hosting scene
  79366. * @param rootUrl defines the root URL to use to load textures
  79367. * @returns a new material
  79368. */
  79369. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79370. }
  79371. }
  79372. declare module BABYLON {
  79373. /**
  79374. * Base class for submeshes
  79375. */
  79376. export class BaseSubMesh {
  79377. /** @hidden */
  79378. _materialDefines: Nullable<MaterialDefines>;
  79379. /** @hidden */
  79380. _materialEffect: Nullable<Effect>;
  79381. /**
  79382. * Gets associated effect
  79383. */
  79384. readonly effect: Nullable<Effect>;
  79385. /**
  79386. * Sets associated effect (effect used to render this submesh)
  79387. * @param effect defines the effect to associate with
  79388. * @param defines defines the set of defines used to compile this effect
  79389. */
  79390. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79391. }
  79392. /**
  79393. * Defines a subdivision inside a mesh
  79394. */
  79395. export class SubMesh extends BaseSubMesh implements ICullable {
  79396. /** the material index to use */
  79397. materialIndex: number;
  79398. /** vertex index start */
  79399. verticesStart: number;
  79400. /** vertices count */
  79401. verticesCount: number;
  79402. /** index start */
  79403. indexStart: number;
  79404. /** indices count */
  79405. indexCount: number;
  79406. /** @hidden */
  79407. _linesIndexCount: number;
  79408. private _mesh;
  79409. private _renderingMesh;
  79410. private _boundingInfo;
  79411. private _linesIndexBuffer;
  79412. /** @hidden */
  79413. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79414. /** @hidden */
  79415. _trianglePlanes: Plane[];
  79416. /** @hidden */
  79417. _lastColliderTransformMatrix: Matrix;
  79418. /** @hidden */
  79419. _renderId: number;
  79420. /** @hidden */
  79421. _alphaIndex: number;
  79422. /** @hidden */
  79423. _distanceToCamera: number;
  79424. /** @hidden */
  79425. _id: number;
  79426. private _currentMaterial;
  79427. /**
  79428. * Add a new submesh to a mesh
  79429. * @param materialIndex defines the material index to use
  79430. * @param verticesStart defines vertex index start
  79431. * @param verticesCount defines vertices count
  79432. * @param indexStart defines index start
  79433. * @param indexCount defines indices count
  79434. * @param mesh defines the parent mesh
  79435. * @param renderingMesh defines an optional rendering mesh
  79436. * @param createBoundingBox defines if bounding box should be created for this submesh
  79437. * @returns the new submesh
  79438. */
  79439. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79440. /**
  79441. * Creates a new submesh
  79442. * @param materialIndex defines the material index to use
  79443. * @param verticesStart defines vertex index start
  79444. * @param verticesCount defines vertices count
  79445. * @param indexStart defines index start
  79446. * @param indexCount defines indices count
  79447. * @param mesh defines the parent mesh
  79448. * @param renderingMesh defines an optional rendering mesh
  79449. * @param createBoundingBox defines if bounding box should be created for this submesh
  79450. */
  79451. constructor(
  79452. /** the material index to use */
  79453. materialIndex: number,
  79454. /** vertex index start */
  79455. verticesStart: number,
  79456. /** vertices count */
  79457. verticesCount: number,
  79458. /** index start */
  79459. indexStart: number,
  79460. /** indices count */
  79461. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79462. /**
  79463. * Returns true if this submesh covers the entire parent mesh
  79464. * @ignorenaming
  79465. */
  79466. readonly IsGlobal: boolean;
  79467. /**
  79468. * Returns the submesh BoudingInfo object
  79469. * @returns current bounding info (or mesh's one if the submesh is global)
  79470. */
  79471. getBoundingInfo(): BoundingInfo;
  79472. /**
  79473. * Sets the submesh BoundingInfo
  79474. * @param boundingInfo defines the new bounding info to use
  79475. * @returns the SubMesh
  79476. */
  79477. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79478. /**
  79479. * Returns the mesh of the current submesh
  79480. * @return the parent mesh
  79481. */
  79482. getMesh(): AbstractMesh;
  79483. /**
  79484. * Returns the rendering mesh of the submesh
  79485. * @returns the rendering mesh (could be different from parent mesh)
  79486. */
  79487. getRenderingMesh(): Mesh;
  79488. /**
  79489. * Returns the submesh material
  79490. * @returns null or the current material
  79491. */
  79492. getMaterial(): Nullable<Material>;
  79493. /**
  79494. * Sets a new updated BoundingInfo object to the submesh
  79495. * @returns the SubMesh
  79496. */
  79497. refreshBoundingInfo(): SubMesh;
  79498. /** @hidden */
  79499. _checkCollision(collider: Collider): boolean;
  79500. /**
  79501. * Updates the submesh BoundingInfo
  79502. * @param world defines the world matrix to use to update the bounding info
  79503. * @returns the submesh
  79504. */
  79505. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79506. /**
  79507. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79508. * @param frustumPlanes defines the frustum planes
  79509. * @returns true if the submesh is intersecting with the frustum
  79510. */
  79511. isInFrustum(frustumPlanes: Plane[]): boolean;
  79512. /**
  79513. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79514. * @param frustumPlanes defines the frustum planes
  79515. * @returns true if the submesh is inside the frustum
  79516. */
  79517. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79518. /**
  79519. * Renders the submesh
  79520. * @param enableAlphaMode defines if alpha needs to be used
  79521. * @returns the submesh
  79522. */
  79523. render(enableAlphaMode: boolean): SubMesh;
  79524. /**
  79525. * @hidden
  79526. */
  79527. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79528. /**
  79529. * Checks if the submesh intersects with a ray
  79530. * @param ray defines the ray to test
  79531. * @returns true is the passed ray intersects the submesh bounding box
  79532. */
  79533. canIntersects(ray: Ray): boolean;
  79534. /**
  79535. * Intersects current submesh with a ray
  79536. * @param ray defines the ray to test
  79537. * @param positions defines mesh's positions array
  79538. * @param indices defines mesh's indices array
  79539. * @param fastCheck defines if only bounding info should be used
  79540. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79541. * @returns intersection info or null if no intersection
  79542. */
  79543. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79544. /** @hidden */
  79545. private _intersectLines;
  79546. /** @hidden */
  79547. private _intersectTriangles;
  79548. /** @hidden */
  79549. _rebuild(): void;
  79550. /**
  79551. * Creates a new submesh from the passed mesh
  79552. * @param newMesh defines the new hosting mesh
  79553. * @param newRenderingMesh defines an optional rendering mesh
  79554. * @returns the new submesh
  79555. */
  79556. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79557. /**
  79558. * Release associated resources
  79559. */
  79560. dispose(): void;
  79561. /**
  79562. * Gets the class name
  79563. * @returns the string "SubMesh".
  79564. */
  79565. getClassName(): string;
  79566. /**
  79567. * Creates a new submesh from indices data
  79568. * @param materialIndex the index of the main mesh material
  79569. * @param startIndex the index where to start the copy in the mesh indices array
  79570. * @param indexCount the number of indices to copy then from the startIndex
  79571. * @param mesh the main mesh to create the submesh from
  79572. * @param renderingMesh the optional rendering mesh
  79573. * @returns a new submesh
  79574. */
  79575. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79576. }
  79577. }
  79578. declare module BABYLON {
  79579. /**
  79580. * Class used to store geometry data (vertex buffers + index buffer)
  79581. */
  79582. export class Geometry implements IGetSetVerticesData {
  79583. /**
  79584. * Gets or sets the ID of the geometry
  79585. */
  79586. id: string;
  79587. /**
  79588. * Gets or sets the unique ID of the geometry
  79589. */
  79590. uniqueId: number;
  79591. /**
  79592. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79593. */
  79594. delayLoadState: number;
  79595. /**
  79596. * Gets the file containing the data to load when running in delay load state
  79597. */
  79598. delayLoadingFile: Nullable<string>;
  79599. /**
  79600. * Callback called when the geometry is updated
  79601. */
  79602. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79603. private _scene;
  79604. private _engine;
  79605. private _meshes;
  79606. private _totalVertices;
  79607. /** @hidden */
  79608. _indices: IndicesArray;
  79609. /** @hidden */
  79610. _vertexBuffers: {
  79611. [key: string]: VertexBuffer;
  79612. };
  79613. private _isDisposed;
  79614. private _extend;
  79615. private _boundingBias;
  79616. /** @hidden */
  79617. _delayInfo: Array<string>;
  79618. private _indexBuffer;
  79619. private _indexBufferIsUpdatable;
  79620. /** @hidden */
  79621. _boundingInfo: Nullable<BoundingInfo>;
  79622. /** @hidden */
  79623. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79624. /** @hidden */
  79625. _softwareSkinningFrameId: number;
  79626. private _vertexArrayObjects;
  79627. private _updatable;
  79628. /** @hidden */
  79629. _positions: Nullable<Vector3[]>;
  79630. /**
  79631. * 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
  79632. */
  79633. /**
  79634. * 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
  79635. */
  79636. boundingBias: Vector2;
  79637. /**
  79638. * Static function used to attach a new empty geometry to a mesh
  79639. * @param mesh defines the mesh to attach the geometry to
  79640. * @returns the new Geometry
  79641. */
  79642. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79643. /**
  79644. * Creates a new geometry
  79645. * @param id defines the unique ID
  79646. * @param scene defines the hosting scene
  79647. * @param vertexData defines the VertexData used to get geometry data
  79648. * @param updatable defines if geometry must be updatable (false by default)
  79649. * @param mesh defines the mesh that will be associated with the geometry
  79650. */
  79651. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79652. /**
  79653. * Gets the current extend of the geometry
  79654. */
  79655. readonly extend: {
  79656. minimum: Vector3;
  79657. maximum: Vector3;
  79658. };
  79659. /**
  79660. * Gets the hosting scene
  79661. * @returns the hosting Scene
  79662. */
  79663. getScene(): Scene;
  79664. /**
  79665. * Gets the hosting engine
  79666. * @returns the hosting Engine
  79667. */
  79668. getEngine(): Engine;
  79669. /**
  79670. * Defines if the geometry is ready to use
  79671. * @returns true if the geometry is ready to be used
  79672. */
  79673. isReady(): boolean;
  79674. /**
  79675. * Gets a value indicating that the geometry should not be serialized
  79676. */
  79677. readonly doNotSerialize: boolean;
  79678. /** @hidden */
  79679. _rebuild(): void;
  79680. /**
  79681. * Affects all geometry data in one call
  79682. * @param vertexData defines the geometry data
  79683. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79684. */
  79685. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79686. /**
  79687. * Set specific vertex data
  79688. * @param kind defines the data kind (Position, normal, etc...)
  79689. * @param data defines the vertex data to use
  79690. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79691. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79692. */
  79693. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79694. /**
  79695. * Removes a specific vertex data
  79696. * @param kind defines the data kind (Position, normal, etc...)
  79697. */
  79698. removeVerticesData(kind: string): void;
  79699. /**
  79700. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79701. * @param buffer defines the vertex buffer to use
  79702. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79703. */
  79704. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79705. /**
  79706. * Update a specific vertex buffer
  79707. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79708. * It will do nothing if the buffer is not updatable
  79709. * @param kind defines the data kind (Position, normal, etc...)
  79710. * @param data defines the data to use
  79711. * @param offset defines the offset in the target buffer where to store the data
  79712. * @param useBytes set to true if the offset is in bytes
  79713. */
  79714. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79715. /**
  79716. * Update a specific vertex buffer
  79717. * This function will create a new buffer if the current one is not updatable
  79718. * @param kind defines the data kind (Position, normal, etc...)
  79719. * @param data defines the data to use
  79720. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79721. */
  79722. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79723. private _updateBoundingInfo;
  79724. /** @hidden */
  79725. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79726. /**
  79727. * Gets total number of vertices
  79728. * @returns the total number of vertices
  79729. */
  79730. getTotalVertices(): number;
  79731. /**
  79732. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79733. * @param kind defines the data kind (Position, normal, etc...)
  79734. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79735. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79736. * @returns a float array containing vertex data
  79737. */
  79738. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79739. /**
  79740. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79741. * @param kind defines the data kind (Position, normal, etc...)
  79742. * @returns true if the vertex buffer with the specified kind is updatable
  79743. */
  79744. isVertexBufferUpdatable(kind: string): boolean;
  79745. /**
  79746. * Gets a specific vertex buffer
  79747. * @param kind defines the data kind (Position, normal, etc...)
  79748. * @returns a VertexBuffer
  79749. */
  79750. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79751. /**
  79752. * Returns all vertex buffers
  79753. * @return an object holding all vertex buffers indexed by kind
  79754. */
  79755. getVertexBuffers(): Nullable<{
  79756. [key: string]: VertexBuffer;
  79757. }>;
  79758. /**
  79759. * Gets a boolean indicating if specific vertex buffer is present
  79760. * @param kind defines the data kind (Position, normal, etc...)
  79761. * @returns true if data is present
  79762. */
  79763. isVerticesDataPresent(kind: string): boolean;
  79764. /**
  79765. * Gets a list of all attached data kinds (Position, normal, etc...)
  79766. * @returns a list of string containing all kinds
  79767. */
  79768. getVerticesDataKinds(): string[];
  79769. /**
  79770. * Update index buffer
  79771. * @param indices defines the indices to store in the index buffer
  79772. * @param offset defines the offset in the target buffer where to store the data
  79773. * @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)
  79774. */
  79775. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  79776. /**
  79777. * Creates a new index buffer
  79778. * @param indices defines the indices to store in the index buffer
  79779. * @param totalVertices defines the total number of vertices (could be null)
  79780. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79781. */
  79782. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79783. /**
  79784. * Return the total number of indices
  79785. * @returns the total number of indices
  79786. */
  79787. getTotalIndices(): number;
  79788. /**
  79789. * Gets the index buffer array
  79790. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79791. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79792. * @returns the index buffer array
  79793. */
  79794. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79795. /**
  79796. * Gets the index buffer
  79797. * @return the index buffer
  79798. */
  79799. getIndexBuffer(): Nullable<WebGLBuffer>;
  79800. /** @hidden */
  79801. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79802. /**
  79803. * Release the associated resources for a specific mesh
  79804. * @param mesh defines the source mesh
  79805. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79806. */
  79807. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79808. /**
  79809. * Apply current geometry to a given mesh
  79810. * @param mesh defines the mesh to apply geometry to
  79811. */
  79812. applyToMesh(mesh: Mesh): void;
  79813. private _updateExtend;
  79814. private _applyToMesh;
  79815. private notifyUpdate;
  79816. /**
  79817. * Load the geometry if it was flagged as delay loaded
  79818. * @param scene defines the hosting scene
  79819. * @param onLoaded defines a callback called when the geometry is loaded
  79820. */
  79821. load(scene: Scene, onLoaded?: () => void): void;
  79822. private _queueLoad;
  79823. /**
  79824. * Invert the geometry to move from a right handed system to a left handed one.
  79825. */
  79826. toLeftHanded(): void;
  79827. /** @hidden */
  79828. _resetPointsArrayCache(): void;
  79829. /** @hidden */
  79830. _generatePointsArray(): boolean;
  79831. /**
  79832. * Gets a value indicating if the geometry is disposed
  79833. * @returns true if the geometry was disposed
  79834. */
  79835. isDisposed(): boolean;
  79836. private _disposeVertexArrayObjects;
  79837. /**
  79838. * Free all associated resources
  79839. */
  79840. dispose(): void;
  79841. /**
  79842. * Clone the current geometry into a new geometry
  79843. * @param id defines the unique ID of the new geometry
  79844. * @returns a new geometry object
  79845. */
  79846. copy(id: string): Geometry;
  79847. /**
  79848. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79849. * @return a JSON representation of the current geometry data (without the vertices data)
  79850. */
  79851. serialize(): any;
  79852. private toNumberArray;
  79853. /**
  79854. * Serialize all vertices data into a JSON oject
  79855. * @returns a JSON representation of the current geometry data
  79856. */
  79857. serializeVerticeData(): any;
  79858. /**
  79859. * Extracts a clone of a mesh geometry
  79860. * @param mesh defines the source mesh
  79861. * @param id defines the unique ID of the new geometry object
  79862. * @returns the new geometry object
  79863. */
  79864. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79865. /**
  79866. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79867. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79868. * Be aware Math.random() could cause collisions, but:
  79869. * "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"
  79870. * @returns a string containing a new GUID
  79871. */
  79872. static RandomId(): string;
  79873. /** @hidden */
  79874. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79875. private static _CleanMatricesWeights;
  79876. /**
  79877. * Create a new geometry from persisted data (Using .babylon file format)
  79878. * @param parsedVertexData defines the persisted data
  79879. * @param scene defines the hosting scene
  79880. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79881. * @returns the new geometry object
  79882. */
  79883. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79884. }
  79885. }
  79886. declare module BABYLON {
  79887. /**
  79888. * Define an interface for all classes that will get and set the data on vertices
  79889. */
  79890. export interface IGetSetVerticesData {
  79891. /**
  79892. * Gets a boolean indicating if specific vertex data is present
  79893. * @param kind defines the vertex data kind to use
  79894. * @returns true is data kind is present
  79895. */
  79896. isVerticesDataPresent(kind: string): boolean;
  79897. /**
  79898. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79899. * @param kind defines the data kind (Position, normal, etc...)
  79900. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79901. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79902. * @returns a float array containing vertex data
  79903. */
  79904. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79905. /**
  79906. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79907. * @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.
  79908. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79909. * @returns the indices array or an empty array if the mesh has no geometry
  79910. */
  79911. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79912. /**
  79913. * Set specific vertex data
  79914. * @param kind defines the data kind (Position, normal, etc...)
  79915. * @param data defines the vertex data to use
  79916. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79917. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79918. */
  79919. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79920. /**
  79921. * Update a specific associated vertex buffer
  79922. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79923. * - VertexBuffer.PositionKind
  79924. * - VertexBuffer.UVKind
  79925. * - VertexBuffer.UV2Kind
  79926. * - VertexBuffer.UV3Kind
  79927. * - VertexBuffer.UV4Kind
  79928. * - VertexBuffer.UV5Kind
  79929. * - VertexBuffer.UV6Kind
  79930. * - VertexBuffer.ColorKind
  79931. * - VertexBuffer.MatricesIndicesKind
  79932. * - VertexBuffer.MatricesIndicesExtraKind
  79933. * - VertexBuffer.MatricesWeightsKind
  79934. * - VertexBuffer.MatricesWeightsExtraKind
  79935. * @param data defines the data source
  79936. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79937. * @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)
  79938. */
  79939. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79940. /**
  79941. * Creates a new index buffer
  79942. * @param indices defines the indices to store in the index buffer
  79943. * @param totalVertices defines the total number of vertices (could be null)
  79944. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79945. */
  79946. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79947. }
  79948. /**
  79949. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79950. */
  79951. export class VertexData {
  79952. /**
  79953. * Mesh side orientation : usually the external or front surface
  79954. */
  79955. static readonly FRONTSIDE: number;
  79956. /**
  79957. * Mesh side orientation : usually the internal or back surface
  79958. */
  79959. static readonly BACKSIDE: number;
  79960. /**
  79961. * Mesh side orientation : both internal and external or front and back surfaces
  79962. */
  79963. static readonly DOUBLESIDE: number;
  79964. /**
  79965. * Mesh side orientation : by default, `FRONTSIDE`
  79966. */
  79967. static readonly DEFAULTSIDE: number;
  79968. /**
  79969. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79970. */
  79971. positions: Nullable<FloatArray>;
  79972. /**
  79973. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79974. */
  79975. normals: Nullable<FloatArray>;
  79976. /**
  79977. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79978. */
  79979. tangents: Nullable<FloatArray>;
  79980. /**
  79981. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79982. */
  79983. uvs: Nullable<FloatArray>;
  79984. /**
  79985. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79986. */
  79987. uvs2: Nullable<FloatArray>;
  79988. /**
  79989. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79990. */
  79991. uvs3: Nullable<FloatArray>;
  79992. /**
  79993. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79994. */
  79995. uvs4: Nullable<FloatArray>;
  79996. /**
  79997. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79998. */
  79999. uvs5: Nullable<FloatArray>;
  80000. /**
  80001. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80002. */
  80003. uvs6: Nullable<FloatArray>;
  80004. /**
  80005. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  80006. */
  80007. colors: Nullable<FloatArray>;
  80008. /**
  80009. * 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).
  80010. */
  80011. matricesIndices: Nullable<FloatArray>;
  80012. /**
  80013. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  80014. */
  80015. matricesWeights: Nullable<FloatArray>;
  80016. /**
  80017. * An array extending the number of possible indices
  80018. */
  80019. matricesIndicesExtra: Nullable<FloatArray>;
  80020. /**
  80021. * An array extending the number of possible weights when the number of indices is extended
  80022. */
  80023. matricesWeightsExtra: Nullable<FloatArray>;
  80024. /**
  80025. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  80026. */
  80027. indices: Nullable<IndicesArray>;
  80028. /**
  80029. * Uses the passed data array to set the set the values for the specified kind of data
  80030. * @param data a linear array of floating numbers
  80031. * @param kind the type of data that is being set, eg positions, colors etc
  80032. */
  80033. set(data: FloatArray, kind: string): void;
  80034. /**
  80035. * Associates the vertexData to the passed Mesh.
  80036. * Sets it as updatable or not (default `false`)
  80037. * @param mesh the mesh the vertexData is applied to
  80038. * @param updatable when used and having the value true allows new data to update the vertexData
  80039. * @returns the VertexData
  80040. */
  80041. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  80042. /**
  80043. * Associates the vertexData to the passed Geometry.
  80044. * Sets it as updatable or not (default `false`)
  80045. * @param geometry the geometry the vertexData is applied to
  80046. * @param updatable when used and having the value true allows new data to update the vertexData
  80047. * @returns VertexData
  80048. */
  80049. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  80050. /**
  80051. * Updates the associated mesh
  80052. * @param mesh the mesh to be updated
  80053. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80054. * @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
  80055. * @returns VertexData
  80056. */
  80057. updateMesh(mesh: Mesh): VertexData;
  80058. /**
  80059. * Updates the associated geometry
  80060. * @param geometry the geometry to be updated
  80061. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80062. * @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
  80063. * @returns VertexData.
  80064. */
  80065. updateGeometry(geometry: Geometry): VertexData;
  80066. private _applyTo;
  80067. private _update;
  80068. /**
  80069. * Transforms each position and each normal of the vertexData according to the passed Matrix
  80070. * @param matrix the transforming matrix
  80071. * @returns the VertexData
  80072. */
  80073. transform(matrix: Matrix): VertexData;
  80074. /**
  80075. * Merges the passed VertexData into the current one
  80076. * @param other the VertexData to be merged into the current one
  80077. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  80078. * @returns the modified VertexData
  80079. */
  80080. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  80081. private _mergeElement;
  80082. private _validate;
  80083. /**
  80084. * Serializes the VertexData
  80085. * @returns a serialized object
  80086. */
  80087. serialize(): any;
  80088. /**
  80089. * Extracts the vertexData from a mesh
  80090. * @param mesh the mesh from which to extract the VertexData
  80091. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  80092. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80093. * @returns the object VertexData associated to the passed mesh
  80094. */
  80095. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80096. /**
  80097. * Extracts the vertexData from the geometry
  80098. * @param geometry the geometry from which to extract the VertexData
  80099. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  80100. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80101. * @returns the object VertexData associated to the passed mesh
  80102. */
  80103. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80104. private static _ExtractFrom;
  80105. /**
  80106. * Creates the VertexData for a Ribbon
  80107. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  80108. * * pathArray array of paths, each of which an array of successive Vector3
  80109. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  80110. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  80111. * * 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
  80112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80113. * * 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)
  80114. * * 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)
  80115. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  80116. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  80117. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  80118. * @returns the VertexData of the ribbon
  80119. */
  80120. static CreateRibbon(options: {
  80121. pathArray: Vector3[][];
  80122. closeArray?: boolean;
  80123. closePath?: boolean;
  80124. offset?: number;
  80125. sideOrientation?: number;
  80126. frontUVs?: Vector4;
  80127. backUVs?: Vector4;
  80128. invertUV?: boolean;
  80129. uvs?: Vector2[];
  80130. colors?: Color4[];
  80131. }): VertexData;
  80132. /**
  80133. * Creates the VertexData for a box
  80134. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80135. * * size sets the width, height and depth of the box to the value of size, optional default 1
  80136. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  80137. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  80138. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  80139. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  80140. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  80141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80142. * * 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)
  80143. * * 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)
  80144. * @returns the VertexData of the box
  80145. */
  80146. static CreateBox(options: {
  80147. size?: number;
  80148. width?: number;
  80149. height?: number;
  80150. depth?: number;
  80151. faceUV?: Vector4[];
  80152. faceColors?: Color4[];
  80153. sideOrientation?: number;
  80154. frontUVs?: Vector4;
  80155. backUVs?: Vector4;
  80156. }): VertexData;
  80157. /**
  80158. * Creates the VertexData for an ellipsoid, defaults to a sphere
  80159. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80160. * * segments sets the number of horizontal strips optional, default 32
  80161. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  80162. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  80163. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  80164. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  80165. * * 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
  80166. * * 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
  80167. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80168. * * 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)
  80169. * * 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)
  80170. * @returns the VertexData of the ellipsoid
  80171. */
  80172. static CreateSphere(options: {
  80173. segments?: number;
  80174. diameter?: number;
  80175. diameterX?: number;
  80176. diameterY?: number;
  80177. diameterZ?: number;
  80178. arc?: number;
  80179. slice?: number;
  80180. sideOrientation?: number;
  80181. frontUVs?: Vector4;
  80182. backUVs?: Vector4;
  80183. }): VertexData;
  80184. /**
  80185. * Creates the VertexData for a cylinder, cone or prism
  80186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80187. * * height sets the height (y direction) of the cylinder, optional, default 2
  80188. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  80189. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  80190. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  80191. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80192. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  80193. * * 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
  80194. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80195. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80196. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  80197. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  80198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80199. * * 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)
  80200. * * 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)
  80201. * @returns the VertexData of the cylinder, cone or prism
  80202. */
  80203. static CreateCylinder(options: {
  80204. height?: number;
  80205. diameterTop?: number;
  80206. diameterBottom?: number;
  80207. diameter?: number;
  80208. tessellation?: number;
  80209. subdivisions?: number;
  80210. arc?: number;
  80211. faceColors?: Color4[];
  80212. faceUV?: Vector4[];
  80213. hasRings?: boolean;
  80214. enclose?: boolean;
  80215. sideOrientation?: number;
  80216. frontUVs?: Vector4;
  80217. backUVs?: Vector4;
  80218. }): VertexData;
  80219. /**
  80220. * Creates the VertexData for a torus
  80221. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80222. * * diameter the diameter of the torus, optional default 1
  80223. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80224. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80226. * * 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)
  80227. * * 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)
  80228. * @returns the VertexData of the torus
  80229. */
  80230. static CreateTorus(options: {
  80231. diameter?: number;
  80232. thickness?: number;
  80233. tessellation?: number;
  80234. sideOrientation?: number;
  80235. frontUVs?: Vector4;
  80236. backUVs?: Vector4;
  80237. }): VertexData;
  80238. /**
  80239. * Creates the VertexData of the LineSystem
  80240. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80241. * - lines an array of lines, each line being an array of successive Vector3
  80242. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80243. * @returns the VertexData of the LineSystem
  80244. */
  80245. static CreateLineSystem(options: {
  80246. lines: Vector3[][];
  80247. colors?: Nullable<Color4[][]>;
  80248. }): VertexData;
  80249. /**
  80250. * Create the VertexData for a DashedLines
  80251. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80252. * - points an array successive Vector3
  80253. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80254. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80255. * - dashNb the intended total number of dashes, optional, default 200
  80256. * @returns the VertexData for the DashedLines
  80257. */
  80258. static CreateDashedLines(options: {
  80259. points: Vector3[];
  80260. dashSize?: number;
  80261. gapSize?: number;
  80262. dashNb?: number;
  80263. }): VertexData;
  80264. /**
  80265. * Creates the VertexData for a Ground
  80266. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80267. * - width the width (x direction) of the ground, optional, default 1
  80268. * - height the height (z direction) of the ground, optional, default 1
  80269. * - subdivisions the number of subdivisions per side, optional, default 1
  80270. * @returns the VertexData of the Ground
  80271. */
  80272. static CreateGround(options: {
  80273. width?: number;
  80274. height?: number;
  80275. subdivisions?: number;
  80276. subdivisionsX?: number;
  80277. subdivisionsY?: number;
  80278. }): VertexData;
  80279. /**
  80280. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80281. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80282. * * xmin the ground minimum X coordinate, optional, default -1
  80283. * * zmin the ground minimum Z coordinate, optional, default -1
  80284. * * xmax the ground maximum X coordinate, optional, default 1
  80285. * * zmax the ground maximum Z coordinate, optional, default 1
  80286. * * 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}
  80287. * * 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}
  80288. * @returns the VertexData of the TiledGround
  80289. */
  80290. static CreateTiledGround(options: {
  80291. xmin: number;
  80292. zmin: number;
  80293. xmax: number;
  80294. zmax: number;
  80295. subdivisions?: {
  80296. w: number;
  80297. h: number;
  80298. };
  80299. precision?: {
  80300. w: number;
  80301. h: number;
  80302. };
  80303. }): VertexData;
  80304. /**
  80305. * Creates the VertexData of the Ground designed from a heightmap
  80306. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80307. * * width the width (x direction) of the ground
  80308. * * height the height (z direction) of the ground
  80309. * * subdivisions the number of subdivisions per side
  80310. * * minHeight the minimum altitude on the ground, optional, default 0
  80311. * * maxHeight the maximum altitude on the ground, optional default 1
  80312. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80313. * * buffer the array holding the image color data
  80314. * * bufferWidth the width of image
  80315. * * bufferHeight the height of image
  80316. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80317. * @returns the VertexData of the Ground designed from a heightmap
  80318. */
  80319. static CreateGroundFromHeightMap(options: {
  80320. width: number;
  80321. height: number;
  80322. subdivisions: number;
  80323. minHeight: number;
  80324. maxHeight: number;
  80325. colorFilter: Color3;
  80326. buffer: Uint8Array;
  80327. bufferWidth: number;
  80328. bufferHeight: number;
  80329. alphaFilter: number;
  80330. }): VertexData;
  80331. /**
  80332. * Creates the VertexData for a Plane
  80333. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80334. * * size sets the width and height of the plane to the value of size, optional default 1
  80335. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80336. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80338. * * 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)
  80339. * * 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)
  80340. * @returns the VertexData of the box
  80341. */
  80342. static CreatePlane(options: {
  80343. size?: number;
  80344. width?: number;
  80345. height?: number;
  80346. sideOrientation?: number;
  80347. frontUVs?: Vector4;
  80348. backUVs?: Vector4;
  80349. }): VertexData;
  80350. /**
  80351. * Creates the VertexData of the Disc or regular Polygon
  80352. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80353. * * radius the radius of the disc, optional default 0.5
  80354. * * tessellation the number of polygon sides, optional, default 64
  80355. * * 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
  80356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80357. * * 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)
  80358. * * 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)
  80359. * @returns the VertexData of the box
  80360. */
  80361. static CreateDisc(options: {
  80362. radius?: number;
  80363. tessellation?: number;
  80364. arc?: number;
  80365. sideOrientation?: number;
  80366. frontUVs?: Vector4;
  80367. backUVs?: Vector4;
  80368. }): VertexData;
  80369. /**
  80370. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80371. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80372. * @param polygon a mesh built from polygonTriangulation.build()
  80373. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80374. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80375. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80376. * @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)
  80377. * @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)
  80378. * @returns the VertexData of the Polygon
  80379. */
  80380. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80381. /**
  80382. * Creates the VertexData of the IcoSphere
  80383. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80384. * * radius the radius of the IcoSphere, optional default 1
  80385. * * radiusX allows stretching in the x direction, optional, default radius
  80386. * * radiusY allows stretching in the y direction, optional, default radius
  80387. * * radiusZ allows stretching in the z direction, optional, default radius
  80388. * * flat when true creates a flat shaded mesh, optional, default true
  80389. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80391. * * 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)
  80392. * * 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)
  80393. * @returns the VertexData of the IcoSphere
  80394. */
  80395. static CreateIcoSphere(options: {
  80396. radius?: number;
  80397. radiusX?: number;
  80398. radiusY?: number;
  80399. radiusZ?: number;
  80400. flat?: boolean;
  80401. subdivisions?: number;
  80402. sideOrientation?: number;
  80403. frontUVs?: Vector4;
  80404. backUVs?: Vector4;
  80405. }): VertexData;
  80406. /**
  80407. * Creates the VertexData for a Polyhedron
  80408. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80409. * * type provided types are:
  80410. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80411. * * 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)
  80412. * * size the size of the IcoSphere, optional default 1
  80413. * * sizeX allows stretching in the x direction, optional, default size
  80414. * * sizeY allows stretching in the y direction, optional, default size
  80415. * * sizeZ allows stretching in the z direction, optional, default size
  80416. * * 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
  80417. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80418. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80419. * * flat when true creates a flat shaded mesh, optional, default true
  80420. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80421. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80422. * * 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)
  80423. * * 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)
  80424. * @returns the VertexData of the Polyhedron
  80425. */
  80426. static CreatePolyhedron(options: {
  80427. type?: number;
  80428. size?: number;
  80429. sizeX?: number;
  80430. sizeY?: number;
  80431. sizeZ?: number;
  80432. custom?: any;
  80433. faceUV?: Vector4[];
  80434. faceColors?: Color4[];
  80435. flat?: boolean;
  80436. sideOrientation?: number;
  80437. frontUVs?: Vector4;
  80438. backUVs?: Vector4;
  80439. }): VertexData;
  80440. /**
  80441. * Creates the VertexData for a TorusKnot
  80442. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80443. * * radius the radius of the torus knot, optional, default 2
  80444. * * tube the thickness of the tube, optional, default 0.5
  80445. * * radialSegments the number of sides on each tube segments, optional, default 32
  80446. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80447. * * p the number of windings around the z axis, optional, default 2
  80448. * * q the number of windings around the x axis, optional, default 3
  80449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80450. * * 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)
  80451. * * 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)
  80452. * @returns the VertexData of the Torus Knot
  80453. */
  80454. static CreateTorusKnot(options: {
  80455. radius?: number;
  80456. tube?: number;
  80457. radialSegments?: number;
  80458. tubularSegments?: number;
  80459. p?: number;
  80460. q?: number;
  80461. sideOrientation?: number;
  80462. frontUVs?: Vector4;
  80463. backUVs?: Vector4;
  80464. }): VertexData;
  80465. /**
  80466. * Compute normals for given positions and indices
  80467. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80468. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80469. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80470. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80471. * * facetNormals : optional array of facet normals (vector3)
  80472. * * facetPositions : optional array of facet positions (vector3)
  80473. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80474. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80475. * * bInfo : optional bounding info, required for facetPartitioning computation
  80476. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80477. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80478. * * useRightHandedSystem: optional boolean to for right handed system computation
  80479. * * depthSort : optional boolean to enable the facet depth sort computation
  80480. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80481. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80482. */
  80483. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80484. facetNormals?: any;
  80485. facetPositions?: any;
  80486. facetPartitioning?: any;
  80487. ratio?: number;
  80488. bInfo?: any;
  80489. bbSize?: Vector3;
  80490. subDiv?: any;
  80491. useRightHandedSystem?: boolean;
  80492. depthSort?: boolean;
  80493. distanceTo?: Vector3;
  80494. depthSortedFacets?: any;
  80495. }): void;
  80496. /** @hidden */
  80497. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80498. /**
  80499. * Applies VertexData created from the imported parameters to the geometry
  80500. * @param parsedVertexData the parsed data from an imported file
  80501. * @param geometry the geometry to apply the VertexData to
  80502. */
  80503. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80504. }
  80505. }
  80506. declare module BABYLON {
  80507. /**
  80508. * Class containing static functions to help procedurally build meshes
  80509. */
  80510. export class DiscBuilder {
  80511. /**
  80512. * Creates a plane polygonal mesh. By default, this is a disc
  80513. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80514. * * 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
  80515. * * 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
  80516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80519. * @param name defines the name of the mesh
  80520. * @param options defines the options used to create the mesh
  80521. * @param scene defines the hosting scene
  80522. * @returns the plane polygonal mesh
  80523. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80524. */
  80525. static CreateDisc(name: string, options: {
  80526. radius?: number;
  80527. tessellation?: number;
  80528. arc?: number;
  80529. updatable?: boolean;
  80530. sideOrientation?: number;
  80531. frontUVs?: Vector4;
  80532. backUVs?: Vector4;
  80533. }, scene?: Nullable<Scene>): Mesh;
  80534. }
  80535. }
  80536. declare module BABYLON {
  80537. /**
  80538. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80539. *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.
  80540. * The SPS is also a particle system. It provides some methods to manage the particles.
  80541. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80542. *
  80543. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80544. */
  80545. export class SolidParticleSystem implements IDisposable {
  80546. /**
  80547. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80548. * Example : var p = SPS.particles[i];
  80549. */
  80550. particles: SolidParticle[];
  80551. /**
  80552. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80553. */
  80554. nbParticles: number;
  80555. /**
  80556. * If the particles must ever face the camera (default false). Useful for planar particles.
  80557. */
  80558. billboard: boolean;
  80559. /**
  80560. * Recompute normals when adding a shape
  80561. */
  80562. recomputeNormals: boolean;
  80563. /**
  80564. * This a counter ofr your own usage. It's not set by any SPS functions.
  80565. */
  80566. counter: number;
  80567. /**
  80568. * The SPS name. This name is also given to the underlying mesh.
  80569. */
  80570. name: string;
  80571. /**
  80572. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80573. */
  80574. mesh: Mesh;
  80575. /**
  80576. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80577. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80578. */
  80579. vars: any;
  80580. /**
  80581. * This array is populated when the SPS is set as 'pickable'.
  80582. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80583. * Each element of this array is an object `{idx: int, faceId: int}`.
  80584. * `idx` is the picked particle index in the `SPS.particles` array
  80585. * `faceId` is the picked face index counted within this particle.
  80586. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80587. */
  80588. pickedParticles: {
  80589. idx: number;
  80590. faceId: number;
  80591. }[];
  80592. /**
  80593. * This array is populated when `enableDepthSort` is set to true.
  80594. * Each element of this array is an instance of the class DepthSortedParticle.
  80595. */
  80596. depthSortedParticles: DepthSortedParticle[];
  80597. /**
  80598. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80599. * @hidden
  80600. */
  80601. _bSphereOnly: boolean;
  80602. /**
  80603. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80604. * @hidden
  80605. */
  80606. _bSphereRadiusFactor: number;
  80607. private _scene;
  80608. private _positions;
  80609. private _indices;
  80610. private _normals;
  80611. private _colors;
  80612. private _uvs;
  80613. private _indices32;
  80614. private _positions32;
  80615. private _normals32;
  80616. private _fixedNormal32;
  80617. private _colors32;
  80618. private _uvs32;
  80619. private _index;
  80620. private _updatable;
  80621. private _pickable;
  80622. private _isVisibilityBoxLocked;
  80623. private _alwaysVisible;
  80624. private _depthSort;
  80625. private _shapeCounter;
  80626. private _copy;
  80627. private _color;
  80628. private _computeParticleColor;
  80629. private _computeParticleTexture;
  80630. private _computeParticleRotation;
  80631. private _computeParticleVertex;
  80632. private _computeBoundingBox;
  80633. private _depthSortParticles;
  80634. private _camera;
  80635. private _mustUnrotateFixedNormals;
  80636. private _particlesIntersect;
  80637. private _needs32Bits;
  80638. /**
  80639. * Creates a SPS (Solid Particle System) object.
  80640. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80641. * @param scene (Scene) is the scene in which the SPS is added.
  80642. * @param options defines the options of the sps e.g.
  80643. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80644. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80645. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80646. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80647. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80648. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80649. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80650. */
  80651. constructor(name: string, scene: Scene, options?: {
  80652. updatable?: boolean;
  80653. isPickable?: boolean;
  80654. enableDepthSort?: boolean;
  80655. particleIntersection?: boolean;
  80656. boundingSphereOnly?: boolean;
  80657. bSphereRadiusFactor?: number;
  80658. });
  80659. /**
  80660. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80661. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80662. * @returns the created mesh
  80663. */
  80664. buildMesh(): Mesh;
  80665. /**
  80666. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80667. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80668. * Thus the particles generated from `digest()` have their property `position` set yet.
  80669. * @param mesh ( Mesh ) is the mesh to be digested
  80670. * @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
  80671. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80672. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80673. * @returns the current SPS
  80674. */
  80675. digest(mesh: Mesh, options?: {
  80676. facetNb?: number;
  80677. number?: number;
  80678. delta?: number;
  80679. }): SolidParticleSystem;
  80680. private _unrotateFixedNormals;
  80681. private _resetCopy;
  80682. private _meshBuilder;
  80683. private _posToShape;
  80684. private _uvsToShapeUV;
  80685. private _addParticle;
  80686. /**
  80687. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80688. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80689. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80690. * @param nb (positive integer) the number of particles to be created from this model
  80691. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80692. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80693. * @returns the number of shapes in the system
  80694. */
  80695. addShape(mesh: Mesh, nb: number, options?: {
  80696. positionFunction?: any;
  80697. vertexFunction?: any;
  80698. }): number;
  80699. private _rebuildParticle;
  80700. /**
  80701. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80702. * @returns the SPS.
  80703. */
  80704. rebuildMesh(): SolidParticleSystem;
  80705. /**
  80706. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80707. * This method calls `updateParticle()` for each particle of the SPS.
  80708. * For an animated SPS, it is usually called within the render loop.
  80709. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80710. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80711. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80712. * @returns the SPS.
  80713. */
  80714. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80715. /**
  80716. * Disposes the SPS.
  80717. */
  80718. dispose(): void;
  80719. /**
  80720. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80721. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80722. * @returns the SPS.
  80723. */
  80724. refreshVisibleSize(): SolidParticleSystem;
  80725. /**
  80726. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80727. * @param size the size (float) of the visibility box
  80728. * note : this doesn't lock the SPS mesh bounding box.
  80729. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80730. */
  80731. setVisibilityBox(size: number): void;
  80732. /**
  80733. * Gets whether the SPS as always visible or not
  80734. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80735. */
  80736. /**
  80737. * Sets the SPS as always visible or not
  80738. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80739. */
  80740. isAlwaysVisible: boolean;
  80741. /**
  80742. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80743. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80744. */
  80745. /**
  80746. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80747. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80748. */
  80749. isVisibilityBoxLocked: boolean;
  80750. /**
  80751. * Tells to `setParticles()` to compute the particle rotations or not.
  80752. * Default value : true. The SPS is faster when it's set to false.
  80753. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80754. */
  80755. /**
  80756. * Gets if `setParticles()` computes the particle rotations or not.
  80757. * Default value : true. The SPS is faster when it's set to false.
  80758. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80759. */
  80760. computeParticleRotation: boolean;
  80761. /**
  80762. * Tells to `setParticles()` to compute the particle colors or not.
  80763. * Default value : true. The SPS is faster when it's set to false.
  80764. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80765. */
  80766. /**
  80767. * Gets if `setParticles()` computes the particle colors or not.
  80768. * Default value : true. The SPS is faster when it's set to false.
  80769. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80770. */
  80771. computeParticleColor: boolean;
  80772. /**
  80773. * Gets if `setParticles()` computes the particle textures or not.
  80774. * Default value : true. The SPS is faster when it's set to false.
  80775. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80776. */
  80777. computeParticleTexture: boolean;
  80778. /**
  80779. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80780. * Default value : false. The SPS is faster when it's set to false.
  80781. * Note : the particle custom vertex positions aren't stored values.
  80782. */
  80783. /**
  80784. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80785. * Default value : false. The SPS is faster when it's set to false.
  80786. * Note : the particle custom vertex positions aren't stored values.
  80787. */
  80788. computeParticleVertex: boolean;
  80789. /**
  80790. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80791. */
  80792. /**
  80793. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80794. */
  80795. computeBoundingBox: boolean;
  80796. /**
  80797. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80798. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80799. * Default : `true`
  80800. */
  80801. /**
  80802. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80803. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80804. * Default : `true`
  80805. */
  80806. depthSortParticles: boolean;
  80807. /**
  80808. * This function does nothing. It may be overwritten to set all the particle first values.
  80809. * The SPS doesn't call this function, you may have to call it by your own.
  80810. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80811. */
  80812. initParticles(): void;
  80813. /**
  80814. * This function does nothing. It may be overwritten to recycle a particle.
  80815. * The SPS doesn't call this function, you may have to call it by your own.
  80816. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80817. * @param particle The particle to recycle
  80818. * @returns the recycled particle
  80819. */
  80820. recycleParticle(particle: SolidParticle): SolidParticle;
  80821. /**
  80822. * Updates a particle : this function should be overwritten by the user.
  80823. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80824. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80825. * @example : just set a particle position or velocity and recycle conditions
  80826. * @param particle The particle to update
  80827. * @returns the updated particle
  80828. */
  80829. updateParticle(particle: SolidParticle): SolidParticle;
  80830. /**
  80831. * Updates a vertex of a particle : it can be overwritten by the user.
  80832. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80833. * @param particle the current particle
  80834. * @param vertex the current index of the current particle
  80835. * @param pt the index of the current vertex in the particle shape
  80836. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80837. * @example : just set a vertex particle position
  80838. * @returns the updated vertex
  80839. */
  80840. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80841. /**
  80842. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80843. * This does nothing and may be overwritten by the user.
  80844. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80845. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80846. * @param update the boolean update value actually passed to setParticles()
  80847. */
  80848. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80849. /**
  80850. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80851. * This will be passed three parameters.
  80852. * This does nothing and may be overwritten by the user.
  80853. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80854. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80855. * @param update the boolean update value actually passed to setParticles()
  80856. */
  80857. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80858. }
  80859. }
  80860. declare module BABYLON {
  80861. /**
  80862. * Represents one particle of a solid particle system.
  80863. */
  80864. export class SolidParticle {
  80865. /**
  80866. * particle global index
  80867. */
  80868. idx: number;
  80869. /**
  80870. * The color of the particle
  80871. */
  80872. color: Nullable<Color4>;
  80873. /**
  80874. * The world space position of the particle.
  80875. */
  80876. position: Vector3;
  80877. /**
  80878. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80879. */
  80880. rotation: Vector3;
  80881. /**
  80882. * The world space rotation quaternion of the particle.
  80883. */
  80884. rotationQuaternion: Nullable<Quaternion>;
  80885. /**
  80886. * The scaling of the particle.
  80887. */
  80888. scaling: Vector3;
  80889. /**
  80890. * The uvs of the particle.
  80891. */
  80892. uvs: Vector4;
  80893. /**
  80894. * The current speed of the particle.
  80895. */
  80896. velocity: Vector3;
  80897. /**
  80898. * The pivot point in the particle local space.
  80899. */
  80900. pivot: Vector3;
  80901. /**
  80902. * Must the particle be translated from its pivot point in its local space ?
  80903. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80904. * Default : false
  80905. */
  80906. translateFromPivot: boolean;
  80907. /**
  80908. * Is the particle active or not ?
  80909. */
  80910. alive: boolean;
  80911. /**
  80912. * Is the particle visible or not ?
  80913. */
  80914. isVisible: boolean;
  80915. /**
  80916. * Index of this particle in the global "positions" array (Internal use)
  80917. * @hidden
  80918. */
  80919. _pos: number;
  80920. /**
  80921. * @hidden Index of this particle in the global "indices" array (Internal use)
  80922. */
  80923. _ind: number;
  80924. /**
  80925. * @hidden ModelShape of this particle (Internal use)
  80926. */
  80927. _model: ModelShape;
  80928. /**
  80929. * ModelShape id of this particle
  80930. */
  80931. shapeId: number;
  80932. /**
  80933. * Index of the particle in its shape id (Internal use)
  80934. */
  80935. idxInShape: number;
  80936. /**
  80937. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80938. */
  80939. _modelBoundingInfo: BoundingInfo;
  80940. /**
  80941. * @hidden Particle BoundingInfo object (Internal use)
  80942. */
  80943. _boundingInfo: BoundingInfo;
  80944. /**
  80945. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80946. */
  80947. _sps: SolidParticleSystem;
  80948. /**
  80949. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80950. */
  80951. _stillInvisible: boolean;
  80952. /**
  80953. * @hidden Last computed particle rotation matrix
  80954. */
  80955. _rotationMatrix: number[];
  80956. /**
  80957. * Parent particle Id, if any.
  80958. * Default null.
  80959. */
  80960. parentId: Nullable<number>;
  80961. /**
  80962. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80963. * The possible values are :
  80964. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80965. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80967. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80968. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80969. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80970. * */
  80971. cullingStrategy: number;
  80972. /**
  80973. * @hidden Internal global position in the SPS.
  80974. */
  80975. _globalPosition: Vector3;
  80976. /**
  80977. * Creates a Solid Particle object.
  80978. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80979. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80980. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80981. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80982. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80983. * @param shapeId (integer) is the model shape identifier in the SPS.
  80984. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80985. * @param sps defines the sps it is associated to
  80986. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80987. */
  80988. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80989. /**
  80990. * Legacy support, changed scale to scaling
  80991. */
  80992. /**
  80993. * Legacy support, changed scale to scaling
  80994. */
  80995. scale: Vector3;
  80996. /**
  80997. * Legacy support, changed quaternion to rotationQuaternion
  80998. */
  80999. /**
  81000. * Legacy support, changed quaternion to rotationQuaternion
  81001. */
  81002. quaternion: Nullable<Quaternion>;
  81003. /**
  81004. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  81005. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  81006. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  81007. * @returns true if it intersects
  81008. */
  81009. intersectsMesh(target: Mesh | SolidParticle): boolean;
  81010. /**
  81011. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  81012. * A particle is in the frustum if its bounding box intersects the frustum
  81013. * @param frustumPlanes defines the frustum to test
  81014. * @returns true if the particle is in the frustum planes
  81015. */
  81016. isInFrustum(frustumPlanes: Plane[]): boolean;
  81017. /**
  81018. * get the rotation matrix of the particle
  81019. * @hidden
  81020. */
  81021. getRotationMatrix(m: Matrix): void;
  81022. }
  81023. /**
  81024. * Represents the shape of the model used by one particle of a solid particle system.
  81025. * SPS internal tool, don't use it manually.
  81026. */
  81027. export class ModelShape {
  81028. /**
  81029. * The shape id
  81030. * @hidden
  81031. */
  81032. shapeID: number;
  81033. /**
  81034. * flat array of model positions (internal use)
  81035. * @hidden
  81036. */
  81037. _shape: Vector3[];
  81038. /**
  81039. * flat array of model UVs (internal use)
  81040. * @hidden
  81041. */
  81042. _shapeUV: number[];
  81043. /**
  81044. * length of the shape in the model indices array (internal use)
  81045. * @hidden
  81046. */
  81047. _indicesLength: number;
  81048. /**
  81049. * Custom position function (internal use)
  81050. * @hidden
  81051. */
  81052. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  81053. /**
  81054. * Custom vertex function (internal use)
  81055. * @hidden
  81056. */
  81057. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  81058. /**
  81059. * 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.
  81060. * SPS internal tool, don't use it manually.
  81061. * @hidden
  81062. */
  81063. 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>);
  81064. }
  81065. /**
  81066. * Represents a Depth Sorted Particle in the solid particle system.
  81067. */
  81068. export class DepthSortedParticle {
  81069. /**
  81070. * Index of the particle in the "indices" array
  81071. */
  81072. ind: number;
  81073. /**
  81074. * Length of the particle shape in the "indices" array
  81075. */
  81076. indicesLength: number;
  81077. /**
  81078. * Squared distance from the particle to the camera
  81079. */
  81080. sqDistance: number;
  81081. }
  81082. }
  81083. declare module BABYLON {
  81084. /**
  81085. * Class used to store all common mesh properties
  81086. */
  81087. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  81088. /** No occlusion */
  81089. static OCCLUSION_TYPE_NONE: number;
  81090. /** Occlusion set to optimisitic */
  81091. static OCCLUSION_TYPE_OPTIMISTIC: number;
  81092. /** Occlusion set to strict */
  81093. static OCCLUSION_TYPE_STRICT: number;
  81094. /** Use an accurante occlusion algorithm */
  81095. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  81096. /** Use a conservative occlusion algorithm */
  81097. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  81098. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81099. * Test order :
  81100. * Is the bounding sphere outside the frustum ?
  81101. * If not, are the bounding box vertices outside the frustum ?
  81102. * It not, then the cullable object is in the frustum.
  81103. */
  81104. static readonly CULLINGSTRATEGY_STANDARD: number;
  81105. /** Culling strategy : Bounding Sphere Only.
  81106. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81107. * It's also less accurate than the standard because some not visible objects can still be selected.
  81108. * Test : is the bounding sphere outside the frustum ?
  81109. * If not, then the cullable object is in the frustum.
  81110. */
  81111. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81112. /** Culling strategy : Optimistic Inclusion.
  81113. * This in an inclusion test first, then the standard exclusion test.
  81114. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81115. * 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.
  81116. * Anyway, it's as accurate as the standard strategy.
  81117. * Test :
  81118. * Is the cullable object bounding sphere center in the frustum ?
  81119. * If not, apply the default culling strategy.
  81120. */
  81121. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81122. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81123. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81124. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81125. * 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.
  81126. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81127. * Test :
  81128. * Is the cullable object bounding sphere center in the frustum ?
  81129. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81130. */
  81131. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81132. /**
  81133. * No billboard
  81134. */
  81135. static readonly BILLBOARDMODE_NONE: number;
  81136. /** Billboard on X axis */
  81137. static readonly BILLBOARDMODE_X: number;
  81138. /** Billboard on Y axis */
  81139. static readonly BILLBOARDMODE_Y: number;
  81140. /** Billboard on Z axis */
  81141. static readonly BILLBOARDMODE_Z: number;
  81142. /** Billboard on all axes */
  81143. static readonly BILLBOARDMODE_ALL: number;
  81144. private _facetData;
  81145. /**
  81146. * The culling strategy to use to check whether the mesh must be rendered or not.
  81147. * This value can be changed at any time and will be used on the next render mesh selection.
  81148. * The possible values are :
  81149. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81150. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81151. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81152. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81153. * Please read each static variable documentation to get details about the culling process.
  81154. * */
  81155. cullingStrategy: number;
  81156. /**
  81157. * Gets the number of facets in the mesh
  81158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81159. */
  81160. readonly facetNb: number;
  81161. /**
  81162. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  81163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81164. */
  81165. partitioningSubdivisions: number;
  81166. /**
  81167. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  81168. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  81169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81170. */
  81171. partitioningBBoxRatio: number;
  81172. /**
  81173. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  81174. * Works only for updatable meshes.
  81175. * Doesn't work with multi-materials
  81176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81177. */
  81178. mustDepthSortFacets: boolean;
  81179. /**
  81180. * The location (Vector3) where the facet depth sort must be computed from.
  81181. * By default, the active camera position.
  81182. * Used only when facet depth sort is enabled
  81183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81184. */
  81185. facetDepthSortFrom: Vector3;
  81186. /**
  81187. * gets a boolean indicating if facetData is enabled
  81188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81189. */
  81190. readonly isFacetDataEnabled: boolean;
  81191. /** @hidden */
  81192. _updateNonUniformScalingState(value: boolean): boolean;
  81193. /**
  81194. * An event triggered when this mesh collides with another one
  81195. */
  81196. onCollideObservable: Observable<AbstractMesh>;
  81197. private _onCollideObserver;
  81198. /** Set a function to call when this mesh collides with another one */
  81199. onCollide: () => void;
  81200. /**
  81201. * An event triggered when the collision's position changes
  81202. */
  81203. onCollisionPositionChangeObservable: Observable<Vector3>;
  81204. private _onCollisionPositionChangeObserver;
  81205. /** Set a function to call when the collision's position changes */
  81206. onCollisionPositionChange: () => void;
  81207. /**
  81208. * An event triggered when material is changed
  81209. */
  81210. onMaterialChangedObservable: Observable<AbstractMesh>;
  81211. /**
  81212. * Gets or sets the orientation for POV movement & rotation
  81213. */
  81214. definedFacingForward: boolean;
  81215. /** @hidden */
  81216. _occlusionQuery: Nullable<WebGLQuery>;
  81217. private _visibility;
  81218. /**
  81219. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81220. */
  81221. /**
  81222. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81223. */
  81224. visibility: number;
  81225. /** Gets or sets the alpha index used to sort transparent meshes
  81226. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81227. */
  81228. alphaIndex: number;
  81229. /**
  81230. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81231. */
  81232. isVisible: boolean;
  81233. /**
  81234. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81235. */
  81236. isPickable: boolean;
  81237. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81238. showSubMeshesBoundingBox: boolean;
  81239. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81240. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81241. */
  81242. isBlocker: boolean;
  81243. /**
  81244. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81245. */
  81246. enablePointerMoveEvents: boolean;
  81247. /**
  81248. * Specifies the rendering group id for this mesh (0 by default)
  81249. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81250. */
  81251. renderingGroupId: number;
  81252. private _material;
  81253. /** Gets or sets current material */
  81254. material: Nullable<Material>;
  81255. private _receiveShadows;
  81256. /**
  81257. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81258. * @see http://doc.babylonjs.com/babylon101/shadows
  81259. */
  81260. receiveShadows: boolean;
  81261. /** Defines color to use when rendering outline */
  81262. outlineColor: Color3;
  81263. /** Define width to use when rendering outline */
  81264. outlineWidth: number;
  81265. /** Defines color to use when rendering overlay */
  81266. overlayColor: Color3;
  81267. /** Defines alpha to use when rendering overlay */
  81268. overlayAlpha: number;
  81269. private _hasVertexAlpha;
  81270. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81271. hasVertexAlpha: boolean;
  81272. private _useVertexColors;
  81273. /** 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) */
  81274. useVertexColors: boolean;
  81275. private _computeBonesUsingShaders;
  81276. /**
  81277. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81278. */
  81279. computeBonesUsingShaders: boolean;
  81280. private _numBoneInfluencers;
  81281. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81282. numBoneInfluencers: number;
  81283. private _applyFog;
  81284. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81285. applyFog: boolean;
  81286. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81287. useOctreeForRenderingSelection: boolean;
  81288. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81289. useOctreeForPicking: boolean;
  81290. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81291. useOctreeForCollisions: boolean;
  81292. private _layerMask;
  81293. /**
  81294. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81295. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81296. */
  81297. layerMask: number;
  81298. /**
  81299. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81300. */
  81301. alwaysSelectAsActiveMesh: boolean;
  81302. /**
  81303. * Gets or sets the current action manager
  81304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81305. */
  81306. actionManager: Nullable<AbstractActionManager>;
  81307. private _checkCollisions;
  81308. private _collisionMask;
  81309. private _collisionGroup;
  81310. /**
  81311. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81313. */
  81314. ellipsoid: Vector3;
  81315. /**
  81316. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81318. */
  81319. ellipsoidOffset: Vector3;
  81320. private _collider;
  81321. private _oldPositionForCollisions;
  81322. private _diffPositionForCollisions;
  81323. /**
  81324. * Gets or sets a collision mask used to mask collisions (default is -1).
  81325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81326. */
  81327. collisionMask: number;
  81328. /**
  81329. * Gets or sets the current collision group mask (-1 by default).
  81330. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81331. */
  81332. collisionGroup: number;
  81333. /**
  81334. * Defines edge width used when edgesRenderer is enabled
  81335. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81336. */
  81337. edgesWidth: number;
  81338. /**
  81339. * Defines edge color used when edgesRenderer is enabled
  81340. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81341. */
  81342. edgesColor: Color4;
  81343. /** @hidden */
  81344. _edgesRenderer: Nullable<IEdgesRenderer>;
  81345. /** @hidden */
  81346. _masterMesh: Nullable<AbstractMesh>;
  81347. /** @hidden */
  81348. _boundingInfo: Nullable<BoundingInfo>;
  81349. /** @hidden */
  81350. _renderId: number;
  81351. /**
  81352. * Gets or sets the list of subMeshes
  81353. * @see http://doc.babylonjs.com/how_to/multi_materials
  81354. */
  81355. subMeshes: SubMesh[];
  81356. /** @hidden */
  81357. _intersectionsInProgress: AbstractMesh[];
  81358. /** @hidden */
  81359. _unIndexed: boolean;
  81360. /** @hidden */
  81361. _lightSources: Light[];
  81362. /** @hidden */
  81363. readonly _positions: Nullable<Vector3[]>;
  81364. /** @hidden */
  81365. _waitingActions: any;
  81366. /** @hidden */
  81367. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81368. private _skeleton;
  81369. /** @hidden */
  81370. _bonesTransformMatrices: Nullable<Float32Array>;
  81371. /**
  81372. * Gets or sets a skeleton to apply skining transformations
  81373. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81374. */
  81375. skeleton: Nullable<Skeleton>;
  81376. /**
  81377. * An event triggered when the mesh is rebuilt.
  81378. */
  81379. onRebuildObservable: Observable<AbstractMesh>;
  81380. /**
  81381. * Creates a new AbstractMesh
  81382. * @param name defines the name of the mesh
  81383. * @param scene defines the hosting scene
  81384. */
  81385. constructor(name: string, scene?: Nullable<Scene>);
  81386. /**
  81387. * Returns the string "AbstractMesh"
  81388. * @returns "AbstractMesh"
  81389. */
  81390. getClassName(): string;
  81391. /**
  81392. * Gets a string representation of the current mesh
  81393. * @param fullDetails defines a boolean indicating if full details must be included
  81394. * @returns a string representation of the current mesh
  81395. */
  81396. toString(fullDetails?: boolean): string;
  81397. /** @hidden */
  81398. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81399. /** @hidden */
  81400. _rebuild(): void;
  81401. /** @hidden */
  81402. _resyncLightSources(): void;
  81403. /** @hidden */
  81404. _resyncLighSource(light: Light): void;
  81405. /** @hidden */
  81406. _unBindEffect(): void;
  81407. /** @hidden */
  81408. _removeLightSource(light: Light): void;
  81409. private _markSubMeshesAsDirty;
  81410. /** @hidden */
  81411. _markSubMeshesAsLightDirty(): void;
  81412. /** @hidden */
  81413. _markSubMeshesAsAttributesDirty(): void;
  81414. /** @hidden */
  81415. _markSubMeshesAsMiscDirty(): void;
  81416. /**
  81417. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81418. */
  81419. scaling: Vector3;
  81420. /**
  81421. * Returns true if the mesh is blocked. Implemented by child classes
  81422. */
  81423. readonly isBlocked: boolean;
  81424. /**
  81425. * Returns the mesh itself by default. Implemented by child classes
  81426. * @param camera defines the camera to use to pick the right LOD level
  81427. * @returns the currentAbstractMesh
  81428. */
  81429. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81430. /**
  81431. * Returns 0 by default. Implemented by child classes
  81432. * @returns an integer
  81433. */
  81434. getTotalVertices(): number;
  81435. /**
  81436. * Returns a positive integer : the total number of indices in this mesh geometry.
  81437. * @returns the numner of indices or zero if the mesh has no geometry.
  81438. */
  81439. getTotalIndices(): number;
  81440. /**
  81441. * Returns null by default. Implemented by child classes
  81442. * @returns null
  81443. */
  81444. getIndices(): Nullable<IndicesArray>;
  81445. /**
  81446. * Returns the array of the requested vertex data kind. Implemented by child classes
  81447. * @param kind defines the vertex data kind to use
  81448. * @returns null
  81449. */
  81450. getVerticesData(kind: string): Nullable<FloatArray>;
  81451. /**
  81452. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81453. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81454. * Note that a new underlying VertexBuffer object is created each call.
  81455. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81456. * @param kind defines vertex data kind:
  81457. * * VertexBuffer.PositionKind
  81458. * * VertexBuffer.UVKind
  81459. * * VertexBuffer.UV2Kind
  81460. * * VertexBuffer.UV3Kind
  81461. * * VertexBuffer.UV4Kind
  81462. * * VertexBuffer.UV5Kind
  81463. * * VertexBuffer.UV6Kind
  81464. * * VertexBuffer.ColorKind
  81465. * * VertexBuffer.MatricesIndicesKind
  81466. * * VertexBuffer.MatricesIndicesExtraKind
  81467. * * VertexBuffer.MatricesWeightsKind
  81468. * * VertexBuffer.MatricesWeightsExtraKind
  81469. * @param data defines the data source
  81470. * @param updatable defines if the data must be flagged as updatable (or static)
  81471. * @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
  81472. * @returns the current mesh
  81473. */
  81474. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81475. /**
  81476. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81477. * If the mesh has no geometry, it is simply returned as it is.
  81478. * @param kind defines vertex data kind:
  81479. * * VertexBuffer.PositionKind
  81480. * * VertexBuffer.UVKind
  81481. * * VertexBuffer.UV2Kind
  81482. * * VertexBuffer.UV3Kind
  81483. * * VertexBuffer.UV4Kind
  81484. * * VertexBuffer.UV5Kind
  81485. * * VertexBuffer.UV6Kind
  81486. * * VertexBuffer.ColorKind
  81487. * * VertexBuffer.MatricesIndicesKind
  81488. * * VertexBuffer.MatricesIndicesExtraKind
  81489. * * VertexBuffer.MatricesWeightsKind
  81490. * * VertexBuffer.MatricesWeightsExtraKind
  81491. * @param data defines the data source
  81492. * @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
  81493. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81494. * @returns the current mesh
  81495. */
  81496. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81497. /**
  81498. * Sets the mesh indices,
  81499. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81500. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81501. * @param totalVertices Defines the total number of vertices
  81502. * @returns the current mesh
  81503. */
  81504. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81505. /**
  81506. * Gets a boolean indicating if specific vertex data is present
  81507. * @param kind defines the vertex data kind to use
  81508. * @returns true is data kind is present
  81509. */
  81510. isVerticesDataPresent(kind: string): boolean;
  81511. /**
  81512. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81513. * @returns a BoundingInfo
  81514. */
  81515. getBoundingInfo(): BoundingInfo;
  81516. /**
  81517. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81518. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81519. * @returns the current mesh
  81520. */
  81521. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81522. /**
  81523. * Overwrite the current bounding info
  81524. * @param boundingInfo defines the new bounding info
  81525. * @returns the current mesh
  81526. */
  81527. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81528. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81529. readonly useBones: boolean;
  81530. /** @hidden */
  81531. _preActivate(): void;
  81532. /** @hidden */
  81533. _preActivateForIntermediateRendering(renderId: number): void;
  81534. /** @hidden */
  81535. _activate(renderId: number): void;
  81536. /**
  81537. * Gets the current world matrix
  81538. * @returns a Matrix
  81539. */
  81540. getWorldMatrix(): Matrix;
  81541. /** @hidden */
  81542. _getWorldMatrixDeterminant(): number;
  81543. /**
  81544. * Perform relative position change from the point of view of behind the front of the mesh.
  81545. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81546. * Supports definition of mesh facing forward or backward
  81547. * @param amountRight defines the distance on the right axis
  81548. * @param amountUp defines the distance on the up axis
  81549. * @param amountForward defines the distance on the forward axis
  81550. * @returns the current mesh
  81551. */
  81552. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81553. /**
  81554. * Calculate relative position change from the point of view of behind the front of the mesh.
  81555. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81556. * Supports definition of mesh facing forward or backward
  81557. * @param amountRight defines the distance on the right axis
  81558. * @param amountUp defines the distance on the up axis
  81559. * @param amountForward defines the distance on the forward axis
  81560. * @returns the new displacement vector
  81561. */
  81562. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81563. /**
  81564. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81565. * Supports definition of mesh facing forward or backward
  81566. * @param flipBack defines the flip
  81567. * @param twirlClockwise defines the twirl
  81568. * @param tiltRight defines the tilt
  81569. * @returns the current mesh
  81570. */
  81571. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81572. /**
  81573. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81574. * Supports definition of mesh facing forward or backward.
  81575. * @param flipBack defines the flip
  81576. * @param twirlClockwise defines the twirl
  81577. * @param tiltRight defines the tilt
  81578. * @returns the new rotation vector
  81579. */
  81580. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81581. /**
  81582. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81583. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81584. * @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
  81585. * @returns the new bounding vectors
  81586. */
  81587. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81588. min: Vector3;
  81589. max: Vector3;
  81590. };
  81591. /**
  81592. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81593. * This means the mesh underlying bounding box and sphere are recomputed.
  81594. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81595. * @returns the current mesh
  81596. */
  81597. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81598. /** @hidden */
  81599. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81600. /** @hidden */
  81601. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81602. /** @hidden */
  81603. _updateBoundingInfo(): AbstractMesh;
  81604. /** @hidden */
  81605. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81606. /** @hidden */
  81607. protected _afterComputeWorldMatrix(): void;
  81608. /**
  81609. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81610. * A mesh is in the frustum if its bounding box intersects the frustum
  81611. * @param frustumPlanes defines the frustum to test
  81612. * @returns true if the mesh is in the frustum planes
  81613. */
  81614. isInFrustum(frustumPlanes: Plane[]): boolean;
  81615. /**
  81616. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81617. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81618. * @param frustumPlanes defines the frustum to test
  81619. * @returns true if the mesh is completely in the frustum planes
  81620. */
  81621. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81622. /**
  81623. * True if the mesh intersects another mesh or a SolidParticle object
  81624. * @param mesh defines a target mesh or SolidParticle to test
  81625. * @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)
  81626. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81627. * @returns true if there is an intersection
  81628. */
  81629. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81630. /**
  81631. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81632. * @param point defines the point to test
  81633. * @returns true if there is an intersection
  81634. */
  81635. intersectsPoint(point: Vector3): boolean;
  81636. /**
  81637. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81639. */
  81640. checkCollisions: boolean;
  81641. /**
  81642. * Gets Collider object used to compute collisions (not physics)
  81643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81644. */
  81645. readonly collider: Collider;
  81646. /**
  81647. * Move the mesh using collision engine
  81648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81649. * @param displacement defines the requested displacement vector
  81650. * @returns the current mesh
  81651. */
  81652. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81653. private _onCollisionPositionChange;
  81654. /** @hidden */
  81655. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81656. /** @hidden */
  81657. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81658. /** @hidden */
  81659. _checkCollision(collider: Collider): AbstractMesh;
  81660. /** @hidden */
  81661. _generatePointsArray(): boolean;
  81662. /**
  81663. * Checks if the passed Ray intersects with the mesh
  81664. * @param ray defines the ray to use
  81665. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81666. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81667. * @returns the picking info
  81668. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81669. */
  81670. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81671. /**
  81672. * Clones the current mesh
  81673. * @param name defines the mesh name
  81674. * @param newParent defines the new mesh parent
  81675. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81676. * @returns the new mesh
  81677. */
  81678. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81679. /**
  81680. * Disposes all the submeshes of the current meshnp
  81681. * @returns the current mesh
  81682. */
  81683. releaseSubMeshes(): AbstractMesh;
  81684. /**
  81685. * Releases resources associated with this abstract mesh.
  81686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81688. */
  81689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81690. /**
  81691. * Adds the passed mesh as a child to the current mesh
  81692. * @param mesh defines the child mesh
  81693. * @returns the current mesh
  81694. */
  81695. addChild(mesh: AbstractMesh): AbstractMesh;
  81696. /**
  81697. * Removes the passed mesh from the current mesh children list
  81698. * @param mesh defines the child mesh
  81699. * @returns the current mesh
  81700. */
  81701. removeChild(mesh: AbstractMesh): AbstractMesh;
  81702. /** @hidden */
  81703. private _initFacetData;
  81704. /**
  81705. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81706. * This method can be called within the render loop.
  81707. * 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
  81708. * @returns the current mesh
  81709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81710. */
  81711. updateFacetData(): AbstractMesh;
  81712. /**
  81713. * Returns the facetLocalNormals array.
  81714. * The normals are expressed in the mesh local spac
  81715. * @returns an array of Vector3
  81716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81717. */
  81718. getFacetLocalNormals(): Vector3[];
  81719. /**
  81720. * Returns the facetLocalPositions array.
  81721. * The facet positions are expressed in the mesh local space
  81722. * @returns an array of Vector3
  81723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81724. */
  81725. getFacetLocalPositions(): Vector3[];
  81726. /**
  81727. * Returns the facetLocalPartioning array
  81728. * @returns an array of array of numbers
  81729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81730. */
  81731. getFacetLocalPartitioning(): number[][];
  81732. /**
  81733. * Returns the i-th facet position in the world system.
  81734. * This method allocates a new Vector3 per call
  81735. * @param i defines the facet index
  81736. * @returns a new Vector3
  81737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81738. */
  81739. getFacetPosition(i: number): Vector3;
  81740. /**
  81741. * Sets the reference Vector3 with the i-th facet position in the world system
  81742. * @param i defines the facet index
  81743. * @param ref defines the target vector
  81744. * @returns the current mesh
  81745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81746. */
  81747. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81748. /**
  81749. * Returns the i-th facet normal in the world system.
  81750. * This method allocates a new Vector3 per call
  81751. * @param i defines the facet index
  81752. * @returns a new Vector3
  81753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81754. */
  81755. getFacetNormal(i: number): Vector3;
  81756. /**
  81757. * Sets the reference Vector3 with the i-th facet normal in the world system
  81758. * @param i defines the facet index
  81759. * @param ref defines the target vector
  81760. * @returns the current mesh
  81761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81762. */
  81763. getFacetNormalToRef(i: number, ref: Vector3): this;
  81764. /**
  81765. * 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)
  81766. * @param x defines x coordinate
  81767. * @param y defines y coordinate
  81768. * @param z defines z coordinate
  81769. * @returns the array of facet indexes
  81770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81771. */
  81772. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81773. /**
  81774. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81775. * @param projected sets as the (x,y,z) world projection on the facet
  81776. * @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
  81777. * @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
  81778. * @param x defines x coordinate
  81779. * @param y defines y coordinate
  81780. * @param z defines z coordinate
  81781. * @returns the face index if found (or null instead)
  81782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81783. */
  81784. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81785. /**
  81786. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81787. * @param projected sets as the (x,y,z) local projection on the facet
  81788. * @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
  81789. * @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
  81790. * @param x defines x coordinate
  81791. * @param y defines y coordinate
  81792. * @param z defines z coordinate
  81793. * @returns the face index if found (or null instead)
  81794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81795. */
  81796. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81797. /**
  81798. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81799. * @returns the parameters
  81800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81801. */
  81802. getFacetDataParameters(): any;
  81803. /**
  81804. * Disables the feature FacetData and frees the related memory
  81805. * @returns the current mesh
  81806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81807. */
  81808. disableFacetData(): AbstractMesh;
  81809. /**
  81810. * Updates the AbstractMesh indices array
  81811. * @param indices defines the data source
  81812. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81813. * @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)
  81814. * @returns the current mesh
  81815. */
  81816. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  81817. /**
  81818. * Creates new normals data for the mesh
  81819. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81820. * @returns the current mesh
  81821. */
  81822. createNormals(updatable: boolean): AbstractMesh;
  81823. /**
  81824. * Align the mesh with a normal
  81825. * @param normal defines the normal to use
  81826. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81827. * @returns the current mesh
  81828. */
  81829. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81830. /** @hidden */
  81831. _checkOcclusionQuery(): boolean;
  81832. }
  81833. }
  81834. declare module BABYLON {
  81835. /**
  81836. * Interface used to define ActionEvent
  81837. */
  81838. export interface IActionEvent {
  81839. /** The mesh or sprite that triggered the action */
  81840. source: any;
  81841. /** The X mouse cursor position at the time of the event */
  81842. pointerX: number;
  81843. /** The Y mouse cursor position at the time of the event */
  81844. pointerY: number;
  81845. /** The mesh that is currently pointed at (can be null) */
  81846. meshUnderPointer: Nullable<AbstractMesh>;
  81847. /** the original (browser) event that triggered the ActionEvent */
  81848. sourceEvent?: any;
  81849. /** additional data for the event */
  81850. additionalData?: any;
  81851. }
  81852. /**
  81853. * ActionEvent is the event being sent when an action is triggered.
  81854. */
  81855. export class ActionEvent implements IActionEvent {
  81856. /** The mesh or sprite that triggered the action */
  81857. source: any;
  81858. /** The X mouse cursor position at the time of the event */
  81859. pointerX: number;
  81860. /** The Y mouse cursor position at the time of the event */
  81861. pointerY: number;
  81862. /** The mesh that is currently pointed at (can be null) */
  81863. meshUnderPointer: Nullable<AbstractMesh>;
  81864. /** the original (browser) event that triggered the ActionEvent */
  81865. sourceEvent?: any;
  81866. /** additional data for the event */
  81867. additionalData?: any;
  81868. /**
  81869. * Creates a new ActionEvent
  81870. * @param source The mesh or sprite that triggered the action
  81871. * @param pointerX The X mouse cursor position at the time of the event
  81872. * @param pointerY The Y mouse cursor position at the time of the event
  81873. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81874. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81875. * @param additionalData additional data for the event
  81876. */
  81877. constructor(
  81878. /** The mesh or sprite that triggered the action */
  81879. source: any,
  81880. /** The X mouse cursor position at the time of the event */
  81881. pointerX: number,
  81882. /** The Y mouse cursor position at the time of the event */
  81883. pointerY: number,
  81884. /** The mesh that is currently pointed at (can be null) */
  81885. meshUnderPointer: Nullable<AbstractMesh>,
  81886. /** the original (browser) event that triggered the ActionEvent */
  81887. sourceEvent?: any,
  81888. /** additional data for the event */
  81889. additionalData?: any);
  81890. /**
  81891. * Helper function to auto-create an ActionEvent from a source mesh.
  81892. * @param source The source mesh that triggered the event
  81893. * @param evt The original (browser) event
  81894. * @param additionalData additional data for the event
  81895. * @returns the new ActionEvent
  81896. */
  81897. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81898. /**
  81899. * Helper function to auto-create an ActionEvent from a source sprite
  81900. * @param source The source sprite that triggered the event
  81901. * @param scene Scene associated with the sprite
  81902. * @param evt The original (browser) event
  81903. * @param additionalData additional data for the event
  81904. * @returns the new ActionEvent
  81905. */
  81906. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81907. /**
  81908. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81909. * @param scene the scene where the event occurred
  81910. * @param evt The original (browser) event
  81911. * @returns the new ActionEvent
  81912. */
  81913. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81914. /**
  81915. * Helper function to auto-create an ActionEvent from a primitive
  81916. * @param prim defines the target primitive
  81917. * @param pointerPos defines the pointer position
  81918. * @param evt The original (browser) event
  81919. * @param additionalData additional data for the event
  81920. * @returns the new ActionEvent
  81921. */
  81922. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81923. }
  81924. }
  81925. declare module BABYLON {
  81926. /**
  81927. * Abstract class used to decouple action Manager from scene and meshes.
  81928. * Do not instantiate.
  81929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81930. */
  81931. export abstract class AbstractActionManager implements IDisposable {
  81932. /** Gets the list of active triggers */
  81933. static Triggers: {
  81934. [key: string]: number;
  81935. };
  81936. /** Gets the cursor to use when hovering items */
  81937. hoverCursor: string;
  81938. /** Gets the list of actions */
  81939. actions: IAction[];
  81940. /**
  81941. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81942. */
  81943. isRecursive: boolean;
  81944. /**
  81945. * Releases all associated resources
  81946. */
  81947. abstract dispose(): void;
  81948. /**
  81949. * Does this action manager has pointer triggers
  81950. */
  81951. abstract readonly hasPointerTriggers: boolean;
  81952. /**
  81953. * Does this action manager has pick triggers
  81954. */
  81955. abstract readonly hasPickTriggers: boolean;
  81956. /**
  81957. * Process a specific trigger
  81958. * @param trigger defines the trigger to process
  81959. * @param evt defines the event details to be processed
  81960. */
  81961. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81962. /**
  81963. * Does this action manager handles actions of any of the given triggers
  81964. * @param triggers defines the triggers to be tested
  81965. * @return a boolean indicating whether one (or more) of the triggers is handled
  81966. */
  81967. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81968. /**
  81969. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81970. * speed.
  81971. * @param triggerA defines the trigger to be tested
  81972. * @param triggerB defines the trigger to be tested
  81973. * @return a boolean indicating whether one (or more) of the triggers is handled
  81974. */
  81975. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81976. /**
  81977. * Does this action manager handles actions of a given trigger
  81978. * @param trigger defines the trigger to be tested
  81979. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81980. * @return whether the trigger is handled
  81981. */
  81982. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81983. /**
  81984. * Serialize this manager to a JSON object
  81985. * @param name defines the property name to store this manager
  81986. * @returns a JSON representation of this manager
  81987. */
  81988. abstract serialize(name: string): any;
  81989. /**
  81990. * Registers an action to this action manager
  81991. * @param action defines the action to be registered
  81992. * @return the action amended (prepared) after registration
  81993. */
  81994. abstract registerAction(action: IAction): Nullable<IAction>;
  81995. /**
  81996. * Unregisters an action to this action manager
  81997. * @param action defines the action to be unregistered
  81998. * @return a boolean indicating whether the action has been unregistered
  81999. */
  82000. abstract unregisterAction(action: IAction): Boolean;
  82001. /**
  82002. * Does exist one action manager with at least one trigger
  82003. **/
  82004. static readonly HasTriggers: boolean;
  82005. /**
  82006. * Does exist one action manager with at least one pick trigger
  82007. **/
  82008. static readonly HasPickTriggers: boolean;
  82009. /**
  82010. * Does exist one action manager that handles actions of a given trigger
  82011. * @param trigger defines the trigger to be tested
  82012. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  82013. **/
  82014. static HasSpecificTrigger(trigger: number): boolean;
  82015. }
  82016. }
  82017. declare module BABYLON {
  82018. /**
  82019. * Defines how a node can be built from a string name.
  82020. */
  82021. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  82022. /**
  82023. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  82024. */
  82025. export class Node implements IBehaviorAware<Node> {
  82026. /** @hidden */
  82027. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  82028. private static _NodeConstructors;
  82029. /**
  82030. * Add a new node constructor
  82031. * @param type defines the type name of the node to construct
  82032. * @param constructorFunc defines the constructor function
  82033. */
  82034. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  82035. /**
  82036. * Returns a node constructor based on type name
  82037. * @param type defines the type name
  82038. * @param name defines the new node name
  82039. * @param scene defines the hosting scene
  82040. * @param options defines optional options to transmit to constructors
  82041. * @returns the new constructor or null
  82042. */
  82043. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  82044. /**
  82045. * Gets or sets the name of the node
  82046. */
  82047. name: string;
  82048. /**
  82049. * Gets or sets the id of the node
  82050. */
  82051. id: string;
  82052. /**
  82053. * Gets or sets the unique id of the node
  82054. */
  82055. uniqueId: number;
  82056. /**
  82057. * Gets or sets a string used to store user defined state for the node
  82058. */
  82059. state: string;
  82060. /**
  82061. * Gets or sets an object used to store user defined information for the node
  82062. */
  82063. metadata: any;
  82064. /**
  82065. * For internal use only. Please do not use.
  82066. */
  82067. reservedDataStore: any;
  82068. /**
  82069. * Gets or sets a boolean used to define if the node must be serialized
  82070. */
  82071. doNotSerialize: boolean;
  82072. /** @hidden */
  82073. _isDisposed: boolean;
  82074. /**
  82075. * Gets a list of Animations associated with the node
  82076. */
  82077. animations: Animation[];
  82078. protected _ranges: {
  82079. [name: string]: Nullable<AnimationRange>;
  82080. };
  82081. /**
  82082. * Callback raised when the node is ready to be used
  82083. */
  82084. onReady: (node: Node) => void;
  82085. private _isEnabled;
  82086. private _isParentEnabled;
  82087. private _isReady;
  82088. /** @hidden */
  82089. _currentRenderId: number;
  82090. private _parentRenderId;
  82091. protected _childRenderId: number;
  82092. /** @hidden */
  82093. _waitingParentId: Nullable<string>;
  82094. /** @hidden */
  82095. _scene: Scene;
  82096. /** @hidden */
  82097. _cache: any;
  82098. private _parentNode;
  82099. private _children;
  82100. /** @hidden */
  82101. _worldMatrix: Matrix;
  82102. /** @hidden */
  82103. _worldMatrixDeterminant: number;
  82104. /** @hidden */
  82105. private _sceneRootNodesIndex;
  82106. /**
  82107. * Gets a boolean indicating if the node has been disposed
  82108. * @returns true if the node was disposed
  82109. */
  82110. isDisposed(): boolean;
  82111. /**
  82112. * Gets or sets the parent of the node
  82113. */
  82114. parent: Nullable<Node>;
  82115. private addToSceneRootNodes;
  82116. private removeFromSceneRootNodes;
  82117. private _animationPropertiesOverride;
  82118. /**
  82119. * Gets or sets the animation properties override
  82120. */
  82121. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82122. /**
  82123. * Gets a string idenfifying the name of the class
  82124. * @returns "Node" string
  82125. */
  82126. getClassName(): string;
  82127. /** @hidden */
  82128. readonly _isNode: boolean;
  82129. /**
  82130. * An event triggered when the mesh is disposed
  82131. */
  82132. onDisposeObservable: Observable<Node>;
  82133. private _onDisposeObserver;
  82134. /**
  82135. * Sets a callback that will be raised when the node will be disposed
  82136. */
  82137. onDispose: () => void;
  82138. /**
  82139. * Creates a new Node
  82140. * @param name the name and id to be given to this node
  82141. * @param scene the scene this node will be added to
  82142. * @param addToRootNodes the node will be added to scene.rootNodes
  82143. */
  82144. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  82145. /**
  82146. * Gets the scene of the node
  82147. * @returns a scene
  82148. */
  82149. getScene(): Scene;
  82150. /**
  82151. * Gets the engine of the node
  82152. * @returns a Engine
  82153. */
  82154. getEngine(): Engine;
  82155. private _behaviors;
  82156. /**
  82157. * Attach a behavior to the node
  82158. * @see http://doc.babylonjs.com/features/behaviour
  82159. * @param behavior defines the behavior to attach
  82160. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  82161. * @returns the current Node
  82162. */
  82163. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  82164. /**
  82165. * Remove an attached behavior
  82166. * @see http://doc.babylonjs.com/features/behaviour
  82167. * @param behavior defines the behavior to attach
  82168. * @returns the current Node
  82169. */
  82170. removeBehavior(behavior: Behavior<Node>): Node;
  82171. /**
  82172. * Gets the list of attached behaviors
  82173. * @see http://doc.babylonjs.com/features/behaviour
  82174. */
  82175. readonly behaviors: Behavior<Node>[];
  82176. /**
  82177. * Gets an attached behavior by name
  82178. * @param name defines the name of the behavior to look for
  82179. * @see http://doc.babylonjs.com/features/behaviour
  82180. * @returns null if behavior was not found else the requested behavior
  82181. */
  82182. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  82183. /**
  82184. * Returns the latest update of the World matrix
  82185. * @returns a Matrix
  82186. */
  82187. getWorldMatrix(): Matrix;
  82188. /** @hidden */
  82189. _getWorldMatrixDeterminant(): number;
  82190. /**
  82191. * Returns directly the latest state of the mesh World matrix.
  82192. * A Matrix is returned.
  82193. */
  82194. readonly worldMatrixFromCache: Matrix;
  82195. /** @hidden */
  82196. _initCache(): void;
  82197. /** @hidden */
  82198. updateCache(force?: boolean): void;
  82199. /** @hidden */
  82200. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82201. /** @hidden */
  82202. _updateCache(ignoreParentClass?: boolean): void;
  82203. /** @hidden */
  82204. _isSynchronized(): boolean;
  82205. /** @hidden */
  82206. _markSyncedWithParent(): void;
  82207. /** @hidden */
  82208. isSynchronizedWithParent(): boolean;
  82209. /** @hidden */
  82210. isSynchronized(): boolean;
  82211. /**
  82212. * Is this node ready to be used/rendered
  82213. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82214. * @return true if the node is ready
  82215. */
  82216. isReady(completeCheck?: boolean): boolean;
  82217. /**
  82218. * Is this node enabled?
  82219. * 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
  82220. * @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
  82221. * @return whether this node (and its parent) is enabled
  82222. */
  82223. isEnabled(checkAncestors?: boolean): boolean;
  82224. /** @hidden */
  82225. protected _syncParentEnabledState(): void;
  82226. /**
  82227. * Set the enabled state of this node
  82228. * @param value defines the new enabled state
  82229. */
  82230. setEnabled(value: boolean): void;
  82231. /**
  82232. * Is this node a descendant of the given node?
  82233. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82234. * @param ancestor defines the parent node to inspect
  82235. * @returns a boolean indicating if this node is a descendant of the given node
  82236. */
  82237. isDescendantOf(ancestor: Node): boolean;
  82238. /** @hidden */
  82239. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82240. /**
  82241. * Will return all nodes that have this node as ascendant
  82242. * @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
  82243. * @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
  82244. * @return all children nodes of all types
  82245. */
  82246. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82247. /**
  82248. * Get all child-meshes of this node
  82249. * @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)
  82250. * @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
  82251. * @returns an array of AbstractMesh
  82252. */
  82253. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82254. /**
  82255. * Get all direct children of this node
  82256. * @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
  82257. * @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)
  82258. * @returns an array of Node
  82259. */
  82260. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82261. /** @hidden */
  82262. _setReady(state: boolean): void;
  82263. /**
  82264. * Get an animation by name
  82265. * @param name defines the name of the animation to look for
  82266. * @returns null if not found else the requested animation
  82267. */
  82268. getAnimationByName(name: string): Nullable<Animation>;
  82269. /**
  82270. * Creates an animation range for this node
  82271. * @param name defines the name of the range
  82272. * @param from defines the starting key
  82273. * @param to defines the end key
  82274. */
  82275. createAnimationRange(name: string, from: number, to: number): void;
  82276. /**
  82277. * Delete a specific animation range
  82278. * @param name defines the name of the range to delete
  82279. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82280. */
  82281. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82282. /**
  82283. * Get an animation range by name
  82284. * @param name defines the name of the animation range to look for
  82285. * @returns null if not found else the requested animation range
  82286. */
  82287. getAnimationRange(name: string): Nullable<AnimationRange>;
  82288. /**
  82289. * Gets the list of all animation ranges defined on this node
  82290. * @returns an array
  82291. */
  82292. getAnimationRanges(): Nullable<AnimationRange>[];
  82293. /**
  82294. * Will start the animation sequence
  82295. * @param name defines the range frames for animation sequence
  82296. * @param loop defines if the animation should loop (false by default)
  82297. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82298. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82299. * @returns the object created for this animation. If range does not exist, it will return null
  82300. */
  82301. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82302. /**
  82303. * Serialize animation ranges into a JSON compatible object
  82304. * @returns serialization object
  82305. */
  82306. serializeAnimationRanges(): any;
  82307. /**
  82308. * Computes the world matrix of the node
  82309. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82310. * @returns the world matrix
  82311. */
  82312. computeWorldMatrix(force?: boolean): Matrix;
  82313. /**
  82314. * Releases resources associated with this node.
  82315. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82316. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82317. */
  82318. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82319. /**
  82320. * Parse animation range data from a serialization object and store them into a given node
  82321. * @param node defines where to store the animation ranges
  82322. * @param parsedNode defines the serialization object to read data from
  82323. * @param scene defines the hosting scene
  82324. */
  82325. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82326. }
  82327. }
  82328. declare module BABYLON {
  82329. /**
  82330. * Class used to store any kind of animation
  82331. */
  82332. export class Animation {
  82333. /**Name of the animation */
  82334. name: string;
  82335. /**Property to animate */
  82336. targetProperty: string;
  82337. /**The frames per second of the animation */
  82338. framePerSecond: number;
  82339. /**The data type of the animation */
  82340. dataType: number;
  82341. /**The loop mode of the animation */
  82342. loopMode?: number | undefined;
  82343. /**Specifies if blending should be enabled */
  82344. enableBlending?: boolean | undefined;
  82345. /**
  82346. * Use matrix interpolation instead of using direct key value when animating matrices
  82347. */
  82348. static AllowMatricesInterpolation: boolean;
  82349. /**
  82350. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82351. */
  82352. static AllowMatrixDecomposeForInterpolation: boolean;
  82353. /**
  82354. * Stores the key frames of the animation
  82355. */
  82356. private _keys;
  82357. /**
  82358. * Stores the easing function of the animation
  82359. */
  82360. private _easingFunction;
  82361. /**
  82362. * @hidden Internal use only
  82363. */
  82364. _runtimeAnimations: RuntimeAnimation[];
  82365. /**
  82366. * The set of event that will be linked to this animation
  82367. */
  82368. private _events;
  82369. /**
  82370. * Stores an array of target property paths
  82371. */
  82372. targetPropertyPath: string[];
  82373. /**
  82374. * Stores the blending speed of the animation
  82375. */
  82376. blendingSpeed: number;
  82377. /**
  82378. * Stores the animation ranges for the animation
  82379. */
  82380. private _ranges;
  82381. /**
  82382. * @hidden Internal use
  82383. */
  82384. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82385. /**
  82386. * Sets up an animation
  82387. * @param property The property to animate
  82388. * @param animationType The animation type to apply
  82389. * @param framePerSecond The frames per second of the animation
  82390. * @param easingFunction The easing function used in the animation
  82391. * @returns The created animation
  82392. */
  82393. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82394. /**
  82395. * Create and start an animation on a node
  82396. * @param name defines the name of the global animation that will be run on all nodes
  82397. * @param node defines the root node where the animation will take place
  82398. * @param targetProperty defines property to animate
  82399. * @param framePerSecond defines the number of frame per second yo use
  82400. * @param totalFrame defines the number of frames in total
  82401. * @param from defines the initial value
  82402. * @param to defines the final value
  82403. * @param loopMode defines which loop mode you want to use (off by default)
  82404. * @param easingFunction defines the easing function to use (linear by default)
  82405. * @param onAnimationEnd defines the callback to call when animation end
  82406. * @returns the animatable created for this animation
  82407. */
  82408. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82409. /**
  82410. * Create and start an animation on a node and its descendants
  82411. * @param name defines the name of the global animation that will be run on all nodes
  82412. * @param node defines the root node where the animation will take place
  82413. * @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
  82414. * @param targetProperty defines property to animate
  82415. * @param framePerSecond defines the number of frame per second to use
  82416. * @param totalFrame defines the number of frames in total
  82417. * @param from defines the initial value
  82418. * @param to defines the final value
  82419. * @param loopMode defines which loop mode you want to use (off by default)
  82420. * @param easingFunction defines the easing function to use (linear by default)
  82421. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82422. * @returns the list of animatables created for all nodes
  82423. * @example https://www.babylonjs-playground.com/#MH0VLI
  82424. */
  82425. 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[]>;
  82426. /**
  82427. * Creates a new animation, merges it with the existing animations and starts it
  82428. * @param name Name of the animation
  82429. * @param node Node which contains the scene that begins the animations
  82430. * @param targetProperty Specifies which property to animate
  82431. * @param framePerSecond The frames per second of the animation
  82432. * @param totalFrame The total number of frames
  82433. * @param from The frame at the beginning of the animation
  82434. * @param to The frame at the end of the animation
  82435. * @param loopMode Specifies the loop mode of the animation
  82436. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82437. * @param onAnimationEnd Callback to run once the animation is complete
  82438. * @returns Nullable animation
  82439. */
  82440. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82441. /**
  82442. * Transition property of an host to the target Value
  82443. * @param property The property to transition
  82444. * @param targetValue The target Value of the property
  82445. * @param host The object where the property to animate belongs
  82446. * @param scene Scene used to run the animation
  82447. * @param frameRate Framerate (in frame/s) to use
  82448. * @param transition The transition type we want to use
  82449. * @param duration The duration of the animation, in milliseconds
  82450. * @param onAnimationEnd Callback trigger at the end of the animation
  82451. * @returns Nullable animation
  82452. */
  82453. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82454. /**
  82455. * Return the array of runtime animations currently using this animation
  82456. */
  82457. readonly runtimeAnimations: RuntimeAnimation[];
  82458. /**
  82459. * Specifies if any of the runtime animations are currently running
  82460. */
  82461. readonly hasRunningRuntimeAnimations: boolean;
  82462. /**
  82463. * Initializes the animation
  82464. * @param name Name of the animation
  82465. * @param targetProperty Property to animate
  82466. * @param framePerSecond The frames per second of the animation
  82467. * @param dataType The data type of the animation
  82468. * @param loopMode The loop mode of the animation
  82469. * @param enableBlending Specifies if blending should be enabled
  82470. */
  82471. constructor(
  82472. /**Name of the animation */
  82473. name: string,
  82474. /**Property to animate */
  82475. targetProperty: string,
  82476. /**The frames per second of the animation */
  82477. framePerSecond: number,
  82478. /**The data type of the animation */
  82479. dataType: number,
  82480. /**The loop mode of the animation */
  82481. loopMode?: number | undefined,
  82482. /**Specifies if blending should be enabled */
  82483. enableBlending?: boolean | undefined);
  82484. /**
  82485. * Converts the animation to a string
  82486. * @param fullDetails support for multiple levels of logging within scene loading
  82487. * @returns String form of the animation
  82488. */
  82489. toString(fullDetails?: boolean): string;
  82490. /**
  82491. * Add an event to this animation
  82492. * @param event Event to add
  82493. */
  82494. addEvent(event: AnimationEvent): void;
  82495. /**
  82496. * Remove all events found at the given frame
  82497. * @param frame The frame to remove events from
  82498. */
  82499. removeEvents(frame: number): void;
  82500. /**
  82501. * Retrieves all the events from the animation
  82502. * @returns Events from the animation
  82503. */
  82504. getEvents(): AnimationEvent[];
  82505. /**
  82506. * Creates an animation range
  82507. * @param name Name of the animation range
  82508. * @param from Starting frame of the animation range
  82509. * @param to Ending frame of the animation
  82510. */
  82511. createRange(name: string, from: number, to: number): void;
  82512. /**
  82513. * Deletes an animation range by name
  82514. * @param name Name of the animation range to delete
  82515. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82516. */
  82517. deleteRange(name: string, deleteFrames?: boolean): void;
  82518. /**
  82519. * Gets the animation range by name, or null if not defined
  82520. * @param name Name of the animation range
  82521. * @returns Nullable animation range
  82522. */
  82523. getRange(name: string): Nullable<AnimationRange>;
  82524. /**
  82525. * Gets the key frames from the animation
  82526. * @returns The key frames of the animation
  82527. */
  82528. getKeys(): Array<IAnimationKey>;
  82529. /**
  82530. * Gets the highest frame rate of the animation
  82531. * @returns Highest frame rate of the animation
  82532. */
  82533. getHighestFrame(): number;
  82534. /**
  82535. * Gets the easing function of the animation
  82536. * @returns Easing function of the animation
  82537. */
  82538. getEasingFunction(): IEasingFunction;
  82539. /**
  82540. * Sets the easing function of the animation
  82541. * @param easingFunction A custom mathematical formula for animation
  82542. */
  82543. setEasingFunction(easingFunction: EasingFunction): void;
  82544. /**
  82545. * Interpolates a scalar linearly
  82546. * @param startValue Start value of the animation curve
  82547. * @param endValue End value of the animation curve
  82548. * @param gradient Scalar amount to interpolate
  82549. * @returns Interpolated scalar value
  82550. */
  82551. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82552. /**
  82553. * Interpolates a scalar cubically
  82554. * @param startValue Start value of the animation curve
  82555. * @param outTangent End tangent of the animation
  82556. * @param endValue End value of the animation curve
  82557. * @param inTangent Start tangent of the animation curve
  82558. * @param gradient Scalar amount to interpolate
  82559. * @returns Interpolated scalar value
  82560. */
  82561. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82562. /**
  82563. * Interpolates a quaternion using a spherical linear interpolation
  82564. * @param startValue Start value of the animation curve
  82565. * @param endValue End value of the animation curve
  82566. * @param gradient Scalar amount to interpolate
  82567. * @returns Interpolated quaternion value
  82568. */
  82569. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82570. /**
  82571. * Interpolates a quaternion cubically
  82572. * @param startValue Start value of the animation curve
  82573. * @param outTangent End tangent of the animation curve
  82574. * @param endValue End value of the animation curve
  82575. * @param inTangent Start tangent of the animation curve
  82576. * @param gradient Scalar amount to interpolate
  82577. * @returns Interpolated quaternion value
  82578. */
  82579. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82580. /**
  82581. * Interpolates a Vector3 linearl
  82582. * @param startValue Start value of the animation curve
  82583. * @param endValue End value of the animation curve
  82584. * @param gradient Scalar amount to interpolate
  82585. * @returns Interpolated scalar value
  82586. */
  82587. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82588. /**
  82589. * Interpolates a Vector3 cubically
  82590. * @param startValue Start value of the animation curve
  82591. * @param outTangent End tangent of the animation
  82592. * @param endValue End value of the animation curve
  82593. * @param inTangent Start tangent of the animation curve
  82594. * @param gradient Scalar amount to interpolate
  82595. * @returns InterpolatedVector3 value
  82596. */
  82597. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82598. /**
  82599. * Interpolates a Vector2 linearly
  82600. * @param startValue Start value of the animation curve
  82601. * @param endValue End value of the animation curve
  82602. * @param gradient Scalar amount to interpolate
  82603. * @returns Interpolated Vector2 value
  82604. */
  82605. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82606. /**
  82607. * Interpolates a Vector2 cubically
  82608. * @param startValue Start value of the animation curve
  82609. * @param outTangent End tangent of the animation
  82610. * @param endValue End value of the animation curve
  82611. * @param inTangent Start tangent of the animation curve
  82612. * @param gradient Scalar amount to interpolate
  82613. * @returns Interpolated Vector2 value
  82614. */
  82615. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82616. /**
  82617. * Interpolates a size linearly
  82618. * @param startValue Start value of the animation curve
  82619. * @param endValue End value of the animation curve
  82620. * @param gradient Scalar amount to interpolate
  82621. * @returns Interpolated Size value
  82622. */
  82623. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82624. /**
  82625. * Interpolates a Color3 linearly
  82626. * @param startValue Start value of the animation curve
  82627. * @param endValue End value of the animation curve
  82628. * @param gradient Scalar amount to interpolate
  82629. * @returns Interpolated Color3 value
  82630. */
  82631. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82632. /**
  82633. * @hidden Internal use only
  82634. */
  82635. _getKeyValue(value: any): any;
  82636. /**
  82637. * @hidden Internal use only
  82638. */
  82639. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82640. /**
  82641. * Defines the function to use to interpolate matrices
  82642. * @param startValue defines the start matrix
  82643. * @param endValue defines the end matrix
  82644. * @param gradient defines the gradient between both matrices
  82645. * @param result defines an optional target matrix where to store the interpolation
  82646. * @returns the interpolated matrix
  82647. */
  82648. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82649. /**
  82650. * Makes a copy of the animation
  82651. * @returns Cloned animation
  82652. */
  82653. clone(): Animation;
  82654. /**
  82655. * Sets the key frames of the animation
  82656. * @param values The animation key frames to set
  82657. */
  82658. setKeys(values: Array<IAnimationKey>): void;
  82659. /**
  82660. * Serializes the animation to an object
  82661. * @returns Serialized object
  82662. */
  82663. serialize(): any;
  82664. /**
  82665. * Float animation type
  82666. */
  82667. private static _ANIMATIONTYPE_FLOAT;
  82668. /**
  82669. * Vector3 animation type
  82670. */
  82671. private static _ANIMATIONTYPE_VECTOR3;
  82672. /**
  82673. * Quaternion animation type
  82674. */
  82675. private static _ANIMATIONTYPE_QUATERNION;
  82676. /**
  82677. * Matrix animation type
  82678. */
  82679. private static _ANIMATIONTYPE_MATRIX;
  82680. /**
  82681. * Color3 animation type
  82682. */
  82683. private static _ANIMATIONTYPE_COLOR3;
  82684. /**
  82685. * Vector2 animation type
  82686. */
  82687. private static _ANIMATIONTYPE_VECTOR2;
  82688. /**
  82689. * Size animation type
  82690. */
  82691. private static _ANIMATIONTYPE_SIZE;
  82692. /**
  82693. * Relative Loop Mode
  82694. */
  82695. private static _ANIMATIONLOOPMODE_RELATIVE;
  82696. /**
  82697. * Cycle Loop Mode
  82698. */
  82699. private static _ANIMATIONLOOPMODE_CYCLE;
  82700. /**
  82701. * Constant Loop Mode
  82702. */
  82703. private static _ANIMATIONLOOPMODE_CONSTANT;
  82704. /**
  82705. * Get the float animation type
  82706. */
  82707. static readonly ANIMATIONTYPE_FLOAT: number;
  82708. /**
  82709. * Get the Vector3 animation type
  82710. */
  82711. static readonly ANIMATIONTYPE_VECTOR3: number;
  82712. /**
  82713. * Get the Vector2 animation type
  82714. */
  82715. static readonly ANIMATIONTYPE_VECTOR2: number;
  82716. /**
  82717. * Get the Size animation type
  82718. */
  82719. static readonly ANIMATIONTYPE_SIZE: number;
  82720. /**
  82721. * Get the Quaternion animation type
  82722. */
  82723. static readonly ANIMATIONTYPE_QUATERNION: number;
  82724. /**
  82725. * Get the Matrix animation type
  82726. */
  82727. static readonly ANIMATIONTYPE_MATRIX: number;
  82728. /**
  82729. * Get the Color3 animation type
  82730. */
  82731. static readonly ANIMATIONTYPE_COLOR3: number;
  82732. /**
  82733. * Get the Relative Loop Mode
  82734. */
  82735. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82736. /**
  82737. * Get the Cycle Loop Mode
  82738. */
  82739. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82740. /**
  82741. * Get the Constant Loop Mode
  82742. */
  82743. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82744. /** @hidden */
  82745. static _UniversalLerp(left: any, right: any, amount: number): any;
  82746. /**
  82747. * Parses an animation object and creates an animation
  82748. * @param parsedAnimation Parsed animation object
  82749. * @returns Animation object
  82750. */
  82751. static Parse(parsedAnimation: any): Animation;
  82752. /**
  82753. * Appends the serialized animations from the source animations
  82754. * @param source Source containing the animations
  82755. * @param destination Target to store the animations
  82756. */
  82757. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82758. }
  82759. }
  82760. declare module BABYLON {
  82761. /**
  82762. * Base class of all the textures in babylon.
  82763. * It groups all the common properties the materials, post process, lights... might need
  82764. * in order to make a correct use of the texture.
  82765. */
  82766. export class BaseTexture implements IAnimatable {
  82767. /**
  82768. * Default anisotropic filtering level for the application.
  82769. * It is set to 4 as a good tradeoff between perf and quality.
  82770. */
  82771. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82772. /**
  82773. * Gets or sets the unique id of the texture
  82774. */
  82775. uniqueId: number;
  82776. /**
  82777. * Define the name of the texture.
  82778. */
  82779. name: string;
  82780. /**
  82781. * Gets or sets an object used to store user defined information.
  82782. */
  82783. metadata: any;
  82784. /**
  82785. * For internal use only. Please do not use.
  82786. */
  82787. reservedDataStore: any;
  82788. private _hasAlpha;
  82789. /**
  82790. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82791. */
  82792. hasAlpha: boolean;
  82793. /**
  82794. * Defines if the alpha value should be determined via the rgb values.
  82795. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82796. */
  82797. getAlphaFromRGB: boolean;
  82798. /**
  82799. * Intensity or strength of the texture.
  82800. * It is commonly used by materials to fine tune the intensity of the texture
  82801. */
  82802. level: number;
  82803. /**
  82804. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82805. * This is part of the texture as textures usually maps to one uv set.
  82806. */
  82807. coordinatesIndex: number;
  82808. private _coordinatesMode;
  82809. /**
  82810. * How a texture is mapped.
  82811. *
  82812. * | Value | Type | Description |
  82813. * | ----- | ----------------------------------- | ----------- |
  82814. * | 0 | EXPLICIT_MODE | |
  82815. * | 1 | SPHERICAL_MODE | |
  82816. * | 2 | PLANAR_MODE | |
  82817. * | 3 | CUBIC_MODE | |
  82818. * | 4 | PROJECTION_MODE | |
  82819. * | 5 | SKYBOX_MODE | |
  82820. * | 6 | INVCUBIC_MODE | |
  82821. * | 7 | EQUIRECTANGULAR_MODE | |
  82822. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82823. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82824. */
  82825. coordinatesMode: number;
  82826. /**
  82827. * | Value | Type | Description |
  82828. * | ----- | ------------------ | ----------- |
  82829. * | 0 | CLAMP_ADDRESSMODE | |
  82830. * | 1 | WRAP_ADDRESSMODE | |
  82831. * | 2 | MIRROR_ADDRESSMODE | |
  82832. */
  82833. wrapU: number;
  82834. /**
  82835. * | Value | Type | Description |
  82836. * | ----- | ------------------ | ----------- |
  82837. * | 0 | CLAMP_ADDRESSMODE | |
  82838. * | 1 | WRAP_ADDRESSMODE | |
  82839. * | 2 | MIRROR_ADDRESSMODE | |
  82840. */
  82841. wrapV: number;
  82842. /**
  82843. * | Value | Type | Description |
  82844. * | ----- | ------------------ | ----------- |
  82845. * | 0 | CLAMP_ADDRESSMODE | |
  82846. * | 1 | WRAP_ADDRESSMODE | |
  82847. * | 2 | MIRROR_ADDRESSMODE | |
  82848. */
  82849. wrapR: number;
  82850. /**
  82851. * With compliant hardware and browser (supporting anisotropic filtering)
  82852. * this defines the level of anisotropic filtering in the texture.
  82853. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82854. */
  82855. anisotropicFilteringLevel: number;
  82856. /**
  82857. * Define if the texture is a cube texture or if false a 2d texture.
  82858. */
  82859. isCube: boolean;
  82860. /**
  82861. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82862. */
  82863. is3D: boolean;
  82864. /**
  82865. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82866. * HDR texture are usually stored in linear space.
  82867. * This only impacts the PBR and Background materials
  82868. */
  82869. gammaSpace: boolean;
  82870. /**
  82871. * Gets whether or not the texture contains RGBD data.
  82872. */
  82873. readonly isRGBD: boolean;
  82874. /**
  82875. * Is Z inverted in the texture (useful in a cube texture).
  82876. */
  82877. invertZ: boolean;
  82878. /**
  82879. * Are mip maps generated for this texture or not.
  82880. */
  82881. readonly noMipmap: boolean;
  82882. /**
  82883. * @hidden
  82884. */
  82885. lodLevelInAlpha: boolean;
  82886. /**
  82887. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82888. */
  82889. lodGenerationOffset: number;
  82890. /**
  82891. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82892. */
  82893. lodGenerationScale: number;
  82894. /**
  82895. * Define if the texture is a render target.
  82896. */
  82897. isRenderTarget: boolean;
  82898. /**
  82899. * Define the unique id of the texture in the scene.
  82900. */
  82901. readonly uid: string;
  82902. /**
  82903. * Return a string representation of the texture.
  82904. * @returns the texture as a string
  82905. */
  82906. toString(): string;
  82907. /**
  82908. * Get the class name of the texture.
  82909. * @returns "BaseTexture"
  82910. */
  82911. getClassName(): string;
  82912. /**
  82913. * Define the list of animation attached to the texture.
  82914. */
  82915. animations: Animation[];
  82916. /**
  82917. * An event triggered when the texture is disposed.
  82918. */
  82919. onDisposeObservable: Observable<BaseTexture>;
  82920. private _onDisposeObserver;
  82921. /**
  82922. * Callback triggered when the texture has been disposed.
  82923. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82924. */
  82925. onDispose: () => void;
  82926. /**
  82927. * Define the current state of the loading sequence when in delayed load mode.
  82928. */
  82929. delayLoadState: number;
  82930. private _scene;
  82931. /** @hidden */
  82932. _texture: Nullable<InternalTexture>;
  82933. private _uid;
  82934. /**
  82935. * Define if the texture is preventinga material to render or not.
  82936. * If not and the texture is not ready, the engine will use a default black texture instead.
  82937. */
  82938. readonly isBlocking: boolean;
  82939. /**
  82940. * Instantiates a new BaseTexture.
  82941. * Base class of all the textures in babylon.
  82942. * It groups all the common properties the materials, post process, lights... might need
  82943. * in order to make a correct use of the texture.
  82944. * @param scene Define the scene the texture blongs to
  82945. */
  82946. constructor(scene: Nullable<Scene>);
  82947. /**
  82948. * Get the scene the texture belongs to.
  82949. * @returns the scene or null if undefined
  82950. */
  82951. getScene(): Nullable<Scene>;
  82952. /**
  82953. * Get the texture transform matrix used to offset tile the texture for istance.
  82954. * @returns the transformation matrix
  82955. */
  82956. getTextureMatrix(): Matrix;
  82957. /**
  82958. * Get the texture reflection matrix used to rotate/transform the reflection.
  82959. * @returns the reflection matrix
  82960. */
  82961. getReflectionTextureMatrix(): Matrix;
  82962. /**
  82963. * Get the underlying lower level texture from Babylon.
  82964. * @returns the insternal texture
  82965. */
  82966. getInternalTexture(): Nullable<InternalTexture>;
  82967. /**
  82968. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82969. * @returns true if ready or not blocking
  82970. */
  82971. isReadyOrNotBlocking(): boolean;
  82972. /**
  82973. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82974. * @returns true if fully ready
  82975. */
  82976. isReady(): boolean;
  82977. private _cachedSize;
  82978. /**
  82979. * Get the size of the texture.
  82980. * @returns the texture size.
  82981. */
  82982. getSize(): ISize;
  82983. /**
  82984. * Get the base size of the texture.
  82985. * It can be different from the size if the texture has been resized for POT for instance
  82986. * @returns the base size
  82987. */
  82988. getBaseSize(): ISize;
  82989. /**
  82990. * Update the sampling mode of the texture.
  82991. * Default is Trilinear mode.
  82992. *
  82993. * | Value | Type | Description |
  82994. * | ----- | ------------------ | ----------- |
  82995. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82996. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82997. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82998. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82999. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83000. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83001. * | 7 | NEAREST_LINEAR | |
  83002. * | 8 | NEAREST_NEAREST | |
  83003. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83004. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83005. * | 11 | LINEAR_LINEAR | |
  83006. * | 12 | LINEAR_NEAREST | |
  83007. *
  83008. * > _mag_: magnification filter (close to the viewer)
  83009. * > _min_: minification filter (far from the viewer)
  83010. * > _mip_: filter used between mip map levels
  83011. *@param samplingMode Define the new sampling mode of the texture
  83012. */
  83013. updateSamplingMode(samplingMode: number): void;
  83014. /**
  83015. * Scales the texture if is `canRescale()`
  83016. * @param ratio the resize factor we want to use to rescale
  83017. */
  83018. scale(ratio: number): void;
  83019. /**
  83020. * Get if the texture can rescale.
  83021. */
  83022. readonly canRescale: boolean;
  83023. /** @hidden */
  83024. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  83025. /** @hidden */
  83026. _rebuild(): void;
  83027. /**
  83028. * Triggers the load sequence in delayed load mode.
  83029. */
  83030. delayLoad(): void;
  83031. /**
  83032. * Clones the texture.
  83033. * @returns the cloned texture
  83034. */
  83035. clone(): Nullable<BaseTexture>;
  83036. /**
  83037. * Get the texture underlying type (INT, FLOAT...)
  83038. */
  83039. readonly textureType: number;
  83040. /**
  83041. * Get the texture underlying format (RGB, RGBA...)
  83042. */
  83043. readonly textureFormat: number;
  83044. /**
  83045. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  83046. * This will returns an RGBA array buffer containing either in values (0-255) or
  83047. * float values (0-1) depending of the underlying buffer type.
  83048. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  83049. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  83050. * @param buffer defines a user defined buffer to fill with data (can be null)
  83051. * @returns The Array buffer containing the pixels data.
  83052. */
  83053. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  83054. /**
  83055. * Release and destroy the underlying lower level texture aka internalTexture.
  83056. */
  83057. releaseInternalTexture(): void;
  83058. /**
  83059. * Get the polynomial representation of the texture data.
  83060. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  83061. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  83062. */
  83063. sphericalPolynomial: Nullable<SphericalPolynomial>;
  83064. /** @hidden */
  83065. readonly _lodTextureHigh: Nullable<BaseTexture>;
  83066. /** @hidden */
  83067. readonly _lodTextureMid: Nullable<BaseTexture>;
  83068. /** @hidden */
  83069. readonly _lodTextureLow: Nullable<BaseTexture>;
  83070. /**
  83071. * Dispose the texture and release its associated resources.
  83072. */
  83073. dispose(): void;
  83074. /**
  83075. * Serialize the texture into a JSON representation that can be parsed later on.
  83076. * @returns the JSON representation of the texture
  83077. */
  83078. serialize(): any;
  83079. /**
  83080. * Helper function to be called back once a list of texture contains only ready textures.
  83081. * @param textures Define the list of textures to wait for
  83082. * @param callback Define the callback triggered once the entire list will be ready
  83083. */
  83084. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  83085. }
  83086. }
  83087. declare module BABYLON {
  83088. /**
  83089. * Uniform buffer objects.
  83090. *
  83091. * Handles blocks of uniform on the GPU.
  83092. *
  83093. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83094. *
  83095. * For more information, please refer to :
  83096. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83097. */
  83098. export class UniformBuffer {
  83099. private _engine;
  83100. private _buffer;
  83101. private _data;
  83102. private _bufferData;
  83103. private _dynamic?;
  83104. private _uniformLocations;
  83105. private _uniformSizes;
  83106. private _uniformLocationPointer;
  83107. private _needSync;
  83108. private _noUBO;
  83109. private _currentEffect;
  83110. private static _MAX_UNIFORM_SIZE;
  83111. private static _tempBuffer;
  83112. /**
  83113. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83114. * This is dynamic to allow compat with webgl 1 and 2.
  83115. * You will need to pass the name of the uniform as well as the value.
  83116. */
  83117. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83118. /**
  83119. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83120. * This is dynamic to allow compat with webgl 1 and 2.
  83121. * You will need to pass the name of the uniform as well as the value.
  83122. */
  83123. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83124. /**
  83125. * Lambda to Update a single float in a uniform buffer.
  83126. * This is dynamic to allow compat with webgl 1 and 2.
  83127. * You will need to pass the name of the uniform as well as the value.
  83128. */
  83129. updateFloat: (name: string, x: number) => void;
  83130. /**
  83131. * Lambda to Update a vec2 of float in a uniform buffer.
  83132. * This is dynamic to allow compat with webgl 1 and 2.
  83133. * You will need to pass the name of the uniform as well as the value.
  83134. */
  83135. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83136. /**
  83137. * Lambda to Update a vec3 of float in a uniform buffer.
  83138. * This is dynamic to allow compat with webgl 1 and 2.
  83139. * You will need to pass the name of the uniform as well as the value.
  83140. */
  83141. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83142. /**
  83143. * Lambda to Update a vec4 of float in a uniform buffer.
  83144. * This is dynamic to allow compat with webgl 1 and 2.
  83145. * You will need to pass the name of the uniform as well as the value.
  83146. */
  83147. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83148. /**
  83149. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83150. * This is dynamic to allow compat with webgl 1 and 2.
  83151. * You will need to pass the name of the uniform as well as the value.
  83152. */
  83153. updateMatrix: (name: string, mat: Matrix) => void;
  83154. /**
  83155. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83156. * This is dynamic to allow compat with webgl 1 and 2.
  83157. * You will need to pass the name of the uniform as well as the value.
  83158. */
  83159. updateVector3: (name: string, vector: Vector3) => void;
  83160. /**
  83161. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83162. * This is dynamic to allow compat with webgl 1 and 2.
  83163. * You will need to pass the name of the uniform as well as the value.
  83164. */
  83165. updateVector4: (name: string, vector: Vector4) => void;
  83166. /**
  83167. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83168. * This is dynamic to allow compat with webgl 1 and 2.
  83169. * You will need to pass the name of the uniform as well as the value.
  83170. */
  83171. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83172. /**
  83173. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83174. * This is dynamic to allow compat with webgl 1 and 2.
  83175. * You will need to pass the name of the uniform as well as the value.
  83176. */
  83177. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83178. /**
  83179. * Instantiates a new Uniform buffer objects.
  83180. *
  83181. * Handles blocks of uniform on the GPU.
  83182. *
  83183. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83184. *
  83185. * For more information, please refer to :
  83186. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83187. * @param engine Define the engine the buffer is associated with
  83188. * @param data Define the data contained in the buffer
  83189. * @param dynamic Define if the buffer is updatable
  83190. */
  83191. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83192. /**
  83193. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83194. * or just falling back on setUniformXXX calls.
  83195. */
  83196. readonly useUbo: boolean;
  83197. /**
  83198. * Indicates if the WebGL underlying uniform buffer is in sync
  83199. * with the javascript cache data.
  83200. */
  83201. readonly isSync: boolean;
  83202. /**
  83203. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83204. * Also, a dynamic UniformBuffer will disable cache verification and always
  83205. * update the underlying WebGL uniform buffer to the GPU.
  83206. * @returns if Dynamic, otherwise false
  83207. */
  83208. isDynamic(): boolean;
  83209. /**
  83210. * The data cache on JS side.
  83211. * @returns the underlying data as a float array
  83212. */
  83213. getData(): Float32Array;
  83214. /**
  83215. * The underlying WebGL Uniform buffer.
  83216. * @returns the webgl buffer
  83217. */
  83218. getBuffer(): Nullable<WebGLBuffer>;
  83219. /**
  83220. * std140 layout specifies how to align data within an UBO structure.
  83221. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83222. * for specs.
  83223. */
  83224. private _fillAlignment;
  83225. /**
  83226. * Adds an uniform in the buffer.
  83227. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83228. * for the layout to be correct !
  83229. * @param name Name of the uniform, as used in the uniform block in the shader.
  83230. * @param size Data size, or data directly.
  83231. */
  83232. addUniform(name: string, size: number | number[]): void;
  83233. /**
  83234. * Adds a Matrix 4x4 to the uniform buffer.
  83235. * @param name Name of the uniform, as used in the uniform block in the shader.
  83236. * @param mat A 4x4 matrix.
  83237. */
  83238. addMatrix(name: string, mat: Matrix): void;
  83239. /**
  83240. * Adds a vec2 to the uniform buffer.
  83241. * @param name Name of the uniform, as used in the uniform block in the shader.
  83242. * @param x Define the x component value of the vec2
  83243. * @param y Define the y component value of the vec2
  83244. */
  83245. addFloat2(name: string, x: number, y: number): void;
  83246. /**
  83247. * Adds a vec3 to the uniform buffer.
  83248. * @param name Name of the uniform, as used in the uniform block in the shader.
  83249. * @param x Define the x component value of the vec3
  83250. * @param y Define the y component value of the vec3
  83251. * @param z Define the z component value of the vec3
  83252. */
  83253. addFloat3(name: string, x: number, y: number, z: number): void;
  83254. /**
  83255. * Adds a vec3 to the uniform buffer.
  83256. * @param name Name of the uniform, as used in the uniform block in the shader.
  83257. * @param color Define the vec3 from a Color
  83258. */
  83259. addColor3(name: string, color: Color3): void;
  83260. /**
  83261. * Adds a vec4 to the uniform buffer.
  83262. * @param name Name of the uniform, as used in the uniform block in the shader.
  83263. * @param color Define the rgb components from a Color
  83264. * @param alpha Define the a component of the vec4
  83265. */
  83266. addColor4(name: string, color: Color3, alpha: number): void;
  83267. /**
  83268. * Adds a vec3 to the uniform buffer.
  83269. * @param name Name of the uniform, as used in the uniform block in the shader.
  83270. * @param vector Define the vec3 components from a Vector
  83271. */
  83272. addVector3(name: string, vector: Vector3): void;
  83273. /**
  83274. * Adds a Matrix 3x3 to the uniform buffer.
  83275. * @param name Name of the uniform, as used in the uniform block in the shader.
  83276. */
  83277. addMatrix3x3(name: string): void;
  83278. /**
  83279. * Adds a Matrix 2x2 to the uniform buffer.
  83280. * @param name Name of the uniform, as used in the uniform block in the shader.
  83281. */
  83282. addMatrix2x2(name: string): void;
  83283. /**
  83284. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83285. */
  83286. create(): void;
  83287. /** @hidden */
  83288. _rebuild(): void;
  83289. /**
  83290. * Updates the WebGL Uniform Buffer on the GPU.
  83291. * If the `dynamic` flag is set to true, no cache comparison is done.
  83292. * Otherwise, the buffer will be updated only if the cache differs.
  83293. */
  83294. update(): void;
  83295. /**
  83296. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83297. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83298. * @param data Define the flattened data
  83299. * @param size Define the size of the data.
  83300. */
  83301. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83302. private _updateMatrix3x3ForUniform;
  83303. private _updateMatrix3x3ForEffect;
  83304. private _updateMatrix2x2ForEffect;
  83305. private _updateMatrix2x2ForUniform;
  83306. private _updateFloatForEffect;
  83307. private _updateFloatForUniform;
  83308. private _updateFloat2ForEffect;
  83309. private _updateFloat2ForUniform;
  83310. private _updateFloat3ForEffect;
  83311. private _updateFloat3ForUniform;
  83312. private _updateFloat4ForEffect;
  83313. private _updateFloat4ForUniform;
  83314. private _updateMatrixForEffect;
  83315. private _updateMatrixForUniform;
  83316. private _updateVector3ForEffect;
  83317. private _updateVector3ForUniform;
  83318. private _updateVector4ForEffect;
  83319. private _updateVector4ForUniform;
  83320. private _updateColor3ForEffect;
  83321. private _updateColor3ForUniform;
  83322. private _updateColor4ForEffect;
  83323. private _updateColor4ForUniform;
  83324. /**
  83325. * Sets a sampler uniform on the effect.
  83326. * @param name Define the name of the sampler.
  83327. * @param texture Define the texture to set in the sampler
  83328. */
  83329. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83330. /**
  83331. * Directly updates the value of the uniform in the cache AND on the GPU.
  83332. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83333. * @param data Define the flattened data
  83334. */
  83335. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83336. /**
  83337. * Binds this uniform buffer to an effect.
  83338. * @param effect Define the effect to bind the buffer to
  83339. * @param name Name of the uniform block in the shader.
  83340. */
  83341. bindToEffect(effect: Effect, name: string): void;
  83342. /**
  83343. * Disposes the uniform buffer.
  83344. */
  83345. dispose(): void;
  83346. }
  83347. }
  83348. declare module BABYLON {
  83349. /**
  83350. * This represents the required contract to create a new type of texture loader.
  83351. */
  83352. export interface IInternalTextureLoader {
  83353. /**
  83354. * Defines wether the loader supports cascade loading the different faces.
  83355. */
  83356. supportCascades: boolean;
  83357. /**
  83358. * This returns if the loader support the current file information.
  83359. * @param extension defines the file extension of the file being loaded
  83360. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83361. * @param fallback defines the fallback internal texture if any
  83362. * @param isBase64 defines whether the texture is encoded as a base64
  83363. * @param isBuffer defines whether the texture data are stored as a buffer
  83364. * @returns true if the loader can load the specified file
  83365. */
  83366. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83367. /**
  83368. * Transform the url before loading if required.
  83369. * @param rootUrl the url of the texture
  83370. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83371. * @returns the transformed texture
  83372. */
  83373. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83374. /**
  83375. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83376. * @param rootUrl the url of the texture
  83377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83378. * @returns the fallback texture
  83379. */
  83380. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83381. /**
  83382. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83383. * @param data contains the texture data
  83384. * @param texture defines the BabylonJS internal texture
  83385. * @param createPolynomials will be true if polynomials have been requested
  83386. * @param onLoad defines the callback to trigger once the texture is ready
  83387. * @param onError defines the callback to trigger in case of error
  83388. */
  83389. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83390. /**
  83391. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83392. * @param data contains the texture data
  83393. * @param texture defines the BabylonJS internal texture
  83394. * @param callback defines the method to call once ready to upload
  83395. */
  83396. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83397. }
  83398. }
  83399. declare module BABYLON {
  83400. /**
  83401. * Creation options of the multi render target texture.
  83402. */
  83403. export interface IMultiRenderTargetOptions {
  83404. /**
  83405. * Define if the texture needs to create mip maps after render.
  83406. */
  83407. generateMipMaps?: boolean;
  83408. /**
  83409. * Define the types of all the draw buffers we want to create
  83410. */
  83411. types?: number[];
  83412. /**
  83413. * Define the sampling modes of all the draw buffers we want to create
  83414. */
  83415. samplingModes?: number[];
  83416. /**
  83417. * Define if a depth buffer is required
  83418. */
  83419. generateDepthBuffer?: boolean;
  83420. /**
  83421. * Define if a stencil buffer is required
  83422. */
  83423. generateStencilBuffer?: boolean;
  83424. /**
  83425. * Define if a depth texture is required instead of a depth buffer
  83426. */
  83427. generateDepthTexture?: boolean;
  83428. /**
  83429. * Define the number of desired draw buffers
  83430. */
  83431. textureCount?: number;
  83432. /**
  83433. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83434. */
  83435. doNotChangeAspectRatio?: boolean;
  83436. /**
  83437. * Define the default type of the buffers we are creating
  83438. */
  83439. defaultType?: number;
  83440. }
  83441. /**
  83442. * A multi render target, like a render target provides the ability to render to a texture.
  83443. * Unlike the render target, it can render to several draw buffers in one draw.
  83444. * This is specially interesting in deferred rendering or for any effects requiring more than
  83445. * just one color from a single pass.
  83446. */
  83447. export class MultiRenderTarget extends RenderTargetTexture {
  83448. private _internalTextures;
  83449. private _textures;
  83450. private _multiRenderTargetOptions;
  83451. /**
  83452. * Get if draw buffers are currently supported by the used hardware and browser.
  83453. */
  83454. readonly isSupported: boolean;
  83455. /**
  83456. * Get the list of textures generated by the multi render target.
  83457. */
  83458. readonly textures: Texture[];
  83459. /**
  83460. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83461. */
  83462. readonly depthTexture: Texture;
  83463. /**
  83464. * Set the wrapping mode on U of all the textures we are rendering to.
  83465. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83466. */
  83467. wrapU: number;
  83468. /**
  83469. * Set the wrapping mode on V of all the textures we are rendering to.
  83470. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83471. */
  83472. wrapV: number;
  83473. /**
  83474. * Instantiate a new multi render target texture.
  83475. * A multi render target, like a render target provides the ability to render to a texture.
  83476. * Unlike the render target, it can render to several draw buffers in one draw.
  83477. * This is specially interesting in deferred rendering or for any effects requiring more than
  83478. * just one color from a single pass.
  83479. * @param name Define the name of the texture
  83480. * @param size Define the size of the buffers to render to
  83481. * @param count Define the number of target we are rendering into
  83482. * @param scene Define the scene the texture belongs to
  83483. * @param options Define the options used to create the multi render target
  83484. */
  83485. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83486. /** @hidden */
  83487. _rebuild(): void;
  83488. private _createInternalTextures;
  83489. private _createTextures;
  83490. /**
  83491. * Define the number of samples used if MSAA is enabled.
  83492. */
  83493. samples: number;
  83494. /**
  83495. * Resize all the textures in the multi render target.
  83496. * Be carrefull as it will recreate all the data in the new texture.
  83497. * @param size Define the new size
  83498. */
  83499. resize(size: any): void;
  83500. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83501. /**
  83502. * Dispose the render targets and their associated resources
  83503. */
  83504. dispose(): void;
  83505. /**
  83506. * Release all the underlying texture used as draw buffers.
  83507. */
  83508. releaseInternalTextures(): void;
  83509. }
  83510. }
  83511. declare module BABYLON {
  83512. /**
  83513. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83515. */
  83516. export class Analyser {
  83517. /**
  83518. * Gets or sets the smoothing
  83519. * @ignorenaming
  83520. */
  83521. SMOOTHING: number;
  83522. /**
  83523. * Gets or sets the FFT table size
  83524. * @ignorenaming
  83525. */
  83526. FFT_SIZE: number;
  83527. /**
  83528. * Gets or sets the bar graph amplitude
  83529. * @ignorenaming
  83530. */
  83531. BARGRAPHAMPLITUDE: number;
  83532. /**
  83533. * Gets or sets the position of the debug canvas
  83534. * @ignorenaming
  83535. */
  83536. DEBUGCANVASPOS: {
  83537. x: number;
  83538. y: number;
  83539. };
  83540. /**
  83541. * Gets or sets the debug canvas size
  83542. * @ignorenaming
  83543. */
  83544. DEBUGCANVASSIZE: {
  83545. width: number;
  83546. height: number;
  83547. };
  83548. private _byteFreqs;
  83549. private _byteTime;
  83550. private _floatFreqs;
  83551. private _webAudioAnalyser;
  83552. private _debugCanvas;
  83553. private _debugCanvasContext;
  83554. private _scene;
  83555. private _registerFunc;
  83556. private _audioEngine;
  83557. /**
  83558. * Creates a new analyser
  83559. * @param scene defines hosting scene
  83560. */
  83561. constructor(scene: Scene);
  83562. /**
  83563. * Get the number of data values you will have to play with for the visualization
  83564. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83565. * @returns a number
  83566. */
  83567. getFrequencyBinCount(): number;
  83568. /**
  83569. * Gets the current frequency data as a byte array
  83570. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83571. * @returns a Uint8Array
  83572. */
  83573. getByteFrequencyData(): Uint8Array;
  83574. /**
  83575. * Gets the current waveform as a byte array
  83576. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83577. * @returns a Uint8Array
  83578. */
  83579. getByteTimeDomainData(): Uint8Array;
  83580. /**
  83581. * Gets the current frequency data as a float array
  83582. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83583. * @returns a Float32Array
  83584. */
  83585. getFloatFrequencyData(): Float32Array;
  83586. /**
  83587. * Renders the debug canvas
  83588. */
  83589. drawDebugCanvas(): void;
  83590. /**
  83591. * Stops rendering the debug canvas and removes it
  83592. */
  83593. stopDebugCanvas(): void;
  83594. /**
  83595. * Connects two audio nodes
  83596. * @param inputAudioNode defines first node to connect
  83597. * @param outputAudioNode defines second node to connect
  83598. */
  83599. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83600. /**
  83601. * Releases all associated resources
  83602. */
  83603. dispose(): void;
  83604. }
  83605. }
  83606. declare module BABYLON {
  83607. /**
  83608. * This represents an audio engine and it is responsible
  83609. * to play, synchronize and analyse sounds throughout the application.
  83610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83611. */
  83612. export interface IAudioEngine extends IDisposable {
  83613. /**
  83614. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83615. */
  83616. readonly canUseWebAudio: boolean;
  83617. /**
  83618. * Gets the current AudioContext if available.
  83619. */
  83620. readonly audioContext: Nullable<AudioContext>;
  83621. /**
  83622. * The master gain node defines the global audio volume of your audio engine.
  83623. */
  83624. readonly masterGain: GainNode;
  83625. /**
  83626. * Gets whether or not mp3 are supported by your browser.
  83627. */
  83628. readonly isMP3supported: boolean;
  83629. /**
  83630. * Gets whether or not ogg are supported by your browser.
  83631. */
  83632. readonly isOGGsupported: boolean;
  83633. /**
  83634. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83635. * @ignoreNaming
  83636. */
  83637. WarnedWebAudioUnsupported: boolean;
  83638. /**
  83639. * Defines if the audio engine relies on a custom unlocked button.
  83640. * In this case, the embedded button will not be displayed.
  83641. */
  83642. useCustomUnlockedButton: boolean;
  83643. /**
  83644. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83645. */
  83646. readonly unlocked: boolean;
  83647. /**
  83648. * Event raised when audio has been unlocked on the browser.
  83649. */
  83650. onAudioUnlockedObservable: Observable<AudioEngine>;
  83651. /**
  83652. * Event raised when audio has been locked on the browser.
  83653. */
  83654. onAudioLockedObservable: Observable<AudioEngine>;
  83655. /**
  83656. * Flags the audio engine in Locked state.
  83657. * This happens due to new browser policies preventing audio to autoplay.
  83658. */
  83659. lock(): void;
  83660. /**
  83661. * Unlocks the audio engine once a user action has been done on the dom.
  83662. * This is helpful to resume play once browser policies have been satisfied.
  83663. */
  83664. unlock(): void;
  83665. }
  83666. /**
  83667. * This represents the default audio engine used in babylon.
  83668. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83670. */
  83671. export class AudioEngine implements IAudioEngine {
  83672. private _audioContext;
  83673. private _audioContextInitialized;
  83674. private _muteButton;
  83675. private _hostElement;
  83676. /**
  83677. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83678. */
  83679. canUseWebAudio: boolean;
  83680. /**
  83681. * The master gain node defines the global audio volume of your audio engine.
  83682. */
  83683. masterGain: GainNode;
  83684. /**
  83685. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83686. * @ignoreNaming
  83687. */
  83688. WarnedWebAudioUnsupported: boolean;
  83689. /**
  83690. * Gets whether or not mp3 are supported by your browser.
  83691. */
  83692. isMP3supported: boolean;
  83693. /**
  83694. * Gets whether or not ogg are supported by your browser.
  83695. */
  83696. isOGGsupported: boolean;
  83697. /**
  83698. * Gets whether audio has been unlocked on the device.
  83699. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83700. * a user interaction has happened.
  83701. */
  83702. unlocked: boolean;
  83703. /**
  83704. * Defines if the audio engine relies on a custom unlocked button.
  83705. * In this case, the embedded button will not be displayed.
  83706. */
  83707. useCustomUnlockedButton: boolean;
  83708. /**
  83709. * Event raised when audio has been unlocked on the browser.
  83710. */
  83711. onAudioUnlockedObservable: Observable<AudioEngine>;
  83712. /**
  83713. * Event raised when audio has been locked on the browser.
  83714. */
  83715. onAudioLockedObservable: Observable<AudioEngine>;
  83716. /**
  83717. * Gets the current AudioContext if available.
  83718. */
  83719. readonly audioContext: Nullable<AudioContext>;
  83720. private _connectedAnalyser;
  83721. /**
  83722. * Instantiates a new audio engine.
  83723. *
  83724. * There should be only one per page as some browsers restrict the number
  83725. * of audio contexts you can create.
  83726. * @param hostElement defines the host element where to display the mute icon if necessary
  83727. */
  83728. constructor(hostElement?: Nullable<HTMLElement>);
  83729. /**
  83730. * Flags the audio engine in Locked state.
  83731. * This happens due to new browser policies preventing audio to autoplay.
  83732. */
  83733. lock(): void;
  83734. /**
  83735. * Unlocks the audio engine once a user action has been done on the dom.
  83736. * This is helpful to resume play once browser policies have been satisfied.
  83737. */
  83738. unlock(): void;
  83739. private _resumeAudioContext;
  83740. private _initializeAudioContext;
  83741. private _tryToRun;
  83742. private _triggerRunningState;
  83743. private _triggerSuspendedState;
  83744. private _displayMuteButton;
  83745. private _moveButtonToTopLeft;
  83746. private _onResize;
  83747. private _hideMuteButton;
  83748. /**
  83749. * Destroy and release the resources associated with the audio ccontext.
  83750. */
  83751. dispose(): void;
  83752. /**
  83753. * Gets the global volume sets on the master gain.
  83754. * @returns the global volume if set or -1 otherwise
  83755. */
  83756. getGlobalVolume(): number;
  83757. /**
  83758. * Sets the global volume of your experience (sets on the master gain).
  83759. * @param newVolume Defines the new global volume of the application
  83760. */
  83761. setGlobalVolume(newVolume: number): void;
  83762. /**
  83763. * Connect the audio engine to an audio analyser allowing some amazing
  83764. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83766. * @param analyser The analyser to connect to the engine
  83767. */
  83768. connectToAnalyser(analyser: Analyser): void;
  83769. }
  83770. }
  83771. declare module BABYLON {
  83772. /**
  83773. * Interface used to present a loading screen while loading a scene
  83774. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83775. */
  83776. export interface ILoadingScreen {
  83777. /**
  83778. * Function called to display the loading screen
  83779. */
  83780. displayLoadingUI: () => void;
  83781. /**
  83782. * Function called to hide the loading screen
  83783. */
  83784. hideLoadingUI: () => void;
  83785. /**
  83786. * Gets or sets the color to use for the background
  83787. */
  83788. loadingUIBackgroundColor: string;
  83789. /**
  83790. * Gets or sets the text to display while loading
  83791. */
  83792. loadingUIText: string;
  83793. }
  83794. /**
  83795. * Class used for the default loading screen
  83796. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83797. */
  83798. export class DefaultLoadingScreen implements ILoadingScreen {
  83799. private _renderingCanvas;
  83800. private _loadingText;
  83801. private _loadingDivBackgroundColor;
  83802. private _loadingDiv;
  83803. private _loadingTextDiv;
  83804. /**
  83805. * Creates a new default loading screen
  83806. * @param _renderingCanvas defines the canvas used to render the scene
  83807. * @param _loadingText defines the default text to display
  83808. * @param _loadingDivBackgroundColor defines the default background color
  83809. */
  83810. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83811. /**
  83812. * Function called to display the loading screen
  83813. */
  83814. displayLoadingUI(): void;
  83815. /**
  83816. * Function called to hide the loading screen
  83817. */
  83818. hideLoadingUI(): void;
  83819. /**
  83820. * Gets or sets the text to display while loading
  83821. */
  83822. loadingUIText: string;
  83823. /**
  83824. * Gets or sets the color to use for the background
  83825. */
  83826. loadingUIBackgroundColor: string;
  83827. private _resizeLoadingUI;
  83828. }
  83829. }
  83830. declare module BABYLON {
  83831. /**
  83832. * Settings for finer control over video usage
  83833. */
  83834. export interface VideoTextureSettings {
  83835. /**
  83836. * Applies `autoplay` to video, if specified
  83837. */
  83838. autoPlay?: boolean;
  83839. /**
  83840. * Applies `loop` to video, if specified
  83841. */
  83842. loop?: boolean;
  83843. /**
  83844. * Automatically updates internal texture from video at every frame in the render loop
  83845. */
  83846. autoUpdateTexture: boolean;
  83847. /**
  83848. * Image src displayed during the video loading or until the user interacts with the video.
  83849. */
  83850. poster?: string;
  83851. }
  83852. /**
  83853. * If you want to display a video in your scene, this is the special texture for that.
  83854. * This special texture works similar to other textures, with the exception of a few parameters.
  83855. * @see https://doc.babylonjs.com/how_to/video_texture
  83856. */
  83857. export class VideoTexture extends Texture {
  83858. /**
  83859. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83860. */
  83861. readonly autoUpdateTexture: boolean;
  83862. /**
  83863. * The video instance used by the texture internally
  83864. */
  83865. readonly video: HTMLVideoElement;
  83866. private _onUserActionRequestedObservable;
  83867. /**
  83868. * Event triggerd when a dom action is required by the user to play the video.
  83869. * This happens due to recent changes in browser policies preventing video to auto start.
  83870. */
  83871. readonly onUserActionRequestedObservable: Observable<Texture>;
  83872. private _generateMipMaps;
  83873. private _engine;
  83874. private _stillImageCaptured;
  83875. private _displayingPosterTexture;
  83876. private _settings;
  83877. private _createInternalTextureOnEvent;
  83878. /**
  83879. * Creates a video texture.
  83880. * If you want to display a video in your scene, this is the special texture for that.
  83881. * This special texture works similar to other textures, with the exception of a few parameters.
  83882. * @see https://doc.babylonjs.com/how_to/video_texture
  83883. * @param name optional name, will detect from video source, if not defined
  83884. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83885. * @param scene is obviously the current scene.
  83886. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83887. * @param invertY is false by default but can be used to invert video on Y axis
  83888. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83889. * @param settings allows finer control over video usage
  83890. */
  83891. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83892. private _getName;
  83893. private _getVideo;
  83894. private _createInternalTexture;
  83895. private reset;
  83896. /**
  83897. * @hidden Internal method to initiate `update`.
  83898. */
  83899. _rebuild(): void;
  83900. /**
  83901. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83902. */
  83903. update(): void;
  83904. /**
  83905. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83906. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83907. */
  83908. updateTexture(isVisible: boolean): void;
  83909. protected _updateInternalTexture: () => void;
  83910. /**
  83911. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83912. * @param url New url.
  83913. */
  83914. updateURL(url: string): void;
  83915. /**
  83916. * Dispose the texture and release its associated resources.
  83917. */
  83918. dispose(): void;
  83919. /**
  83920. * Creates a video texture straight from a stream.
  83921. * @param scene Define the scene the texture should be created in
  83922. * @param stream Define the stream the texture should be created from
  83923. * @returns The created video texture as a promise
  83924. */
  83925. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83926. /**
  83927. * Creates a video texture straight from your WebCam video feed.
  83928. * @param scene Define the scene the texture should be created in
  83929. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83930. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83931. * @returns The created video texture as a promise
  83932. */
  83933. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83934. minWidth: number;
  83935. maxWidth: number;
  83936. minHeight: number;
  83937. maxHeight: number;
  83938. deviceId: string;
  83939. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83940. /**
  83941. * Creates a video texture straight from your WebCam video feed.
  83942. * @param scene Define the scene the texture should be created in
  83943. * @param onReady Define a callback to triggered once the texture will be ready
  83944. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83945. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83946. */
  83947. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83948. minWidth: number;
  83949. maxWidth: number;
  83950. minHeight: number;
  83951. maxHeight: number;
  83952. deviceId: string;
  83953. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83954. }
  83955. }
  83956. declare module BABYLON {
  83957. /**
  83958. * Interface for attribute information associated with buffer instanciation
  83959. */
  83960. export class InstancingAttributeInfo {
  83961. /**
  83962. * Index/offset of the attribute in the vertex shader
  83963. */
  83964. index: number;
  83965. /**
  83966. * size of the attribute, 1, 2, 3 or 4
  83967. */
  83968. attributeSize: number;
  83969. /**
  83970. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83971. * default is FLOAT
  83972. */
  83973. attribyteType: number;
  83974. /**
  83975. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83976. */
  83977. normalized: boolean;
  83978. /**
  83979. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83980. */
  83981. offset: number;
  83982. /**
  83983. * Name of the GLSL attribute, for debugging purpose only
  83984. */
  83985. attributeName: string;
  83986. }
  83987. /**
  83988. * Define options used to create a depth texture
  83989. */
  83990. export class DepthTextureCreationOptions {
  83991. /** Specifies whether or not a stencil should be allocated in the texture */
  83992. generateStencil?: boolean;
  83993. /** Specifies whether or not bilinear filtering is enable on the texture */
  83994. bilinearFiltering?: boolean;
  83995. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83996. comparisonFunction?: number;
  83997. /** Specifies if the created texture is a cube texture */
  83998. isCube?: boolean;
  83999. }
  84000. /**
  84001. * Class used to describe the capabilities of the engine relatively to the current browser
  84002. */
  84003. export class EngineCapabilities {
  84004. /** Maximum textures units per fragment shader */
  84005. maxTexturesImageUnits: number;
  84006. /** Maximum texture units per vertex shader */
  84007. maxVertexTextureImageUnits: number;
  84008. /** Maximum textures units in the entire pipeline */
  84009. maxCombinedTexturesImageUnits: number;
  84010. /** Maximum texture size */
  84011. maxTextureSize: number;
  84012. /** Maximum cube texture size */
  84013. maxCubemapTextureSize: number;
  84014. /** Maximum render texture size */
  84015. maxRenderTextureSize: number;
  84016. /** Maximum number of vertex attributes */
  84017. maxVertexAttribs: number;
  84018. /** Maximum number of varyings */
  84019. maxVaryingVectors: number;
  84020. /** Maximum number of uniforms per vertex shader */
  84021. maxVertexUniformVectors: number;
  84022. /** Maximum number of uniforms per fragment shader */
  84023. maxFragmentUniformVectors: number;
  84024. /** Defines if standard derivates (dx/dy) are supported */
  84025. standardDerivatives: boolean;
  84026. /** Defines if s3tc texture compression is supported */
  84027. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  84028. /** Defines if pvrtc texture compression is supported */
  84029. pvrtc: any;
  84030. /** Defines if etc1 texture compression is supported */
  84031. etc1: any;
  84032. /** Defines if etc2 texture compression is supported */
  84033. etc2: any;
  84034. /** Defines if astc texture compression is supported */
  84035. astc: any;
  84036. /** Defines if float textures are supported */
  84037. textureFloat: boolean;
  84038. /** Defines if vertex array objects are supported */
  84039. vertexArrayObject: boolean;
  84040. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  84041. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  84042. /** Gets the maximum level of anisotropy supported */
  84043. maxAnisotropy: number;
  84044. /** Defines if instancing is supported */
  84045. instancedArrays: boolean;
  84046. /** Defines if 32 bits indices are supported */
  84047. uintIndices: boolean;
  84048. /** Defines if high precision shaders are supported */
  84049. highPrecisionShaderSupported: boolean;
  84050. /** Defines if depth reading in the fragment shader is supported */
  84051. fragmentDepthSupported: boolean;
  84052. /** Defines if float texture linear filtering is supported*/
  84053. textureFloatLinearFiltering: boolean;
  84054. /** Defines if rendering to float textures is supported */
  84055. textureFloatRender: boolean;
  84056. /** Defines if half float textures are supported*/
  84057. textureHalfFloat: boolean;
  84058. /** Defines if half float texture linear filtering is supported*/
  84059. textureHalfFloatLinearFiltering: boolean;
  84060. /** Defines if rendering to half float textures is supported */
  84061. textureHalfFloatRender: boolean;
  84062. /** Defines if textureLOD shader command is supported */
  84063. textureLOD: boolean;
  84064. /** Defines if draw buffers extension is supported */
  84065. drawBuffersExtension: boolean;
  84066. /** Defines if depth textures are supported */
  84067. depthTextureExtension: boolean;
  84068. /** Defines if float color buffer are supported */
  84069. colorBufferFloat: boolean;
  84070. /** Gets disjoint timer query extension (null if not supported) */
  84071. timerQuery: EXT_disjoint_timer_query;
  84072. /** Defines if timestamp can be used with timer query */
  84073. canUseTimestampForTimerQuery: boolean;
  84074. /** Function used to let the system compiles shaders in background */
  84075. parallelShaderCompile: {
  84076. MAX_SHADER_COMPILER_THREADS_KHR: number;
  84077. maxShaderCompilerThreadsKHR: (thread: number) => void;
  84078. COMPLETION_STATUS_KHR: number;
  84079. };
  84080. }
  84081. /** Interface defining initialization parameters for Engine class */
  84082. export interface EngineOptions extends WebGLContextAttributes {
  84083. /**
  84084. * Defines if the engine should no exceed a specified device ratio
  84085. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  84086. */
  84087. limitDeviceRatio?: number;
  84088. /**
  84089. * Defines if webvr should be enabled automatically
  84090. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84091. */
  84092. autoEnableWebVR?: boolean;
  84093. /**
  84094. * Defines if webgl2 should be turned off even if supported
  84095. * @see http://doc.babylonjs.com/features/webgl2
  84096. */
  84097. disableWebGL2Support?: boolean;
  84098. /**
  84099. * Defines if webaudio should be initialized as well
  84100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84101. */
  84102. audioEngine?: boolean;
  84103. /**
  84104. * Defines if animations should run using a deterministic lock step
  84105. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84106. */
  84107. deterministicLockstep?: boolean;
  84108. /** Defines the maximum steps to use with deterministic lock step mode */
  84109. lockstepMaxSteps?: number;
  84110. /**
  84111. * Defines that engine should ignore context lost events
  84112. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  84113. */
  84114. doNotHandleContextLost?: boolean;
  84115. /**
  84116. * Defines that engine should ignore modifying touch action attribute and style
  84117. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  84118. */
  84119. doNotHandleTouchAction?: boolean;
  84120. }
  84121. /**
  84122. * Defines the interface used by display changed events
  84123. */
  84124. export interface IDisplayChangedEventArgs {
  84125. /** Gets the vrDisplay object (if any) */
  84126. vrDisplay: Nullable<any>;
  84127. /** Gets a boolean indicating if webVR is supported */
  84128. vrSupported: boolean;
  84129. }
  84130. /**
  84131. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  84132. */
  84133. export class Engine {
  84134. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  84135. static ExceptionList: ({
  84136. key: string;
  84137. capture: string;
  84138. captureConstraint: number;
  84139. targets: string[];
  84140. } | {
  84141. key: string;
  84142. capture: null;
  84143. captureConstraint: null;
  84144. targets: string[];
  84145. })[];
  84146. /** Gets the list of created engines */
  84147. static readonly Instances: Engine[];
  84148. /**
  84149. * Gets the latest created engine
  84150. */
  84151. static readonly LastCreatedEngine: Nullable<Engine>;
  84152. /**
  84153. * Gets the latest created scene
  84154. */
  84155. static readonly LastCreatedScene: Nullable<Scene>;
  84156. /**
  84157. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  84158. * @param flag defines which part of the materials must be marked as dirty
  84159. * @param predicate defines a predicate used to filter which materials should be affected
  84160. */
  84161. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  84162. /**
  84163. * Hidden
  84164. */
  84165. static _TextureLoaders: IInternalTextureLoader[];
  84166. /** Defines that alpha blending is disabled */
  84167. static readonly ALPHA_DISABLE: number;
  84168. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  84169. static readonly ALPHA_ADD: number;
  84170. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  84171. static readonly ALPHA_COMBINE: number;
  84172. /** Defines that alpha blending to DEST - SRC * DEST */
  84173. static readonly ALPHA_SUBTRACT: number;
  84174. /** Defines that alpha blending to SRC * DEST */
  84175. static readonly ALPHA_MULTIPLY: number;
  84176. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  84177. static readonly ALPHA_MAXIMIZED: number;
  84178. /** Defines that alpha blending to SRC + DEST */
  84179. static readonly ALPHA_ONEONE: number;
  84180. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  84181. static readonly ALPHA_PREMULTIPLIED: number;
  84182. /**
  84183. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  84184. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  84185. */
  84186. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  84187. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  84188. static readonly ALPHA_INTERPOLATE: number;
  84189. /**
  84190. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  84191. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  84192. */
  84193. static readonly ALPHA_SCREENMODE: number;
  84194. /** Defines that the ressource is not delayed*/
  84195. static readonly DELAYLOADSTATE_NONE: number;
  84196. /** Defines that the ressource was successfully delay loaded */
  84197. static readonly DELAYLOADSTATE_LOADED: number;
  84198. /** Defines that the ressource is currently delay loading */
  84199. static readonly DELAYLOADSTATE_LOADING: number;
  84200. /** Defines that the ressource is delayed and has not started loading */
  84201. static readonly DELAYLOADSTATE_NOTLOADED: number;
  84202. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  84203. static readonly NEVER: number;
  84204. /** 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 */
  84205. static readonly ALWAYS: number;
  84206. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  84207. static readonly LESS: number;
  84208. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  84209. static readonly EQUAL: number;
  84210. /** 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 */
  84211. static readonly LEQUAL: number;
  84212. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  84213. static readonly GREATER: number;
  84214. /** 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 */
  84215. static readonly GEQUAL: number;
  84216. /** 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 */
  84217. static readonly NOTEQUAL: number;
  84218. /** Passed to stencilOperation to specify that stencil value must be kept */
  84219. static readonly KEEP: number;
  84220. /** Passed to stencilOperation to specify that stencil value must be replaced */
  84221. static readonly REPLACE: number;
  84222. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84223. static readonly INCR: number;
  84224. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84225. static readonly DECR: number;
  84226. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84227. static readonly INVERT: number;
  84228. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84229. static readonly INCR_WRAP: number;
  84230. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84231. static readonly DECR_WRAP: number;
  84232. /** Texture is not repeating outside of 0..1 UVs */
  84233. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84234. /** Texture is repeating outside of 0..1 UVs */
  84235. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84236. /** Texture is repeating and mirrored */
  84237. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84238. /** ALPHA */
  84239. static readonly TEXTUREFORMAT_ALPHA: number;
  84240. /** LUMINANCE */
  84241. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84242. /** LUMINANCE_ALPHA */
  84243. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84244. /** RGB */
  84245. static readonly TEXTUREFORMAT_RGB: number;
  84246. /** RGBA */
  84247. static readonly TEXTUREFORMAT_RGBA: number;
  84248. /** RED */
  84249. static readonly TEXTUREFORMAT_RED: number;
  84250. /** RED (2nd reference) */
  84251. static readonly TEXTUREFORMAT_R: number;
  84252. /** RG */
  84253. static readonly TEXTUREFORMAT_RG: number;
  84254. /** RED_INTEGER */
  84255. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84256. /** RED_INTEGER (2nd reference) */
  84257. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84258. /** RG_INTEGER */
  84259. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84260. /** RGB_INTEGER */
  84261. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84262. /** RGBA_INTEGER */
  84263. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84264. /** UNSIGNED_BYTE */
  84265. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84266. /** UNSIGNED_BYTE (2nd reference) */
  84267. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84268. /** FLOAT */
  84269. static readonly TEXTURETYPE_FLOAT: number;
  84270. /** HALF_FLOAT */
  84271. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84272. /** BYTE */
  84273. static readonly TEXTURETYPE_BYTE: number;
  84274. /** SHORT */
  84275. static readonly TEXTURETYPE_SHORT: number;
  84276. /** UNSIGNED_SHORT */
  84277. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84278. /** INT */
  84279. static readonly TEXTURETYPE_INT: number;
  84280. /** UNSIGNED_INT */
  84281. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84282. /** UNSIGNED_SHORT_4_4_4_4 */
  84283. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84284. /** UNSIGNED_SHORT_5_5_5_1 */
  84285. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84286. /** UNSIGNED_SHORT_5_6_5 */
  84287. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84288. /** UNSIGNED_INT_2_10_10_10_REV */
  84289. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84290. /** UNSIGNED_INT_24_8 */
  84291. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84292. /** UNSIGNED_INT_10F_11F_11F_REV */
  84293. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84294. /** UNSIGNED_INT_5_9_9_9_REV */
  84295. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84296. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84297. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84298. /** nearest is mag = nearest and min = nearest and mip = linear */
  84299. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84300. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84301. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84302. /** Trilinear is mag = linear and min = linear and mip = linear */
  84303. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84304. /** nearest is mag = nearest and min = nearest and mip = linear */
  84305. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84306. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84307. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84308. /** Trilinear is mag = linear and min = linear and mip = linear */
  84309. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84310. /** mag = nearest and min = nearest and mip = nearest */
  84311. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84312. /** mag = nearest and min = linear and mip = nearest */
  84313. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84314. /** mag = nearest and min = linear and mip = linear */
  84315. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84316. /** mag = nearest and min = linear and mip = none */
  84317. static readonly TEXTURE_NEAREST_LINEAR: number;
  84318. /** mag = nearest and min = nearest and mip = none */
  84319. static readonly TEXTURE_NEAREST_NEAREST: number;
  84320. /** mag = linear and min = nearest and mip = nearest */
  84321. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84322. /** mag = linear and min = nearest and mip = linear */
  84323. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84324. /** mag = linear and min = linear and mip = none */
  84325. static readonly TEXTURE_LINEAR_LINEAR: number;
  84326. /** mag = linear and min = nearest and mip = none */
  84327. static readonly TEXTURE_LINEAR_NEAREST: number;
  84328. /** Explicit coordinates mode */
  84329. static readonly TEXTURE_EXPLICIT_MODE: number;
  84330. /** Spherical coordinates mode */
  84331. static readonly TEXTURE_SPHERICAL_MODE: number;
  84332. /** Planar coordinates mode */
  84333. static readonly TEXTURE_PLANAR_MODE: number;
  84334. /** Cubic coordinates mode */
  84335. static readonly TEXTURE_CUBIC_MODE: number;
  84336. /** Projection coordinates mode */
  84337. static readonly TEXTURE_PROJECTION_MODE: number;
  84338. /** Skybox coordinates mode */
  84339. static readonly TEXTURE_SKYBOX_MODE: number;
  84340. /** Inverse Cubic coordinates mode */
  84341. static readonly TEXTURE_INVCUBIC_MODE: number;
  84342. /** Equirectangular coordinates mode */
  84343. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84344. /** Equirectangular Fixed coordinates mode */
  84345. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84346. /** Equirectangular Fixed Mirrored coordinates mode */
  84347. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84348. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84349. static readonly SCALEMODE_FLOOR: number;
  84350. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84351. static readonly SCALEMODE_NEAREST: number;
  84352. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84353. static readonly SCALEMODE_CEILING: number;
  84354. /**
  84355. * Returns the current version of the framework
  84356. */
  84357. static readonly Version: string;
  84358. /**
  84359. * Returns a string describing the current engine
  84360. */
  84361. readonly description: string;
  84362. /**
  84363. * Gets or sets the epsilon value used by collision engine
  84364. */
  84365. static CollisionsEpsilon: number;
  84366. /**
  84367. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84368. */
  84369. static ShadersRepository: string;
  84370. /**
  84371. * Method called to create the default loading screen.
  84372. * This can be overriden in your own app.
  84373. * @param canvas The rendering canvas element
  84374. * @returns The loading screen
  84375. */
  84376. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84377. /**
  84378. * Method called to create the default rescale post process on each engine.
  84379. */
  84380. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84381. /**
  84382. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84383. */
  84384. forcePOTTextures: boolean;
  84385. /**
  84386. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84387. */
  84388. isFullscreen: boolean;
  84389. /**
  84390. * Gets a boolean indicating if the pointer is currently locked
  84391. */
  84392. isPointerLock: boolean;
  84393. /**
  84394. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84395. */
  84396. cullBackFaces: boolean;
  84397. /**
  84398. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84399. */
  84400. renderEvenInBackground: boolean;
  84401. /**
  84402. * Gets or sets a boolean indicating that cache can be kept between frames
  84403. */
  84404. preventCacheWipeBetweenFrames: boolean;
  84405. /**
  84406. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84407. **/
  84408. enableOfflineSupport: boolean;
  84409. /**
  84410. * 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)
  84411. **/
  84412. disableManifestCheck: boolean;
  84413. /**
  84414. * Gets the list of created scenes
  84415. */
  84416. scenes: Scene[];
  84417. /**
  84418. * Event raised when a new scene is created
  84419. */
  84420. onNewSceneAddedObservable: Observable<Scene>;
  84421. /**
  84422. * Gets the list of created postprocesses
  84423. */
  84424. postProcesses: PostProcess[];
  84425. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84426. validateShaderPrograms: boolean;
  84427. /**
  84428. * Observable event triggered each time the rendering canvas is resized
  84429. */
  84430. onResizeObservable: Observable<Engine>;
  84431. /**
  84432. * Observable event triggered each time the canvas loses focus
  84433. */
  84434. onCanvasBlurObservable: Observable<Engine>;
  84435. /**
  84436. * Observable event triggered each time the canvas gains focus
  84437. */
  84438. onCanvasFocusObservable: Observable<Engine>;
  84439. /**
  84440. * Observable event triggered each time the canvas receives pointerout event
  84441. */
  84442. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84443. /**
  84444. * Observable event triggered before each texture is initialized
  84445. */
  84446. onBeforeTextureInitObservable: Observable<Texture>;
  84447. private _vrDisplay;
  84448. private _vrSupported;
  84449. private _oldSize;
  84450. private _oldHardwareScaleFactor;
  84451. private _vrExclusivePointerMode;
  84452. private _webVRInitPromise;
  84453. /**
  84454. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84455. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84456. */
  84457. readonly isInVRExclusivePointerMode: boolean;
  84458. /**
  84459. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84460. */
  84461. disableUniformBuffers: boolean;
  84462. /** @hidden */
  84463. _uniformBuffers: UniformBuffer[];
  84464. /**
  84465. * Gets a boolean indicating that the engine supports uniform buffers
  84466. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84467. */
  84468. readonly supportsUniformBuffers: boolean;
  84469. /**
  84470. * Observable raised when the engine begins a new frame
  84471. */
  84472. onBeginFrameObservable: Observable<Engine>;
  84473. /**
  84474. * If set, will be used to request the next animation frame for the render loop
  84475. */
  84476. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84477. /**
  84478. * Observable raised when the engine ends the current frame
  84479. */
  84480. onEndFrameObservable: Observable<Engine>;
  84481. /**
  84482. * Observable raised when the engine is about to compile a shader
  84483. */
  84484. onBeforeShaderCompilationObservable: Observable<Engine>;
  84485. /**
  84486. * Observable raised when the engine has jsut compiled a shader
  84487. */
  84488. onAfterShaderCompilationObservable: Observable<Engine>;
  84489. /** @hidden */
  84490. _gl: WebGLRenderingContext;
  84491. private _renderingCanvas;
  84492. private _windowIsBackground;
  84493. private _webGLVersion;
  84494. /**
  84495. * Gets a boolean indicating that only power of 2 textures are supported
  84496. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84497. */
  84498. readonly needPOTTextures: boolean;
  84499. /** @hidden */
  84500. _badOS: boolean;
  84501. /** @hidden */
  84502. _badDesktopOS: boolean;
  84503. /**
  84504. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84505. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84506. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84507. */
  84508. disableTextureBindingOptimization: boolean;
  84509. /**
  84510. * Gets the audio engine
  84511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84512. * @ignorenaming
  84513. */
  84514. static audioEngine: IAudioEngine;
  84515. /**
  84516. * Default AudioEngine factory responsible of creating the Audio Engine.
  84517. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84518. */
  84519. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84520. /**
  84521. * Default offline support factory responsible of creating a tool used to store data locally.
  84522. * By default, this will create a Database object if the workload has been embedded.
  84523. */
  84524. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84525. private _onFocus;
  84526. private _onBlur;
  84527. private _onCanvasPointerOut;
  84528. private _onCanvasBlur;
  84529. private _onCanvasFocus;
  84530. private _onFullscreenChange;
  84531. private _onPointerLockChange;
  84532. private _onVRDisplayPointerRestricted;
  84533. private _onVRDisplayPointerUnrestricted;
  84534. private _onVrDisplayConnect;
  84535. private _onVrDisplayDisconnect;
  84536. private _onVrDisplayPresentChange;
  84537. /**
  84538. * Observable signaled when VR display mode changes
  84539. */
  84540. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84541. /**
  84542. * Observable signaled when VR request present is complete
  84543. */
  84544. onVRRequestPresentComplete: Observable<boolean>;
  84545. /**
  84546. * Observable signaled when VR request present starts
  84547. */
  84548. onVRRequestPresentStart: Observable<Engine>;
  84549. private _hardwareScalingLevel;
  84550. /** @hidden */
  84551. protected _caps: EngineCapabilities;
  84552. private _pointerLockRequested;
  84553. private _isStencilEnable;
  84554. private _colorWrite;
  84555. private _loadingScreen;
  84556. /** @hidden */
  84557. _drawCalls: PerfCounter;
  84558. /** @hidden */
  84559. _textureCollisions: PerfCounter;
  84560. private _glVersion;
  84561. private _glRenderer;
  84562. private _glVendor;
  84563. private _videoTextureSupported;
  84564. private _renderingQueueLaunched;
  84565. private _activeRenderLoops;
  84566. private _deterministicLockstep;
  84567. private _lockstepMaxSteps;
  84568. /**
  84569. * Observable signaled when a context lost event is raised
  84570. */
  84571. onContextLostObservable: Observable<Engine>;
  84572. /**
  84573. * Observable signaled when a context restored event is raised
  84574. */
  84575. onContextRestoredObservable: Observable<Engine>;
  84576. private _onContextLost;
  84577. private _onContextRestored;
  84578. private _contextWasLost;
  84579. private _doNotHandleContextLost;
  84580. /**
  84581. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84582. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84583. */
  84584. doNotHandleContextLost: boolean;
  84585. private _performanceMonitor;
  84586. private _fps;
  84587. private _deltaTime;
  84588. /**
  84589. * Turn this value on if you want to pause FPS computation when in background
  84590. */
  84591. disablePerformanceMonitorInBackground: boolean;
  84592. /**
  84593. * Gets the performance monitor attached to this engine
  84594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84595. */
  84596. readonly performanceMonitor: PerformanceMonitor;
  84597. /** @hidden */
  84598. protected _depthCullingState: _DepthCullingState;
  84599. /** @hidden */
  84600. protected _stencilState: _StencilState;
  84601. /** @hidden */
  84602. protected _alphaState: _AlphaState;
  84603. /** @hidden */
  84604. protected _alphaMode: number;
  84605. protected _internalTexturesCache: InternalTexture[];
  84606. /** @hidden */
  84607. protected _activeChannel: number;
  84608. private _currentTextureChannel;
  84609. /** @hidden */
  84610. protected _boundTexturesCache: {
  84611. [key: string]: Nullable<InternalTexture>;
  84612. };
  84613. /** @hidden */
  84614. protected _currentEffect: Nullable<Effect>;
  84615. /** @hidden */
  84616. protected _currentProgram: Nullable<WebGLProgram>;
  84617. private _compiledEffects;
  84618. private _vertexAttribArraysEnabled;
  84619. /** @hidden */
  84620. protected _cachedViewport: Nullable<Viewport>;
  84621. private _cachedVertexArrayObject;
  84622. /** @hidden */
  84623. protected _cachedVertexBuffers: any;
  84624. /** @hidden */
  84625. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84626. /** @hidden */
  84627. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84628. /** @hidden */
  84629. protected _currentRenderTarget: Nullable<InternalTexture>;
  84630. private _uintIndicesCurrentlySet;
  84631. private _currentBoundBuffer;
  84632. /** @hidden */
  84633. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84634. private _currentBufferPointers;
  84635. private _currentInstanceLocations;
  84636. private _currentInstanceBuffers;
  84637. private _textureUnits;
  84638. private _firstBoundInternalTextureTracker;
  84639. private _lastBoundInternalTextureTracker;
  84640. private _workingCanvas;
  84641. private _workingContext;
  84642. private _rescalePostProcess;
  84643. private _dummyFramebuffer;
  84644. private _externalData;
  84645. private _bindedRenderFunction;
  84646. private _vaoRecordInProgress;
  84647. private _mustWipeVertexAttributes;
  84648. private _emptyTexture;
  84649. private _emptyCubeTexture;
  84650. private _emptyTexture3D;
  84651. /** @hidden */
  84652. _frameHandler: number;
  84653. private _nextFreeTextureSlots;
  84654. private _maxSimultaneousTextures;
  84655. private _activeRequests;
  84656. private _texturesSupported;
  84657. private _textureFormatInUse;
  84658. /**
  84659. * Gets the list of texture formats supported
  84660. */
  84661. readonly texturesSupported: Array<string>;
  84662. /**
  84663. * Gets the list of texture formats in use
  84664. */
  84665. readonly textureFormatInUse: Nullable<string>;
  84666. /**
  84667. * Gets the current viewport
  84668. */
  84669. readonly currentViewport: Nullable<Viewport>;
  84670. /**
  84671. * Gets the default empty texture
  84672. */
  84673. readonly emptyTexture: InternalTexture;
  84674. /**
  84675. * Gets the default empty 3D texture
  84676. */
  84677. readonly emptyTexture3D: InternalTexture;
  84678. /**
  84679. * Gets the default empty cube texture
  84680. */
  84681. readonly emptyCubeTexture: InternalTexture;
  84682. /**
  84683. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84684. */
  84685. readonly premultipliedAlpha: boolean;
  84686. /**
  84687. * Creates a new engine
  84688. * @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
  84689. * @param antialias defines enable antialiasing (default: false)
  84690. * @param options defines further options to be sent to the getContext() function
  84691. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84692. */
  84693. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84694. private _disableTouchAction;
  84695. private _rebuildInternalTextures;
  84696. private _rebuildEffects;
  84697. /**
  84698. * Gets a boolean indicating if all created effects are ready
  84699. * @returns true if all effects are ready
  84700. */
  84701. areAllEffectsReady(): boolean;
  84702. private _rebuildBuffers;
  84703. private _initGLContext;
  84704. /**
  84705. * Gets version of the current webGL context
  84706. */
  84707. readonly webGLVersion: number;
  84708. /**
  84709. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84710. */
  84711. readonly isStencilEnable: boolean;
  84712. private _prepareWorkingCanvas;
  84713. /**
  84714. * Reset the texture cache to empty state
  84715. */
  84716. resetTextureCache(): void;
  84717. /**
  84718. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84720. * @returns true if engine is in deterministic lock step mode
  84721. */
  84722. isDeterministicLockStep(): boolean;
  84723. /**
  84724. * Gets the max steps when engine is running in deterministic lock step
  84725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84726. * @returns the max steps
  84727. */
  84728. getLockstepMaxSteps(): number;
  84729. /**
  84730. * Gets an object containing information about the current webGL context
  84731. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84732. */
  84733. getGlInfo(): {
  84734. vendor: string;
  84735. renderer: string;
  84736. version: string;
  84737. };
  84738. /**
  84739. * Gets current aspect ratio
  84740. * @param camera defines the camera to use to get the aspect ratio
  84741. * @param useScreen defines if screen size must be used (or the current render target if any)
  84742. * @returns a number defining the aspect ratio
  84743. */
  84744. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84745. /**
  84746. * Gets current screen aspect ratio
  84747. * @returns a number defining the aspect ratio
  84748. */
  84749. getScreenAspectRatio(): number;
  84750. /**
  84751. * Gets the current render width
  84752. * @param useScreen defines if screen size must be used (or the current render target if any)
  84753. * @returns a number defining the current render width
  84754. */
  84755. getRenderWidth(useScreen?: boolean): number;
  84756. /**
  84757. * Gets the current render height
  84758. * @param useScreen defines if screen size must be used (or the current render target if any)
  84759. * @returns a number defining the current render height
  84760. */
  84761. getRenderHeight(useScreen?: boolean): number;
  84762. /**
  84763. * Gets the HTML canvas attached with the current webGL context
  84764. * @returns a HTML canvas
  84765. */
  84766. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84767. /**
  84768. * Gets the client rect of the HTML canvas attached with the current webGL context
  84769. * @returns a client rectanglee
  84770. */
  84771. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84772. /**
  84773. * Defines the hardware scaling level.
  84774. * By default the hardware scaling level is computed from the window device ratio.
  84775. * 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.
  84776. * @param level defines the level to use
  84777. */
  84778. setHardwareScalingLevel(level: number): void;
  84779. /**
  84780. * Gets the current hardware scaling level.
  84781. * By default the hardware scaling level is computed from the window device ratio.
  84782. * 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.
  84783. * @returns a number indicating the current hardware scaling level
  84784. */
  84785. getHardwareScalingLevel(): number;
  84786. /**
  84787. * Gets the list of loaded textures
  84788. * @returns an array containing all loaded textures
  84789. */
  84790. getLoadedTexturesCache(): InternalTexture[];
  84791. /**
  84792. * Gets the object containing all engine capabilities
  84793. * @returns the EngineCapabilities object
  84794. */
  84795. getCaps(): EngineCapabilities;
  84796. /**
  84797. * Gets the current depth function
  84798. * @returns a number defining the depth function
  84799. */
  84800. getDepthFunction(): Nullable<number>;
  84801. /**
  84802. * Sets the current depth function
  84803. * @param depthFunc defines the function to use
  84804. */
  84805. setDepthFunction(depthFunc: number): void;
  84806. /**
  84807. * Sets the current depth function to GREATER
  84808. */
  84809. setDepthFunctionToGreater(): void;
  84810. /**
  84811. * Sets the current depth function to GEQUAL
  84812. */
  84813. setDepthFunctionToGreaterOrEqual(): void;
  84814. /**
  84815. * Sets the current depth function to LESS
  84816. */
  84817. setDepthFunctionToLess(): void;
  84818. /**
  84819. * Sets the current depth function to LEQUAL
  84820. */
  84821. setDepthFunctionToLessOrEqual(): void;
  84822. /**
  84823. * Gets a boolean indicating if stencil buffer is enabled
  84824. * @returns the current stencil buffer state
  84825. */
  84826. getStencilBuffer(): boolean;
  84827. /**
  84828. * Enable or disable the stencil buffer
  84829. * @param enable defines if the stencil buffer must be enabled or disabled
  84830. */
  84831. setStencilBuffer(enable: boolean): void;
  84832. /**
  84833. * Gets the current stencil mask
  84834. * @returns a number defining the new stencil mask to use
  84835. */
  84836. getStencilMask(): number;
  84837. /**
  84838. * Sets the current stencil mask
  84839. * @param mask defines the new stencil mask to use
  84840. */
  84841. setStencilMask(mask: number): void;
  84842. /**
  84843. * Gets the current stencil function
  84844. * @returns a number defining the stencil function to use
  84845. */
  84846. getStencilFunction(): number;
  84847. /**
  84848. * Gets the current stencil reference value
  84849. * @returns a number defining the stencil reference value to use
  84850. */
  84851. getStencilFunctionReference(): number;
  84852. /**
  84853. * Gets the current stencil mask
  84854. * @returns a number defining the stencil mask to use
  84855. */
  84856. getStencilFunctionMask(): number;
  84857. /**
  84858. * Sets the current stencil function
  84859. * @param stencilFunc defines the new stencil function to use
  84860. */
  84861. setStencilFunction(stencilFunc: number): void;
  84862. /**
  84863. * Sets the current stencil reference
  84864. * @param reference defines the new stencil reference to use
  84865. */
  84866. setStencilFunctionReference(reference: number): void;
  84867. /**
  84868. * Sets the current stencil mask
  84869. * @param mask defines the new stencil mask to use
  84870. */
  84871. setStencilFunctionMask(mask: number): void;
  84872. /**
  84873. * Gets the current stencil operation when stencil fails
  84874. * @returns a number defining stencil operation to use when stencil fails
  84875. */
  84876. getStencilOperationFail(): number;
  84877. /**
  84878. * Gets the current stencil operation when depth fails
  84879. * @returns a number defining stencil operation to use when depth fails
  84880. */
  84881. getStencilOperationDepthFail(): number;
  84882. /**
  84883. * Gets the current stencil operation when stencil passes
  84884. * @returns a number defining stencil operation to use when stencil passes
  84885. */
  84886. getStencilOperationPass(): number;
  84887. /**
  84888. * Sets the stencil operation to use when stencil fails
  84889. * @param operation defines the stencil operation to use when stencil fails
  84890. */
  84891. setStencilOperationFail(operation: number): void;
  84892. /**
  84893. * Sets the stencil operation to use when depth fails
  84894. * @param operation defines the stencil operation to use when depth fails
  84895. */
  84896. setStencilOperationDepthFail(operation: number): void;
  84897. /**
  84898. * Sets the stencil operation to use when stencil passes
  84899. * @param operation defines the stencil operation to use when stencil passes
  84900. */
  84901. setStencilOperationPass(operation: number): void;
  84902. /**
  84903. * Sets a boolean indicating if the dithering state is enabled or disabled
  84904. * @param value defines the dithering state
  84905. */
  84906. setDitheringState(value: boolean): void;
  84907. /**
  84908. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84909. * @param value defines the rasterizer state
  84910. */
  84911. setRasterizerState(value: boolean): void;
  84912. /**
  84913. * stop executing a render loop function and remove it from the execution array
  84914. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84915. */
  84916. stopRenderLoop(renderFunction?: () => void): void;
  84917. /** @hidden */
  84918. _renderLoop(): void;
  84919. /**
  84920. * Register and execute a render loop. The engine can have more than one render function
  84921. * @param renderFunction defines the function to continuously execute
  84922. */
  84923. runRenderLoop(renderFunction: () => void): void;
  84924. /**
  84925. * Toggle full screen mode
  84926. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84927. */
  84928. switchFullscreen(requestPointerLock: boolean): void;
  84929. /**
  84930. * Enters full screen mode
  84931. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84932. */
  84933. enterFullscreen(requestPointerLock: boolean): void;
  84934. /**
  84935. * Exits full screen mode
  84936. */
  84937. exitFullscreen(): void;
  84938. /**
  84939. * Clear the current render buffer or the current render target (if any is set up)
  84940. * @param color defines the color to use
  84941. * @param backBuffer defines if the back buffer must be cleared
  84942. * @param depth defines if the depth buffer must be cleared
  84943. * @param stencil defines if the stencil buffer must be cleared
  84944. */
  84945. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84946. /**
  84947. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84948. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84949. * @param y defines the y-coordinate of the corner of the clear rectangle
  84950. * @param width defines the width of the clear rectangle
  84951. * @param height defines the height of the clear rectangle
  84952. * @param clearColor defines the clear color
  84953. */
  84954. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84955. /**
  84956. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84957. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84958. * @param y defines the y-coordinate of the corner of the clear rectangle
  84959. * @param width defines the width of the clear rectangle
  84960. * @param height defines the height of the clear rectangle
  84961. */
  84962. enableScissor(x: number, y: number, width: number, height: number): void;
  84963. /**
  84964. * Disable previously set scissor test rectangle
  84965. */
  84966. disableScissor(): void;
  84967. private _viewportCached;
  84968. /** @hidden */
  84969. _viewport(x: number, y: number, width: number, height: number): void;
  84970. /**
  84971. * Set the WebGL's viewport
  84972. * @param viewport defines the viewport element to be used
  84973. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84974. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84975. */
  84976. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84977. /**
  84978. * Directly set the WebGL Viewport
  84979. * @param x defines the x coordinate of the viewport (in screen space)
  84980. * @param y defines the y coordinate of the viewport (in screen space)
  84981. * @param width defines the width of the viewport (in screen space)
  84982. * @param height defines the height of the viewport (in screen space)
  84983. * @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
  84984. */
  84985. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84986. /**
  84987. * Begin a new frame
  84988. */
  84989. beginFrame(): void;
  84990. /**
  84991. * Enf the current frame
  84992. */
  84993. endFrame(): void;
  84994. /**
  84995. * Resize the view according to the canvas' size
  84996. */
  84997. resize(): void;
  84998. /**
  84999. * Force a specific size of the canvas
  85000. * @param width defines the new canvas' width
  85001. * @param height defines the new canvas' height
  85002. */
  85003. setSize(width: number, height: number): void;
  85004. /**
  85005. * Gets a boolean indicating if a webVR device was detected
  85006. * @returns true if a webVR device was detected
  85007. */
  85008. isVRDevicePresent(): boolean;
  85009. /**
  85010. * Gets the current webVR device
  85011. * @returns the current webVR device (or null)
  85012. */
  85013. getVRDevice(): any;
  85014. /**
  85015. * Initializes a webVR display and starts listening to display change events
  85016. * The onVRDisplayChangedObservable will be notified upon these changes
  85017. * @returns The onVRDisplayChangedObservable
  85018. */
  85019. initWebVR(): Observable<IDisplayChangedEventArgs>;
  85020. /**
  85021. * Initializes a webVR display and starts listening to display change events
  85022. * The onVRDisplayChangedObservable will be notified upon these changes
  85023. * @returns A promise containing a VRDisplay and if vr is supported
  85024. */
  85025. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85026. /**
  85027. * Call this function to switch to webVR mode
  85028. * Will do nothing if webVR is not supported or if there is no webVR device
  85029. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85030. */
  85031. enableVR(): void;
  85032. /**
  85033. * Call this function to leave webVR mode
  85034. * Will do nothing if webVR is not supported or if there is no webVR device
  85035. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85036. */
  85037. disableVR(): void;
  85038. private _onVRFullScreenTriggered;
  85039. private _getVRDisplaysAsync;
  85040. /**
  85041. * Binds the frame buffer to the specified texture.
  85042. * @param texture The texture to render to or null for the default canvas
  85043. * @param faceIndex The face of the texture to render to in case of cube texture
  85044. * @param requiredWidth The width of the target to render to
  85045. * @param requiredHeight The height of the target to render to
  85046. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  85047. * @param depthStencilTexture The depth stencil texture to use to render
  85048. * @param lodLevel defines le lod level to bind to the frame buffer
  85049. */
  85050. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  85051. private bindUnboundFramebuffer;
  85052. /**
  85053. * Unbind the current render target texture from the webGL context
  85054. * @param texture defines the render target texture to unbind
  85055. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85056. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85057. */
  85058. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85059. /**
  85060. * Unbind a list of render target textures from the webGL context
  85061. * This is used only when drawBuffer extension or webGL2 are active
  85062. * @param textures defines the render target textures to unbind
  85063. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85064. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85065. */
  85066. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85067. /**
  85068. * Force the mipmap generation for the given render target texture
  85069. * @param texture defines the render target texture to use
  85070. */
  85071. generateMipMapsForCubemap(texture: InternalTexture): void;
  85072. /**
  85073. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  85074. */
  85075. flushFramebuffer(): void;
  85076. /**
  85077. * Unbind the current render target and bind the default framebuffer
  85078. */
  85079. restoreDefaultFramebuffer(): void;
  85080. /**
  85081. * Create an uniform buffer
  85082. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85083. * @param elements defines the content of the uniform buffer
  85084. * @returns the webGL uniform buffer
  85085. */
  85086. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  85087. /**
  85088. * Create a dynamic uniform buffer
  85089. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85090. * @param elements defines the content of the uniform buffer
  85091. * @returns the webGL uniform buffer
  85092. */
  85093. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  85094. /**
  85095. * Update an existing uniform buffer
  85096. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85097. * @param uniformBuffer defines the target uniform buffer
  85098. * @param elements defines the content to update
  85099. * @param offset defines the offset in the uniform buffer where update should start
  85100. * @param count defines the size of the data to update
  85101. */
  85102. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85103. private _resetVertexBufferBinding;
  85104. /**
  85105. * Creates a vertex buffer
  85106. * @param data the data for the vertex buffer
  85107. * @returns the new WebGL static buffer
  85108. */
  85109. createVertexBuffer(data: DataArray): WebGLBuffer;
  85110. /**
  85111. * Creates a dynamic vertex buffer
  85112. * @param data the data for the dynamic vertex buffer
  85113. * @returns the new WebGL dynamic buffer
  85114. */
  85115. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  85116. /**
  85117. * Update a dynamic index buffer
  85118. * @param indexBuffer defines the target index buffer
  85119. * @param indices defines the data to update
  85120. * @param offset defines the offset in the target index buffer where update should start
  85121. */
  85122. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  85123. /**
  85124. * Updates a dynamic vertex buffer.
  85125. * @param vertexBuffer the vertex buffer to update
  85126. * @param data the data used to update the vertex buffer
  85127. * @param byteOffset the byte offset of the data
  85128. * @param byteLength the byte length of the data
  85129. */
  85130. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  85131. private _resetIndexBufferBinding;
  85132. /**
  85133. * Creates a new index buffer
  85134. * @param indices defines the content of the index buffer
  85135. * @param updatable defines if the index buffer must be updatable
  85136. * @returns a new webGL buffer
  85137. */
  85138. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  85139. /**
  85140. * Bind a webGL buffer to the webGL context
  85141. * @param buffer defines the buffer to bind
  85142. */
  85143. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  85144. /**
  85145. * Bind an uniform buffer to the current webGL context
  85146. * @param buffer defines the buffer to bind
  85147. */
  85148. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  85149. /**
  85150. * Bind a buffer to the current webGL context at a given location
  85151. * @param buffer defines the buffer to bind
  85152. * @param location defines the index where to bind the buffer
  85153. */
  85154. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  85155. /**
  85156. * Bind a specific block at a given index in a specific shader program
  85157. * @param shaderProgram defines the shader program
  85158. * @param blockName defines the block name
  85159. * @param index defines the index where to bind the block
  85160. */
  85161. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  85162. private bindIndexBuffer;
  85163. private bindBuffer;
  85164. /**
  85165. * update the bound buffer with the given data
  85166. * @param data defines the data to update
  85167. */
  85168. updateArrayBuffer(data: Float32Array): void;
  85169. private _vertexAttribPointer;
  85170. private _bindIndexBufferWithCache;
  85171. private _bindVertexBuffersAttributes;
  85172. /**
  85173. * Records a vertex array object
  85174. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85175. * @param vertexBuffers defines the list of vertex buffers to store
  85176. * @param indexBuffer defines the index buffer to store
  85177. * @param effect defines the effect to store
  85178. * @returns the new vertex array object
  85179. */
  85180. recordVertexArrayObject(vertexBuffers: {
  85181. [key: string]: VertexBuffer;
  85182. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  85183. /**
  85184. * Bind a specific vertex array object
  85185. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85186. * @param vertexArrayObject defines the vertex array object to bind
  85187. * @param indexBuffer defines the index buffer to bind
  85188. */
  85189. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  85190. /**
  85191. * Bind webGl buffers directly to the webGL context
  85192. * @param vertexBuffer defines the vertex buffer to bind
  85193. * @param indexBuffer defines the index buffer to bind
  85194. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  85195. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  85196. * @param effect defines the effect associated with the vertex buffer
  85197. */
  85198. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  85199. private _unbindVertexArrayObject;
  85200. /**
  85201. * Bind a list of vertex buffers to the webGL context
  85202. * @param vertexBuffers defines the list of vertex buffers to bind
  85203. * @param indexBuffer defines the index buffer to bind
  85204. * @param effect defines the effect associated with the vertex buffers
  85205. */
  85206. bindBuffers(vertexBuffers: {
  85207. [key: string]: Nullable<VertexBuffer>;
  85208. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  85209. /**
  85210. * Unbind all instance attributes
  85211. */
  85212. unbindInstanceAttributes(): void;
  85213. /**
  85214. * Release and free the memory of a vertex array object
  85215. * @param vao defines the vertex array object to delete
  85216. */
  85217. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  85218. /** @hidden */
  85219. _releaseBuffer(buffer: WebGLBuffer): boolean;
  85220. /**
  85221. * Creates a webGL buffer to use with instanciation
  85222. * @param capacity defines the size of the buffer
  85223. * @returns the webGL buffer
  85224. */
  85225. createInstancesBuffer(capacity: number): WebGLBuffer;
  85226. /**
  85227. * Delete a webGL buffer used with instanciation
  85228. * @param buffer defines the webGL buffer to delete
  85229. */
  85230. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85231. /**
  85232. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85233. * @param instancesBuffer defines the webGL buffer to update and bind
  85234. * @param data defines the data to store in the buffer
  85235. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85236. */
  85237. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85238. /**
  85239. * Apply all cached states (depth, culling, stencil and alpha)
  85240. */
  85241. applyStates(): void;
  85242. /**
  85243. * Send a draw order
  85244. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85245. * @param indexStart defines the starting index
  85246. * @param indexCount defines the number of index to draw
  85247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85248. */
  85249. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85250. /**
  85251. * Draw a list of points
  85252. * @param verticesStart defines the index of first vertex to draw
  85253. * @param verticesCount defines the count of vertices to draw
  85254. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85255. */
  85256. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85257. /**
  85258. * Draw a list of unindexed primitives
  85259. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85260. * @param verticesStart defines the index of first vertex to draw
  85261. * @param verticesCount defines the count of vertices to draw
  85262. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85263. */
  85264. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85265. /**
  85266. * Draw a list of indexed primitives
  85267. * @param fillMode defines the primitive to use
  85268. * @param indexStart defines the starting index
  85269. * @param indexCount defines the number of index to draw
  85270. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85271. */
  85272. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85273. /**
  85274. * Draw a list of unindexed primitives
  85275. * @param fillMode defines the primitive to use
  85276. * @param verticesStart defines the index of first vertex to draw
  85277. * @param verticesCount defines the count of vertices to draw
  85278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85279. */
  85280. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85281. private _drawMode;
  85282. /** @hidden */
  85283. _releaseEffect(effect: Effect): void;
  85284. /** @hidden */
  85285. _deleteProgram(program: WebGLProgram): void;
  85286. /**
  85287. * Create a new effect (used to store vertex/fragment shaders)
  85288. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85289. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85290. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85291. * @param samplers defines an array of string used to represent textures
  85292. * @param defines defines the string containing the defines to use to compile the shaders
  85293. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85294. * @param onCompiled defines a function to call when the effect creation is successful
  85295. * @param onError defines a function to call when the effect creation has failed
  85296. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85297. * @returns the new Effect
  85298. */
  85299. 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;
  85300. private _compileShader;
  85301. private _compileRawShader;
  85302. /**
  85303. * Directly creates a webGL program
  85304. * @param vertexCode defines the vertex shader code to use
  85305. * @param fragmentCode defines the fragment shader code to use
  85306. * @param context defines the webGL context to use (if not set, the current one will be used)
  85307. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85308. * @returns the new webGL program
  85309. */
  85310. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85311. /**
  85312. * Creates a webGL program
  85313. * @param vertexCode defines the vertex shader code to use
  85314. * @param fragmentCode defines the fragment shader code to use
  85315. * @param defines defines the string containing the defines to use to compile the shaders
  85316. * @param context defines the webGL context to use (if not set, the current one will be used)
  85317. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85318. * @returns the new webGL program
  85319. */
  85320. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85321. private _createShaderProgram;
  85322. private _finalizeProgram;
  85323. /** @hidden */
  85324. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85325. /** @hidden */
  85326. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85327. /**
  85328. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85329. * @param shaderProgram defines the webGL program to use
  85330. * @param uniformsNames defines the list of uniform names
  85331. * @returns an array of webGL uniform locations
  85332. */
  85333. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85334. /**
  85335. * Gets the lsit of active attributes for a given webGL program
  85336. * @param shaderProgram defines the webGL program to use
  85337. * @param attributesNames defines the list of attribute names to get
  85338. * @returns an array of indices indicating the offset of each attribute
  85339. */
  85340. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85341. /**
  85342. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85343. * @param effect defines the effect to activate
  85344. */
  85345. enableEffect(effect: Nullable<Effect>): void;
  85346. /**
  85347. * Set the value of an uniform to an array of int32
  85348. * @param uniform defines the webGL uniform location where to store the value
  85349. * @param array defines the array of int32 to store
  85350. */
  85351. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85352. /**
  85353. * Set the value of an uniform to an array of int32 (stored as vec2)
  85354. * @param uniform defines the webGL uniform location where to store the value
  85355. * @param array defines the array of int32 to store
  85356. */
  85357. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85358. /**
  85359. * Set the value of an uniform to an array of int32 (stored as vec3)
  85360. * @param uniform defines the webGL uniform location where to store the value
  85361. * @param array defines the array of int32 to store
  85362. */
  85363. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85364. /**
  85365. * Set the value of an uniform to an array of int32 (stored as vec4)
  85366. * @param uniform defines the webGL uniform location where to store the value
  85367. * @param array defines the array of int32 to store
  85368. */
  85369. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85370. /**
  85371. * Set the value of an uniform to an array of float32
  85372. * @param uniform defines the webGL uniform location where to store the value
  85373. * @param array defines the array of float32 to store
  85374. */
  85375. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85376. /**
  85377. * Set the value of an uniform to an array of float32 (stored as vec2)
  85378. * @param uniform defines the webGL uniform location where to store the value
  85379. * @param array defines the array of float32 to store
  85380. */
  85381. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85382. /**
  85383. * Set the value of an uniform to an array of float32 (stored as vec3)
  85384. * @param uniform defines the webGL uniform location where to store the value
  85385. * @param array defines the array of float32 to store
  85386. */
  85387. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85388. /**
  85389. * Set the value of an uniform to an array of float32 (stored as vec4)
  85390. * @param uniform defines the webGL uniform location where to store the value
  85391. * @param array defines the array of float32 to store
  85392. */
  85393. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85394. /**
  85395. * Set the value of an uniform to an array of number
  85396. * @param uniform defines the webGL uniform location where to store the value
  85397. * @param array defines the array of number to store
  85398. */
  85399. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85400. /**
  85401. * Set the value of an uniform to an array of number (stored as vec2)
  85402. * @param uniform defines the webGL uniform location where to store the value
  85403. * @param array defines the array of number to store
  85404. */
  85405. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85406. /**
  85407. * Set the value of an uniform to an array of number (stored as vec3)
  85408. * @param uniform defines the webGL uniform location where to store the value
  85409. * @param array defines the array of number to store
  85410. */
  85411. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85412. /**
  85413. * Set the value of an uniform to an array of number (stored as vec4)
  85414. * @param uniform defines the webGL uniform location where to store the value
  85415. * @param array defines the array of number to store
  85416. */
  85417. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85418. /**
  85419. * Set the value of an uniform to an array of float32 (stored as matrices)
  85420. * @param uniform defines the webGL uniform location where to store the value
  85421. * @param matrices defines the array of float32 to store
  85422. */
  85423. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85424. /**
  85425. * Set the value of an uniform to a matrix
  85426. * @param uniform defines the webGL uniform location where to store the value
  85427. * @param matrix defines the matrix to store
  85428. */
  85429. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85430. /**
  85431. * Set the value of an uniform to a matrix (3x3)
  85432. * @param uniform defines the webGL uniform location where to store the value
  85433. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85434. */
  85435. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85436. /**
  85437. * Set the value of an uniform to a matrix (2x2)
  85438. * @param uniform defines the webGL uniform location where to store the value
  85439. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85440. */
  85441. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85442. /**
  85443. * Set the value of an uniform to a number (int)
  85444. * @param uniform defines the webGL uniform location where to store the value
  85445. * @param value defines the int number to store
  85446. */
  85447. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85448. /**
  85449. * Set the value of an uniform to a number (float)
  85450. * @param uniform defines the webGL uniform location where to store the value
  85451. * @param value defines the float number to store
  85452. */
  85453. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85454. /**
  85455. * Set the value of an uniform to a vec2
  85456. * @param uniform defines the webGL uniform location where to store the value
  85457. * @param x defines the 1st component of the value
  85458. * @param y defines the 2nd component of the value
  85459. */
  85460. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85461. /**
  85462. * Set the value of an uniform to a vec3
  85463. * @param uniform defines the webGL uniform location where to store the value
  85464. * @param x defines the 1st component of the value
  85465. * @param y defines the 2nd component of the value
  85466. * @param z defines the 3rd component of the value
  85467. */
  85468. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85469. /**
  85470. * Set the value of an uniform to a boolean
  85471. * @param uniform defines the webGL uniform location where to store the value
  85472. * @param bool defines the boolean to store
  85473. */
  85474. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85475. /**
  85476. * Set the value of an uniform to a vec4
  85477. * @param uniform defines the webGL uniform location where to store the value
  85478. * @param x defines the 1st component of the value
  85479. * @param y defines the 2nd component of the value
  85480. * @param z defines the 3rd component of the value
  85481. * @param w defines the 4th component of the value
  85482. */
  85483. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85484. /**
  85485. * Set the value of an uniform to a Color3
  85486. * @param uniform defines the webGL uniform location where to store the value
  85487. * @param color3 defines the color to store
  85488. */
  85489. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85490. /**
  85491. * Set the value of an uniform to a Color3 and an alpha value
  85492. * @param uniform defines the webGL uniform location where to store the value
  85493. * @param color3 defines the color to store
  85494. * @param alpha defines the alpha component to store
  85495. */
  85496. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85497. /**
  85498. * Sets a Color4 on a uniform variable
  85499. * @param uniform defines the uniform location
  85500. * @param color4 defines the value to be set
  85501. */
  85502. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85503. /**
  85504. * Set various states to the webGL context
  85505. * @param culling defines backface culling state
  85506. * @param zOffset defines the value to apply to zOffset (0 by default)
  85507. * @param force defines if states must be applied even if cache is up to date
  85508. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85509. */
  85510. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85511. /**
  85512. * Set the z offset to apply to current rendering
  85513. * @param value defines the offset to apply
  85514. */
  85515. setZOffset(value: number): void;
  85516. /**
  85517. * Gets the current value of the zOffset
  85518. * @returns the current zOffset state
  85519. */
  85520. getZOffset(): number;
  85521. /**
  85522. * Enable or disable depth buffering
  85523. * @param enable defines the state to set
  85524. */
  85525. setDepthBuffer(enable: boolean): void;
  85526. /**
  85527. * Gets a boolean indicating if depth writing is enabled
  85528. * @returns the current depth writing state
  85529. */
  85530. getDepthWrite(): boolean;
  85531. /**
  85532. * Enable or disable depth writing
  85533. * @param enable defines the state to set
  85534. */
  85535. setDepthWrite(enable: boolean): void;
  85536. /**
  85537. * Enable or disable color writing
  85538. * @param enable defines the state to set
  85539. */
  85540. setColorWrite(enable: boolean): void;
  85541. /**
  85542. * Gets a boolean indicating if color writing is enabled
  85543. * @returns the current color writing state
  85544. */
  85545. getColorWrite(): boolean;
  85546. /**
  85547. * Sets alpha constants used by some alpha blending modes
  85548. * @param r defines the red component
  85549. * @param g defines the green component
  85550. * @param b defines the blue component
  85551. * @param a defines the alpha component
  85552. */
  85553. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85554. /**
  85555. * Sets the current alpha mode
  85556. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85557. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85558. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85559. */
  85560. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85561. /**
  85562. * Gets the current alpha mode
  85563. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85564. * @returns the current alpha mode
  85565. */
  85566. getAlphaMode(): number;
  85567. /**
  85568. * Clears the list of texture accessible through engine.
  85569. * This can help preventing texture load conflict due to name collision.
  85570. */
  85571. clearInternalTexturesCache(): void;
  85572. /**
  85573. * Force the entire cache to be cleared
  85574. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85575. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85576. */
  85577. wipeCaches(bruteForce?: boolean): void;
  85578. /**
  85579. * Set the compressed texture format to use, based on the formats you have, and the formats
  85580. * supported by the hardware / browser.
  85581. *
  85582. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85583. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85584. * to API arguments needed to compressed textures. This puts the burden on the container
  85585. * generator to house the arcane code for determining these for current & future formats.
  85586. *
  85587. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85588. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85589. *
  85590. * Note: The result of this call is not taken into account when a texture is base64.
  85591. *
  85592. * @param formatsAvailable defines the list of those format families you have created
  85593. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85594. *
  85595. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85596. * @returns The extension selected.
  85597. */
  85598. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85599. private _getSamplingParameters;
  85600. private _partialLoadImg;
  85601. private _cascadeLoadImgs;
  85602. /** @hidden */
  85603. _createTexture(): WebGLTexture;
  85604. /**
  85605. * Usually called from Texture.ts.
  85606. * Passed information to create a WebGLTexture
  85607. * @param urlArg defines a value which contains one of the following:
  85608. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85609. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85610. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85612. * @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)
  85613. * @param scene needed for loading to the correct scene
  85614. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85615. * @param onLoad optional callback to be called upon successful completion
  85616. * @param onError optional callback to be called upon failure
  85617. * @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
  85618. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85619. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85620. * @param forcedExtension defines the extension to use to pick the right loader
  85621. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85622. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85623. */
  85624. 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;
  85625. private _rescaleTexture;
  85626. /**
  85627. * Update a raw texture
  85628. * @param texture defines the texture to update
  85629. * @param data defines the data to store in the texture
  85630. * @param format defines the format of the data
  85631. * @param invertY defines if data must be stored with Y axis inverted
  85632. * @param compression defines the compression used (null by default)
  85633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85634. */
  85635. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85636. /**
  85637. * Creates a raw texture
  85638. * @param data defines the data to store in the texture
  85639. * @param width defines the width of the texture
  85640. * @param height defines the height of the texture
  85641. * @param format defines the format of the data
  85642. * @param generateMipMaps defines if the engine should generate the mip levels
  85643. * @param invertY defines if data must be stored with Y axis inverted
  85644. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85645. * @param compression defines the compression used (null by default)
  85646. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85647. * @returns the raw texture inside an InternalTexture
  85648. */
  85649. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85650. private _unpackFlipYCached;
  85651. /**
  85652. * In case you are sharing the context with other applications, it might
  85653. * be interested to not cache the unpack flip y state to ensure a consistent
  85654. * value would be set.
  85655. */
  85656. enableUnpackFlipYCached: boolean;
  85657. /** @hidden */
  85658. _unpackFlipY(value: boolean): void;
  85659. /** @hidden */
  85660. _getUnpackAlignement(): number;
  85661. /**
  85662. * Creates a dynamic texture
  85663. * @param width defines the width of the texture
  85664. * @param height defines the height of the texture
  85665. * @param generateMipMaps defines if the engine should generate the mip levels
  85666. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85667. * @returns the dynamic texture inside an InternalTexture
  85668. */
  85669. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85670. /**
  85671. * Update the sampling mode of a given texture
  85672. * @param samplingMode defines the required sampling mode
  85673. * @param texture defines the texture to update
  85674. */
  85675. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85676. /**
  85677. * Update the content of a dynamic texture
  85678. * @param texture defines the texture to update
  85679. * @param canvas defines the canvas containing the source
  85680. * @param invertY defines if data must be stored with Y axis inverted
  85681. * @param premulAlpha defines if alpha is stored as premultiplied
  85682. * @param format defines the format of the data
  85683. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85684. */
  85685. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85686. /**
  85687. * Update a video texture
  85688. * @param texture defines the texture to update
  85689. * @param video defines the video element to use
  85690. * @param invertY defines if data must be stored with Y axis inverted
  85691. */
  85692. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85693. /**
  85694. * Updates a depth texture Comparison Mode and Function.
  85695. * If the comparison Function is equal to 0, the mode will be set to none.
  85696. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85697. * @param texture The texture to set the comparison function for
  85698. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85699. */
  85700. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85701. private _setupDepthStencilTexture;
  85702. /**
  85703. * Creates a depth stencil texture.
  85704. * This is only available in WebGL 2 or with the depth texture extension available.
  85705. * @param size The size of face edge in the texture.
  85706. * @param options The options defining the texture.
  85707. * @returns The texture
  85708. */
  85709. createDepthStencilTexture(size: number | {
  85710. width: number;
  85711. height: number;
  85712. }, options: DepthTextureCreationOptions): InternalTexture;
  85713. /**
  85714. * Creates a depth stencil texture.
  85715. * This is only available in WebGL 2 or with the depth texture extension available.
  85716. * @param size The size of face edge in the texture.
  85717. * @param options The options defining the texture.
  85718. * @returns The texture
  85719. */
  85720. private _createDepthStencilTexture;
  85721. /**
  85722. * Creates a depth stencil cube texture.
  85723. * This is only available in WebGL 2.
  85724. * @param size The size of face edge in the cube texture.
  85725. * @param options The options defining the cube texture.
  85726. * @returns The cube texture
  85727. */
  85728. private _createDepthStencilCubeTexture;
  85729. /**
  85730. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85731. * @param renderTarget The render target to set the frame buffer for
  85732. */
  85733. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85734. /**
  85735. * Creates a new render target texture
  85736. * @param size defines the size of the texture
  85737. * @param options defines the options used to create the texture
  85738. * @returns a new render target texture stored in an InternalTexture
  85739. */
  85740. createRenderTargetTexture(size: number | {
  85741. width: number;
  85742. height: number;
  85743. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85744. /**
  85745. * Create a multi render target texture
  85746. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85747. * @param size defines the size of the texture
  85748. * @param options defines the creation options
  85749. * @returns the cube texture as an InternalTexture
  85750. */
  85751. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85752. private _setupFramebufferDepthAttachments;
  85753. /**
  85754. * Updates the sample count of a render target texture
  85755. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85756. * @param texture defines the texture to update
  85757. * @param samples defines the sample count to set
  85758. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85759. */
  85760. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85761. /**
  85762. * Update the sample count for a given multiple render target texture
  85763. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85764. * @param textures defines the textures to update
  85765. * @param samples defines the sample count to set
  85766. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85767. */
  85768. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85769. /** @hidden */
  85770. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85771. /** @hidden */
  85772. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85773. /** @hidden */
  85774. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85775. /** @hidden */
  85776. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85777. /**
  85778. * Creates a new render target cube texture
  85779. * @param size defines the size of the texture
  85780. * @param options defines the options used to create the texture
  85781. * @returns a new render target cube texture stored in an InternalTexture
  85782. */
  85783. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85784. /**
  85785. * Creates a cube texture
  85786. * @param rootUrl defines the url where the files to load is located
  85787. * @param scene defines the current scene
  85788. * @param files defines the list of files to load (1 per face)
  85789. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85790. * @param onLoad defines an optional callback raised when the texture is loaded
  85791. * @param onError defines an optional callback raised if there is an issue to load the texture
  85792. * @param format defines the format of the data
  85793. * @param forcedExtension defines the extension to use to pick the right loader
  85794. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85795. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85796. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85797. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85798. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85799. * @returns the cube texture as an InternalTexture
  85800. */
  85801. 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;
  85802. /**
  85803. * @hidden
  85804. */
  85805. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85806. /**
  85807. * Update a raw cube texture
  85808. * @param texture defines the texture to udpdate
  85809. * @param data defines the data to store
  85810. * @param format defines the data format
  85811. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85812. * @param invertY defines if data must be stored with Y axis inverted
  85813. * @param compression defines the compression used (null by default)
  85814. * @param level defines which level of the texture to update
  85815. */
  85816. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85817. /**
  85818. * Creates a new raw cube texture
  85819. * @param data defines the array of data to use to create each face
  85820. * @param size defines the size of the textures
  85821. * @param format defines the format of the data
  85822. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85823. * @param generateMipMaps defines if the engine should generate the mip levels
  85824. * @param invertY defines if data must be stored with Y axis inverted
  85825. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85826. * @param compression defines the compression used (null by default)
  85827. * @returns the cube texture as an InternalTexture
  85828. */
  85829. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85830. /**
  85831. * Creates a new raw cube texture from a specified url
  85832. * @param url defines the url where the data is located
  85833. * @param scene defines the current scene
  85834. * @param size defines the size of the textures
  85835. * @param format defines the format of the data
  85836. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85837. * @param noMipmap defines if the engine should avoid generating the mip levels
  85838. * @param callback defines a callback used to extract texture data from loaded data
  85839. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85840. * @param onLoad defines a callback called when texture is loaded
  85841. * @param onError defines a callback called if there is an error
  85842. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85843. * @param invertY defines if data must be stored with Y axis inverted
  85844. * @returns the cube texture as an InternalTexture
  85845. */
  85846. 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;
  85847. /**
  85848. * Update a raw 3D texture
  85849. * @param texture defines the texture to update
  85850. * @param data defines the data to store
  85851. * @param format defines the data format
  85852. * @param invertY defines if data must be stored with Y axis inverted
  85853. * @param compression defines the used compression (can be null)
  85854. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85855. */
  85856. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85857. /**
  85858. * Creates a new raw 3D texture
  85859. * @param data defines the data used to create the texture
  85860. * @param width defines the width of the texture
  85861. * @param height defines the height of the texture
  85862. * @param depth defines the depth of the texture
  85863. * @param format defines the format of the texture
  85864. * @param generateMipMaps defines if the engine must generate mip levels
  85865. * @param invertY defines if data must be stored with Y axis inverted
  85866. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85867. * @param compression defines the compressed used (can be null)
  85868. * @param textureType defines the compressed used (can be null)
  85869. * @returns a new raw 3D texture (stored in an InternalTexture)
  85870. */
  85871. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85872. private _prepareWebGLTextureContinuation;
  85873. private _prepareWebGLTexture;
  85874. private _convertRGBtoRGBATextureData;
  85875. /** @hidden */
  85876. _releaseFramebufferObjects(texture: InternalTexture): void;
  85877. /** @hidden */
  85878. _releaseTexture(texture: InternalTexture): void;
  85879. private setProgram;
  85880. private _boundUniforms;
  85881. /**
  85882. * Binds an effect to the webGL context
  85883. * @param effect defines the effect to bind
  85884. */
  85885. bindSamplers(effect: Effect): void;
  85886. private _moveBoundTextureOnTop;
  85887. private _getCorrectTextureChannel;
  85888. private _linkTrackers;
  85889. private _removeDesignatedSlot;
  85890. private _activateCurrentTexture;
  85891. /** @hidden */
  85892. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85893. /** @hidden */
  85894. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85895. /**
  85896. * Sets a texture to the webGL context from a postprocess
  85897. * @param channel defines the channel to use
  85898. * @param postProcess defines the source postprocess
  85899. */
  85900. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85901. /**
  85902. * Binds the output of the passed in post process to the texture channel specified
  85903. * @param channel The channel the texture should be bound to
  85904. * @param postProcess The post process which's output should be bound
  85905. */
  85906. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85907. /**
  85908. * Unbind all textures from the webGL context
  85909. */
  85910. unbindAllTextures(): void;
  85911. /**
  85912. * Sets a texture to the according uniform.
  85913. * @param channel The texture channel
  85914. * @param uniform The uniform to set
  85915. * @param texture The texture to apply
  85916. */
  85917. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85918. /**
  85919. * Sets a depth stencil texture from a render target to the according uniform.
  85920. * @param channel The texture channel
  85921. * @param uniform The uniform to set
  85922. * @param texture The render target texture containing the depth stencil texture to apply
  85923. */
  85924. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85925. private _bindSamplerUniformToChannel;
  85926. private _getTextureWrapMode;
  85927. private _setTexture;
  85928. /**
  85929. * Sets an array of texture to the webGL context
  85930. * @param channel defines the channel where the texture array must be set
  85931. * @param uniform defines the associated uniform location
  85932. * @param textures defines the array of textures to bind
  85933. */
  85934. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85935. /** @hidden */
  85936. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85937. private _setTextureParameterFloat;
  85938. private _setTextureParameterInteger;
  85939. /**
  85940. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85941. * @param x defines the x coordinate of the rectangle where pixels must be read
  85942. * @param y defines the y coordinate of the rectangle where pixels must be read
  85943. * @param width defines the width of the rectangle where pixels must be read
  85944. * @param height defines the height of the rectangle where pixels must be read
  85945. * @returns a Uint8Array containing RGBA colors
  85946. */
  85947. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85948. /**
  85949. * Add an externaly attached data from its key.
  85950. * This method call will fail and return false, if such key already exists.
  85951. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85952. * @param key the unique key that identifies the data
  85953. * @param data the data object to associate to the key for this Engine instance
  85954. * @return true if no such key were already present and the data was added successfully, false otherwise
  85955. */
  85956. addExternalData<T>(key: string, data: T): boolean;
  85957. /**
  85958. * Get an externaly attached data from its key
  85959. * @param key the unique key that identifies the data
  85960. * @return the associated data, if present (can be null), or undefined if not present
  85961. */
  85962. getExternalData<T>(key: string): T;
  85963. /**
  85964. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85965. * @param key the unique key that identifies the data
  85966. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85967. * @return the associated data, can be null if the factory returned null.
  85968. */
  85969. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85970. /**
  85971. * Remove an externaly attached data from the Engine instance
  85972. * @param key the unique key that identifies the data
  85973. * @return true if the data was successfully removed, false if it doesn't exist
  85974. */
  85975. removeExternalData(key: string): boolean;
  85976. /**
  85977. * Unbind all vertex attributes from the webGL context
  85978. */
  85979. unbindAllAttributes(): void;
  85980. /**
  85981. * 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
  85982. */
  85983. releaseEffects(): void;
  85984. /**
  85985. * Dispose and release all associated resources
  85986. */
  85987. dispose(): void;
  85988. /**
  85989. * Display the loading screen
  85990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85991. */
  85992. displayLoadingUI(): void;
  85993. /**
  85994. * Hide the loading screen
  85995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85996. */
  85997. hideLoadingUI(): void;
  85998. /**
  85999. * Gets the current loading screen object
  86000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86001. */
  86002. /**
  86003. * Sets the current loading screen object
  86004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86005. */
  86006. loadingScreen: ILoadingScreen;
  86007. /**
  86008. * Sets the current loading screen text
  86009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86010. */
  86011. loadingUIText: string;
  86012. /**
  86013. * Sets the current loading screen background color
  86014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86015. */
  86016. loadingUIBackgroundColor: string;
  86017. /**
  86018. * Attach a new callback raised when context lost event is fired
  86019. * @param callback defines the callback to call
  86020. */
  86021. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86022. /**
  86023. * Attach a new callback raised when context restored event is fired
  86024. * @param callback defines the callback to call
  86025. */
  86026. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86027. /**
  86028. * Gets the source code of the vertex shader associated with a specific webGL program
  86029. * @param program defines the program to use
  86030. * @returns a string containing the source code of the vertex shader associated with the program
  86031. */
  86032. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  86033. /**
  86034. * Gets the source code of the fragment shader associated with a specific webGL program
  86035. * @param program defines the program to use
  86036. * @returns a string containing the source code of the fragment shader associated with the program
  86037. */
  86038. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  86039. /**
  86040. * Get the current error code of the webGL context
  86041. * @returns the error code
  86042. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  86043. */
  86044. getError(): number;
  86045. /**
  86046. * Gets the current framerate
  86047. * @returns a number representing the framerate
  86048. */
  86049. getFps(): number;
  86050. /**
  86051. * Gets the time spent between current and previous frame
  86052. * @returns a number representing the delta time in ms
  86053. */
  86054. getDeltaTime(): number;
  86055. private _measureFps;
  86056. /** @hidden */
  86057. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  86058. private _canRenderToFloatFramebuffer;
  86059. private _canRenderToHalfFloatFramebuffer;
  86060. private _canRenderToFramebuffer;
  86061. /** @hidden */
  86062. _getWebGLTextureType(type: number): number;
  86063. private _getInternalFormat;
  86064. /** @hidden */
  86065. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  86066. /** @hidden */
  86067. _getRGBAMultiSampleBufferFormat(type: number): number;
  86068. /** @hidden */
  86069. _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;
  86070. /** @hidden */
  86071. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  86072. private _partialLoadFile;
  86073. private _cascadeLoadFiles;
  86074. /**
  86075. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  86076. * @returns true if the engine can be created
  86077. * @ignorenaming
  86078. */
  86079. static isSupported(): boolean;
  86080. }
  86081. }
  86082. declare module BABYLON {
  86083. /**
  86084. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86085. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86086. */
  86087. export class EffectFallbacks {
  86088. private _defines;
  86089. private _currentRank;
  86090. private _maxRank;
  86091. private _mesh;
  86092. /**
  86093. * Removes the fallback from the bound mesh.
  86094. */
  86095. unBindMesh(): void;
  86096. /**
  86097. * Adds a fallback on the specified property.
  86098. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86099. * @param define The name of the define in the shader
  86100. */
  86101. addFallback(rank: number, define: string): void;
  86102. /**
  86103. * Sets the mesh to use CPU skinning when needing to fallback.
  86104. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86105. * @param mesh The mesh to use the fallbacks.
  86106. */
  86107. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86108. /**
  86109. * Checks to see if more fallbacks are still availible.
  86110. */
  86111. readonly isMoreFallbacks: boolean;
  86112. /**
  86113. * Removes the defines that shoould be removed when falling back.
  86114. * @param currentDefines defines the current define statements for the shader.
  86115. * @param effect defines the current effect we try to compile
  86116. * @returns The resulting defines with defines of the current rank removed.
  86117. */
  86118. reduce(currentDefines: string, effect: Effect): string;
  86119. }
  86120. /**
  86121. * Options to be used when creating an effect.
  86122. */
  86123. export class EffectCreationOptions {
  86124. /**
  86125. * Atrributes that will be used in the shader.
  86126. */
  86127. attributes: string[];
  86128. /**
  86129. * Uniform varible names that will be set in the shader.
  86130. */
  86131. uniformsNames: string[];
  86132. /**
  86133. * Uniform buffer varible names that will be set in the shader.
  86134. */
  86135. uniformBuffersNames: string[];
  86136. /**
  86137. * Sampler texture variable names that will be set in the shader.
  86138. */
  86139. samplers: string[];
  86140. /**
  86141. * Define statements that will be set in the shader.
  86142. */
  86143. defines: any;
  86144. /**
  86145. * Possible fallbacks for this effect to improve performance when needed.
  86146. */
  86147. fallbacks: Nullable<EffectFallbacks>;
  86148. /**
  86149. * Callback that will be called when the shader is compiled.
  86150. */
  86151. onCompiled: Nullable<(effect: Effect) => void>;
  86152. /**
  86153. * Callback that will be called if an error occurs during shader compilation.
  86154. */
  86155. onError: Nullable<(effect: Effect, errors: string) => void>;
  86156. /**
  86157. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86158. */
  86159. indexParameters: any;
  86160. /**
  86161. * Max number of lights that can be used in the shader.
  86162. */
  86163. maxSimultaneousLights: number;
  86164. /**
  86165. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  86166. */
  86167. transformFeedbackVaryings: Nullable<string[]>;
  86168. }
  86169. /**
  86170. * Effect containing vertex and fragment shader that can be executed on an object.
  86171. */
  86172. export class Effect {
  86173. /**
  86174. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86175. */
  86176. static ShadersRepository: string;
  86177. /**
  86178. * Name of the effect.
  86179. */
  86180. name: any;
  86181. /**
  86182. * String container all the define statements that should be set on the shader.
  86183. */
  86184. defines: string;
  86185. /**
  86186. * Callback that will be called when the shader is compiled.
  86187. */
  86188. onCompiled: Nullable<(effect: Effect) => void>;
  86189. /**
  86190. * Callback that will be called if an error occurs during shader compilation.
  86191. */
  86192. onError: Nullable<(effect: Effect, errors: string) => void>;
  86193. /**
  86194. * Callback that will be called when effect is bound.
  86195. */
  86196. onBind: Nullable<(effect: Effect) => void>;
  86197. /**
  86198. * Unique ID of the effect.
  86199. */
  86200. uniqueId: number;
  86201. /**
  86202. * Observable that will be called when the shader is compiled.
  86203. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  86204. */
  86205. onCompileObservable: Observable<Effect>;
  86206. /**
  86207. * Observable that will be called if an error occurs during shader compilation.
  86208. */
  86209. onErrorObservable: Observable<Effect>;
  86210. /** @hidden */
  86211. _onBindObservable: Nullable<Observable<Effect>>;
  86212. /**
  86213. * Observable that will be called when effect is bound.
  86214. */
  86215. readonly onBindObservable: Observable<Effect>;
  86216. /** @hidden */
  86217. _bonesComputationForcedToCPU: boolean;
  86218. private static _uniqueIdSeed;
  86219. private _engine;
  86220. private _uniformBuffersNames;
  86221. private _uniformsNames;
  86222. private _samplers;
  86223. private _isReady;
  86224. private _compilationError;
  86225. private _attributesNames;
  86226. private _attributes;
  86227. private _uniforms;
  86228. /**
  86229. * Key for the effect.
  86230. * @hidden
  86231. */
  86232. _key: string;
  86233. private _indexParameters;
  86234. private _fallbacks;
  86235. private _vertexSourceCode;
  86236. private _fragmentSourceCode;
  86237. private _vertexSourceCodeOverride;
  86238. private _fragmentSourceCodeOverride;
  86239. private _transformFeedbackVaryings;
  86240. /**
  86241. * Compiled shader to webGL program.
  86242. * @hidden
  86243. */
  86244. _program: WebGLProgram;
  86245. private _valueCache;
  86246. private static _baseCache;
  86247. /**
  86248. * Instantiates an effect.
  86249. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86250. * @param baseName Name of the effect.
  86251. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86252. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86253. * @param samplers List of sampler variables that will be passed to the shader.
  86254. * @param engine Engine to be used to render the effect
  86255. * @param defines Define statements to be added to the shader.
  86256. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86257. * @param onCompiled Callback that will be called when the shader is compiled.
  86258. * @param onError Callback that will be called if an error occurs during shader compilation.
  86259. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86260. */
  86261. 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);
  86262. /**
  86263. * Unique key for this effect
  86264. */
  86265. readonly key: string;
  86266. /**
  86267. * If the effect has been compiled and prepared.
  86268. * @returns if the effect is compiled and prepared.
  86269. */
  86270. isReady(): boolean;
  86271. /**
  86272. * The engine the effect was initialized with.
  86273. * @returns the engine.
  86274. */
  86275. getEngine(): Engine;
  86276. /**
  86277. * The compiled webGL program for the effect
  86278. * @returns the webGL program.
  86279. */
  86280. getProgram(): WebGLProgram;
  86281. /**
  86282. * The set of names of attribute variables for the shader.
  86283. * @returns An array of attribute names.
  86284. */
  86285. getAttributesNames(): string[];
  86286. /**
  86287. * Returns the attribute at the given index.
  86288. * @param index The index of the attribute.
  86289. * @returns The location of the attribute.
  86290. */
  86291. getAttributeLocation(index: number): number;
  86292. /**
  86293. * Returns the attribute based on the name of the variable.
  86294. * @param name of the attribute to look up.
  86295. * @returns the attribute location.
  86296. */
  86297. getAttributeLocationByName(name: string): number;
  86298. /**
  86299. * The number of attributes.
  86300. * @returns the numnber of attributes.
  86301. */
  86302. getAttributesCount(): number;
  86303. /**
  86304. * Gets the index of a uniform variable.
  86305. * @param uniformName of the uniform to look up.
  86306. * @returns the index.
  86307. */
  86308. getUniformIndex(uniformName: string): number;
  86309. /**
  86310. * Returns the attribute based on the name of the variable.
  86311. * @param uniformName of the uniform to look up.
  86312. * @returns the location of the uniform.
  86313. */
  86314. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86315. /**
  86316. * Returns an array of sampler variable names
  86317. * @returns The array of sampler variable neames.
  86318. */
  86319. getSamplers(): string[];
  86320. /**
  86321. * The error from the last compilation.
  86322. * @returns the error string.
  86323. */
  86324. getCompilationError(): string;
  86325. /**
  86326. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86327. * @param func The callback to be used.
  86328. */
  86329. executeWhenCompiled(func: (effect: Effect) => void): void;
  86330. private _checkIsReady;
  86331. /** @hidden */
  86332. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86333. /** @hidden */
  86334. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86335. /** @hidden */
  86336. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86337. private _processShaderConversion;
  86338. private _processIncludes;
  86339. private _processPrecision;
  86340. /**
  86341. * Recompiles the webGL program
  86342. * @param vertexSourceCode The source code for the vertex shader.
  86343. * @param fragmentSourceCode The source code for the fragment shader.
  86344. * @param onCompiled Callback called when completed.
  86345. * @param onError Callback called on error.
  86346. * @hidden
  86347. */
  86348. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86349. /**
  86350. * Gets the uniform locations of the the specified variable names
  86351. * @param names THe names of the variables to lookup.
  86352. * @returns Array of locations in the same order as variable names.
  86353. */
  86354. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86355. /**
  86356. * Prepares the effect
  86357. * @hidden
  86358. */
  86359. _prepareEffect(): void;
  86360. /**
  86361. * Checks if the effect is supported. (Must be called after compilation)
  86362. */
  86363. readonly isSupported: boolean;
  86364. /**
  86365. * Binds a texture to the engine to be used as output of the shader.
  86366. * @param channel Name of the output variable.
  86367. * @param texture Texture to bind.
  86368. * @hidden
  86369. */
  86370. _bindTexture(channel: string, texture: InternalTexture): void;
  86371. /**
  86372. * Sets a texture on the engine to be used in the shader.
  86373. * @param channel Name of the sampler variable.
  86374. * @param texture Texture to set.
  86375. */
  86376. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86377. /**
  86378. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86379. * @param channel Name of the sampler variable.
  86380. * @param texture Texture to set.
  86381. */
  86382. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86383. /**
  86384. * Sets an array of textures on the engine to be used in the shader.
  86385. * @param channel Name of the variable.
  86386. * @param textures Textures to set.
  86387. */
  86388. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86389. /**
  86390. * 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)
  86391. * @param channel Name of the sampler variable.
  86392. * @param postProcess Post process to get the input texture from.
  86393. */
  86394. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86395. /**
  86396. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86397. * 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)
  86398. * @param channel Name of the sampler variable.
  86399. * @param postProcess Post process to get the output texture from.
  86400. */
  86401. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86402. /** @hidden */
  86403. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86404. /** @hidden */
  86405. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86406. /** @hidden */
  86407. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86408. /** @hidden */
  86409. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86410. /**
  86411. * Binds a buffer to a uniform.
  86412. * @param buffer Buffer to bind.
  86413. * @param name Name of the uniform variable to bind to.
  86414. */
  86415. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86416. /**
  86417. * Binds block to a uniform.
  86418. * @param blockName Name of the block to bind.
  86419. * @param index Index to bind.
  86420. */
  86421. bindUniformBlock(blockName: string, index: number): void;
  86422. /**
  86423. * Sets an interger value on a uniform variable.
  86424. * @param uniformName Name of the variable.
  86425. * @param value Value to be set.
  86426. * @returns this effect.
  86427. */
  86428. setInt(uniformName: string, value: number): Effect;
  86429. /**
  86430. * Sets an int array on a uniform variable.
  86431. * @param uniformName Name of the variable.
  86432. * @param array array to be set.
  86433. * @returns this effect.
  86434. */
  86435. setIntArray(uniformName: string, array: Int32Array): Effect;
  86436. /**
  86437. * 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)
  86438. * @param uniformName Name of the variable.
  86439. * @param array array to be set.
  86440. * @returns this effect.
  86441. */
  86442. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86443. /**
  86444. * 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)
  86445. * @param uniformName Name of the variable.
  86446. * @param array array to be set.
  86447. * @returns this effect.
  86448. */
  86449. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86450. /**
  86451. * 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)
  86452. * @param uniformName Name of the variable.
  86453. * @param array array to be set.
  86454. * @returns this effect.
  86455. */
  86456. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86457. /**
  86458. * Sets an float array on a uniform variable.
  86459. * @param uniformName Name of the variable.
  86460. * @param array array to be set.
  86461. * @returns this effect.
  86462. */
  86463. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86464. /**
  86465. * 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)
  86466. * @param uniformName Name of the variable.
  86467. * @param array array to be set.
  86468. * @returns this effect.
  86469. */
  86470. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86471. /**
  86472. * 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)
  86473. * @param uniformName Name of the variable.
  86474. * @param array array to be set.
  86475. * @returns this effect.
  86476. */
  86477. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86478. /**
  86479. * 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)
  86480. * @param uniformName Name of the variable.
  86481. * @param array array to be set.
  86482. * @returns this effect.
  86483. */
  86484. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86485. /**
  86486. * Sets an array on a uniform variable.
  86487. * @param uniformName Name of the variable.
  86488. * @param array array to be set.
  86489. * @returns this effect.
  86490. */
  86491. setArray(uniformName: string, array: number[]): Effect;
  86492. /**
  86493. * 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)
  86494. * @param uniformName Name of the variable.
  86495. * @param array array to be set.
  86496. * @returns this effect.
  86497. */
  86498. setArray2(uniformName: string, array: number[]): Effect;
  86499. /**
  86500. * 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)
  86501. * @param uniformName Name of the variable.
  86502. * @param array array to be set.
  86503. * @returns this effect.
  86504. */
  86505. setArray3(uniformName: string, array: number[]): Effect;
  86506. /**
  86507. * 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)
  86508. * @param uniformName Name of the variable.
  86509. * @param array array to be set.
  86510. * @returns this effect.
  86511. */
  86512. setArray4(uniformName: string, array: number[]): Effect;
  86513. /**
  86514. * Sets matrices on a uniform variable.
  86515. * @param uniformName Name of the variable.
  86516. * @param matrices matrices to be set.
  86517. * @returns this effect.
  86518. */
  86519. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86520. /**
  86521. * Sets matrix on a uniform variable.
  86522. * @param uniformName Name of the variable.
  86523. * @param matrix matrix to be set.
  86524. * @returns this effect.
  86525. */
  86526. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86527. /**
  86528. * 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)
  86529. * @param uniformName Name of the variable.
  86530. * @param matrix matrix to be set.
  86531. * @returns this effect.
  86532. */
  86533. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86534. /**
  86535. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86536. * @param uniformName Name of the variable.
  86537. * @param matrix matrix to be set.
  86538. * @returns this effect.
  86539. */
  86540. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86541. /**
  86542. * Sets a float on a uniform variable.
  86543. * @param uniformName Name of the variable.
  86544. * @param value value to be set.
  86545. * @returns this effect.
  86546. */
  86547. setFloat(uniformName: string, value: number): Effect;
  86548. /**
  86549. * Sets a boolean on a uniform variable.
  86550. * @param uniformName Name of the variable.
  86551. * @param bool value to be set.
  86552. * @returns this effect.
  86553. */
  86554. setBool(uniformName: string, bool: boolean): Effect;
  86555. /**
  86556. * Sets a Vector2 on a uniform variable.
  86557. * @param uniformName Name of the variable.
  86558. * @param vector2 vector2 to be set.
  86559. * @returns this effect.
  86560. */
  86561. setVector2(uniformName: string, vector2: Vector2): Effect;
  86562. /**
  86563. * Sets a float2 on a uniform variable.
  86564. * @param uniformName Name of the variable.
  86565. * @param x First float in float2.
  86566. * @param y Second float in float2.
  86567. * @returns this effect.
  86568. */
  86569. setFloat2(uniformName: string, x: number, y: number): Effect;
  86570. /**
  86571. * Sets a Vector3 on a uniform variable.
  86572. * @param uniformName Name of the variable.
  86573. * @param vector3 Value to be set.
  86574. * @returns this effect.
  86575. */
  86576. setVector3(uniformName: string, vector3: Vector3): Effect;
  86577. /**
  86578. * Sets a float3 on a uniform variable.
  86579. * @param uniformName Name of the variable.
  86580. * @param x First float in float3.
  86581. * @param y Second float in float3.
  86582. * @param z Third float in float3.
  86583. * @returns this effect.
  86584. */
  86585. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86586. /**
  86587. * Sets a Vector4 on a uniform variable.
  86588. * @param uniformName Name of the variable.
  86589. * @param vector4 Value to be set.
  86590. * @returns this effect.
  86591. */
  86592. setVector4(uniformName: string, vector4: Vector4): Effect;
  86593. /**
  86594. * Sets a float4 on a uniform variable.
  86595. * @param uniformName Name of the variable.
  86596. * @param x First float in float4.
  86597. * @param y Second float in float4.
  86598. * @param z Third float in float4.
  86599. * @param w Fourth float in float4.
  86600. * @returns this effect.
  86601. */
  86602. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86603. /**
  86604. * Sets a Color3 on a uniform variable.
  86605. * @param uniformName Name of the variable.
  86606. * @param color3 Value to be set.
  86607. * @returns this effect.
  86608. */
  86609. setColor3(uniformName: string, color3: Color3): Effect;
  86610. /**
  86611. * Sets a Color4 on a uniform variable.
  86612. * @param uniformName Name of the variable.
  86613. * @param color3 Value to be set.
  86614. * @param alpha Alpha value to be set.
  86615. * @returns this effect.
  86616. */
  86617. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86618. /**
  86619. * Sets a Color4 on a uniform variable
  86620. * @param uniformName defines the name of the variable
  86621. * @param color4 defines the value to be set
  86622. * @returns this effect.
  86623. */
  86624. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86625. /**
  86626. * This function will add a new shader to the shader store
  86627. * @param name the name of the shader
  86628. * @param pixelShader optional pixel shader content
  86629. * @param vertexShader optional vertex shader content
  86630. */
  86631. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86632. /**
  86633. * Store of each shader (The can be looked up using effect.key)
  86634. */
  86635. static ShadersStore: {
  86636. [key: string]: string;
  86637. };
  86638. /**
  86639. * Store of each included file for a shader (The can be looked up using effect.key)
  86640. */
  86641. static IncludesShadersStore: {
  86642. [key: string]: string;
  86643. };
  86644. /**
  86645. * Resets the cache of effects.
  86646. */
  86647. static ResetCache(): void;
  86648. }
  86649. }
  86650. declare module BABYLON {
  86651. /**
  86652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86654. * 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;
  86655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86656. */
  86657. export class ColorCurves {
  86658. private _dirty;
  86659. private _tempColor;
  86660. private _globalCurve;
  86661. private _highlightsCurve;
  86662. private _midtonesCurve;
  86663. private _shadowsCurve;
  86664. private _positiveCurve;
  86665. private _negativeCurve;
  86666. private _globalHue;
  86667. private _globalDensity;
  86668. private _globalSaturation;
  86669. private _globalExposure;
  86670. /**
  86671. * Gets the global Hue value.
  86672. * 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).
  86673. */
  86674. /**
  86675. * Sets the global Hue value.
  86676. * 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).
  86677. */
  86678. globalHue: number;
  86679. /**
  86680. * Gets the global Density value.
  86681. * 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.
  86682. * Values less than zero provide a filter of opposite hue.
  86683. */
  86684. /**
  86685. * Sets the global Density value.
  86686. * 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.
  86687. * Values less than zero provide a filter of opposite hue.
  86688. */
  86689. globalDensity: number;
  86690. /**
  86691. * Gets the global Saturation value.
  86692. * 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.
  86693. */
  86694. /**
  86695. * Sets the global Saturation value.
  86696. * 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.
  86697. */
  86698. globalSaturation: number;
  86699. /**
  86700. * Gets the global Exposure value.
  86701. * 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.
  86702. */
  86703. /**
  86704. * Sets the global Exposure value.
  86705. * 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.
  86706. */
  86707. globalExposure: number;
  86708. private _highlightsHue;
  86709. private _highlightsDensity;
  86710. private _highlightsSaturation;
  86711. private _highlightsExposure;
  86712. /**
  86713. * Gets the highlights Hue value.
  86714. * 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).
  86715. */
  86716. /**
  86717. * Sets the highlights Hue value.
  86718. * 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).
  86719. */
  86720. highlightsHue: number;
  86721. /**
  86722. * Gets the highlights Density value.
  86723. * 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.
  86724. * Values less than zero provide a filter of opposite hue.
  86725. */
  86726. /**
  86727. * Sets the highlights Density value.
  86728. * 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.
  86729. * Values less than zero provide a filter of opposite hue.
  86730. */
  86731. highlightsDensity: number;
  86732. /**
  86733. * Gets the highlights Saturation value.
  86734. * 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.
  86735. */
  86736. /**
  86737. * Sets the highlights Saturation value.
  86738. * 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.
  86739. */
  86740. highlightsSaturation: number;
  86741. /**
  86742. * Gets the highlights Exposure value.
  86743. * 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.
  86744. */
  86745. /**
  86746. * Sets the highlights Exposure value.
  86747. * 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.
  86748. */
  86749. highlightsExposure: number;
  86750. private _midtonesHue;
  86751. private _midtonesDensity;
  86752. private _midtonesSaturation;
  86753. private _midtonesExposure;
  86754. /**
  86755. * Gets the midtones Hue value.
  86756. * 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).
  86757. */
  86758. /**
  86759. * Sets the midtones Hue value.
  86760. * 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).
  86761. */
  86762. midtonesHue: number;
  86763. /**
  86764. * Gets the midtones Density value.
  86765. * 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.
  86766. * Values less than zero provide a filter of opposite hue.
  86767. */
  86768. /**
  86769. * Sets the midtones Density value.
  86770. * 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.
  86771. * Values less than zero provide a filter of opposite hue.
  86772. */
  86773. midtonesDensity: number;
  86774. /**
  86775. * Gets the midtones Saturation value.
  86776. * 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.
  86777. */
  86778. /**
  86779. * Sets the midtones Saturation value.
  86780. * 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.
  86781. */
  86782. midtonesSaturation: number;
  86783. /**
  86784. * Gets the midtones Exposure value.
  86785. * 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.
  86786. */
  86787. /**
  86788. * Sets the midtones Exposure value.
  86789. * 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.
  86790. */
  86791. midtonesExposure: number;
  86792. private _shadowsHue;
  86793. private _shadowsDensity;
  86794. private _shadowsSaturation;
  86795. private _shadowsExposure;
  86796. /**
  86797. * Gets the shadows Hue value.
  86798. * 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).
  86799. */
  86800. /**
  86801. * Sets the shadows Hue value.
  86802. * 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).
  86803. */
  86804. shadowsHue: number;
  86805. /**
  86806. * Gets the shadows Density value.
  86807. * 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.
  86808. * Values less than zero provide a filter of opposite hue.
  86809. */
  86810. /**
  86811. * Sets the shadows Density value.
  86812. * 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.
  86813. * Values less than zero provide a filter of opposite hue.
  86814. */
  86815. shadowsDensity: number;
  86816. /**
  86817. * Gets the shadows Saturation value.
  86818. * 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.
  86819. */
  86820. /**
  86821. * Sets the shadows Saturation value.
  86822. * 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.
  86823. */
  86824. shadowsSaturation: number;
  86825. /**
  86826. * Gets the shadows Exposure value.
  86827. * 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.
  86828. */
  86829. /**
  86830. * Sets the shadows Exposure value.
  86831. * 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.
  86832. */
  86833. shadowsExposure: number;
  86834. /**
  86835. * Returns the class name
  86836. * @returns The class name
  86837. */
  86838. getClassName(): string;
  86839. /**
  86840. * Binds the color curves to the shader.
  86841. * @param colorCurves The color curve to bind
  86842. * @param effect The effect to bind to
  86843. * @param positiveUniform The positive uniform shader parameter
  86844. * @param neutralUniform The neutral uniform shader parameter
  86845. * @param negativeUniform The negative uniform shader parameter
  86846. */
  86847. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86848. /**
  86849. * Prepare the list of uniforms associated with the ColorCurves effects.
  86850. * @param uniformsList The list of uniforms used in the effect
  86851. */
  86852. static PrepareUniforms(uniformsList: string[]): void;
  86853. /**
  86854. * Returns color grading data based on a hue, density, saturation and exposure value.
  86855. * @param filterHue The hue of the color filter.
  86856. * @param filterDensity The density of the color filter.
  86857. * @param saturation The saturation.
  86858. * @param exposure The exposure.
  86859. * @param result The result data container.
  86860. */
  86861. private getColorGradingDataToRef;
  86862. /**
  86863. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86864. * @param value The input slider value in range [-100,100].
  86865. * @returns Adjusted value.
  86866. */
  86867. private static applyColorGradingSliderNonlinear;
  86868. /**
  86869. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86870. * @param hue The hue (H) input.
  86871. * @param saturation The saturation (S) input.
  86872. * @param brightness The brightness (B) input.
  86873. * @result An RGBA color represented as Vector4.
  86874. */
  86875. private static fromHSBToRef;
  86876. /**
  86877. * Returns a value clamped between min and max
  86878. * @param value The value to clamp
  86879. * @param min The minimum of value
  86880. * @param max The maximum of value
  86881. * @returns The clamped value.
  86882. */
  86883. private static clamp;
  86884. /**
  86885. * Clones the current color curve instance.
  86886. * @return The cloned curves
  86887. */
  86888. clone(): ColorCurves;
  86889. /**
  86890. * Serializes the current color curve instance to a json representation.
  86891. * @return a JSON representation
  86892. */
  86893. serialize(): any;
  86894. /**
  86895. * Parses the color curve from a json representation.
  86896. * @param source the JSON source to parse
  86897. * @return The parsed curves
  86898. */
  86899. static Parse(source: any): ColorCurves;
  86900. }
  86901. }
  86902. declare module BABYLON {
  86903. /**
  86904. * Interface to follow in your material defines to integrate easily the
  86905. * Image proccessing functions.
  86906. * @hidden
  86907. */
  86908. export interface IImageProcessingConfigurationDefines {
  86909. IMAGEPROCESSING: boolean;
  86910. VIGNETTE: boolean;
  86911. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86912. VIGNETTEBLENDMODEOPAQUE: boolean;
  86913. TONEMAPPING: boolean;
  86914. TONEMAPPING_ACES: boolean;
  86915. CONTRAST: boolean;
  86916. EXPOSURE: boolean;
  86917. COLORCURVES: boolean;
  86918. COLORGRADING: boolean;
  86919. COLORGRADING3D: boolean;
  86920. SAMPLER3DGREENDEPTH: boolean;
  86921. SAMPLER3DBGRMAP: boolean;
  86922. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86923. }
  86924. /**
  86925. * @hidden
  86926. */
  86927. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86928. IMAGEPROCESSING: boolean;
  86929. VIGNETTE: boolean;
  86930. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86931. VIGNETTEBLENDMODEOPAQUE: boolean;
  86932. TONEMAPPING: boolean;
  86933. TONEMAPPING_ACES: boolean;
  86934. CONTRAST: boolean;
  86935. COLORCURVES: boolean;
  86936. COLORGRADING: boolean;
  86937. COLORGRADING3D: boolean;
  86938. SAMPLER3DGREENDEPTH: boolean;
  86939. SAMPLER3DBGRMAP: boolean;
  86940. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86941. EXPOSURE: boolean;
  86942. constructor();
  86943. }
  86944. /**
  86945. * This groups together the common properties used for image processing either in direct forward pass
  86946. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86947. * or not.
  86948. */
  86949. export class ImageProcessingConfiguration {
  86950. /**
  86951. * Default tone mapping applied in BabylonJS.
  86952. */
  86953. static readonly TONEMAPPING_STANDARD: number;
  86954. /**
  86955. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86956. * to other engines rendering to increase portability.
  86957. */
  86958. static readonly TONEMAPPING_ACES: number;
  86959. /**
  86960. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86961. */
  86962. colorCurves: Nullable<ColorCurves>;
  86963. private _colorCurvesEnabled;
  86964. /**
  86965. * Gets wether the color curves effect is enabled.
  86966. */
  86967. /**
  86968. * Sets wether the color curves effect is enabled.
  86969. */
  86970. colorCurvesEnabled: boolean;
  86971. private _colorGradingTexture;
  86972. /**
  86973. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86974. */
  86975. /**
  86976. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86977. */
  86978. colorGradingTexture: Nullable<BaseTexture>;
  86979. private _colorGradingEnabled;
  86980. /**
  86981. * Gets wether the color grading effect is enabled.
  86982. */
  86983. /**
  86984. * Sets wether the color grading effect is enabled.
  86985. */
  86986. colorGradingEnabled: boolean;
  86987. private _colorGradingWithGreenDepth;
  86988. /**
  86989. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86990. */
  86991. /**
  86992. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86993. */
  86994. colorGradingWithGreenDepth: boolean;
  86995. private _colorGradingBGR;
  86996. /**
  86997. * Gets wether the color grading texture contains BGR values.
  86998. */
  86999. /**
  87000. * Sets wether the color grading texture contains BGR values.
  87001. */
  87002. colorGradingBGR: boolean;
  87003. /** @hidden */
  87004. _exposure: number;
  87005. /**
  87006. * Gets the Exposure used in the effect.
  87007. */
  87008. /**
  87009. * Sets the Exposure used in the effect.
  87010. */
  87011. exposure: number;
  87012. private _toneMappingEnabled;
  87013. /**
  87014. * Gets wether the tone mapping effect is enabled.
  87015. */
  87016. /**
  87017. * Sets wether the tone mapping effect is enabled.
  87018. */
  87019. toneMappingEnabled: boolean;
  87020. private _toneMappingType;
  87021. /**
  87022. * Gets the type of tone mapping effect.
  87023. */
  87024. /**
  87025. * Sets the type of tone mapping effect used in BabylonJS.
  87026. */
  87027. toneMappingType: number;
  87028. protected _contrast: number;
  87029. /**
  87030. * Gets the contrast used in the effect.
  87031. */
  87032. /**
  87033. * Sets the contrast used in the effect.
  87034. */
  87035. contrast: number;
  87036. /**
  87037. * Vignette stretch size.
  87038. */
  87039. vignetteStretch: number;
  87040. /**
  87041. * Vignette centre X Offset.
  87042. */
  87043. vignetteCentreX: number;
  87044. /**
  87045. * Vignette centre Y Offset.
  87046. */
  87047. vignetteCentreY: number;
  87048. /**
  87049. * Vignette weight or intensity of the vignette effect.
  87050. */
  87051. vignetteWeight: number;
  87052. /**
  87053. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87054. * if vignetteEnabled is set to true.
  87055. */
  87056. vignetteColor: Color4;
  87057. /**
  87058. * Camera field of view used by the Vignette effect.
  87059. */
  87060. vignetteCameraFov: number;
  87061. private _vignetteBlendMode;
  87062. /**
  87063. * Gets the vignette blend mode allowing different kind of effect.
  87064. */
  87065. /**
  87066. * Sets the vignette blend mode allowing different kind of effect.
  87067. */
  87068. vignetteBlendMode: number;
  87069. private _vignetteEnabled;
  87070. /**
  87071. * Gets wether the vignette effect is enabled.
  87072. */
  87073. /**
  87074. * Sets wether the vignette effect is enabled.
  87075. */
  87076. vignetteEnabled: boolean;
  87077. private _applyByPostProcess;
  87078. /**
  87079. * Gets wether the image processing is applied through a post process or not.
  87080. */
  87081. /**
  87082. * Sets wether the image processing is applied through a post process or not.
  87083. */
  87084. applyByPostProcess: boolean;
  87085. private _isEnabled;
  87086. /**
  87087. * Gets wether the image processing is enabled or not.
  87088. */
  87089. /**
  87090. * Sets wether the image processing is enabled or not.
  87091. */
  87092. isEnabled: boolean;
  87093. /**
  87094. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87095. */
  87096. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87097. /**
  87098. * Method called each time the image processing information changes requires to recompile the effect.
  87099. */
  87100. protected _updateParameters(): void;
  87101. /**
  87102. * Gets the current class name.
  87103. * @return "ImageProcessingConfiguration"
  87104. */
  87105. getClassName(): string;
  87106. /**
  87107. * Prepare the list of uniforms associated with the Image Processing effects.
  87108. * @param uniforms The list of uniforms used in the effect
  87109. * @param defines the list of defines currently in use
  87110. */
  87111. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87112. /**
  87113. * Prepare the list of samplers associated with the Image Processing effects.
  87114. * @param samplersList The list of uniforms used in the effect
  87115. * @param defines the list of defines currently in use
  87116. */
  87117. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87118. /**
  87119. * Prepare the list of defines associated to the shader.
  87120. * @param defines the list of defines to complete
  87121. * @param forPostProcess Define if we are currently in post process mode or not
  87122. */
  87123. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87124. /**
  87125. * Returns true if all the image processing information are ready.
  87126. * @returns True if ready, otherwise, false
  87127. */
  87128. isReady(): boolean;
  87129. /**
  87130. * Binds the image processing to the shader.
  87131. * @param effect The effect to bind to
  87132. * @param aspectRatio Define the current aspect ratio of the effect
  87133. */
  87134. bind(effect: Effect, aspectRatio?: number): void;
  87135. /**
  87136. * Clones the current image processing instance.
  87137. * @return The cloned image processing
  87138. */
  87139. clone(): ImageProcessingConfiguration;
  87140. /**
  87141. * Serializes the current image processing instance to a json representation.
  87142. * @return a JSON representation
  87143. */
  87144. serialize(): any;
  87145. /**
  87146. * Parses the image processing from a json representation.
  87147. * @param source the JSON source to parse
  87148. * @return The parsed image processing
  87149. */
  87150. static Parse(source: any): ImageProcessingConfiguration;
  87151. private static _VIGNETTEMODE_MULTIPLY;
  87152. private static _VIGNETTEMODE_OPAQUE;
  87153. /**
  87154. * Used to apply the vignette as a mix with the pixel color.
  87155. */
  87156. static readonly VIGNETTEMODE_MULTIPLY: number;
  87157. /**
  87158. * Used to apply the vignette as a replacement of the pixel color.
  87159. */
  87160. static readonly VIGNETTEMODE_OPAQUE: number;
  87161. }
  87162. }
  87163. declare module BABYLON {
  87164. /**
  87165. * This represents all the required information to add a fresnel effect on a material:
  87166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  87167. */
  87168. export class FresnelParameters {
  87169. private _isEnabled;
  87170. /**
  87171. * Define if the fresnel effect is enable or not.
  87172. */
  87173. isEnabled: boolean;
  87174. /**
  87175. * Define the color used on edges (grazing angle)
  87176. */
  87177. leftColor: Color3;
  87178. /**
  87179. * Define the color used on center
  87180. */
  87181. rightColor: Color3;
  87182. /**
  87183. * Define bias applied to computed fresnel term
  87184. */
  87185. bias: number;
  87186. /**
  87187. * Defined the power exponent applied to fresnel term
  87188. */
  87189. power: number;
  87190. /**
  87191. * Clones the current fresnel and its valuues
  87192. * @returns a clone fresnel configuration
  87193. */
  87194. clone(): FresnelParameters;
  87195. /**
  87196. * Serializes the current fresnel parameters to a JSON representation.
  87197. * @return the JSON serialization
  87198. */
  87199. serialize(): any;
  87200. /**
  87201. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  87202. * @param parsedFresnelParameters Define the JSON representation
  87203. * @returns the parsed parameters
  87204. */
  87205. static Parse(parsedFresnelParameters: any): FresnelParameters;
  87206. }
  87207. }
  87208. declare module BABYLON {
  87209. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  87210. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87211. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87212. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87213. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87214. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87215. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87216. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87217. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87218. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87219. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87220. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87221. /**
  87222. * Decorator used to define property that can be serialized as reference to a camera
  87223. * @param sourceName defines the name of the property to decorate
  87224. */
  87225. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87226. /**
  87227. * Class used to help serialization objects
  87228. */
  87229. export class SerializationHelper {
  87230. /** hidden */
  87231. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87232. /** hidden */
  87233. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87234. /** hidden */
  87235. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87236. /** hidden */
  87237. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87238. /**
  87239. * Appends the serialized animations from the source animations
  87240. * @param source Source containing the animations
  87241. * @param destination Target to store the animations
  87242. */
  87243. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87244. /**
  87245. * Static function used to serialized a specific entity
  87246. * @param entity defines the entity to serialize
  87247. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87248. * @returns a JSON compatible object representing the serialization of the entity
  87249. */
  87250. static Serialize<T>(entity: T, serializationObject?: any): any;
  87251. /**
  87252. * Creates a new entity from a serialization data object
  87253. * @param creationFunction defines a function used to instanciated the new entity
  87254. * @param source defines the source serialization data
  87255. * @param scene defines the hosting scene
  87256. * @param rootUrl defines the root url for resources
  87257. * @returns a new entity
  87258. */
  87259. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87260. /**
  87261. * Clones an object
  87262. * @param creationFunction defines the function used to instanciate the new object
  87263. * @param source defines the source object
  87264. * @returns the cloned object
  87265. */
  87266. static Clone<T>(creationFunction: () => T, source: T): T;
  87267. /**
  87268. * Instanciates a new object based on a source one (some data will be shared between both object)
  87269. * @param creationFunction defines the function used to instanciate the new object
  87270. * @param source defines the source object
  87271. * @returns the new object
  87272. */
  87273. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87274. }
  87275. }
  87276. declare module BABYLON {
  87277. /**
  87278. * This is the base class of all the camera used in the application.
  87279. * @see http://doc.babylonjs.com/features/cameras
  87280. */
  87281. export class Camera extends Node {
  87282. /** @hidden */
  87283. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87284. /**
  87285. * This is the default projection mode used by the cameras.
  87286. * It helps recreating a feeling of perspective and better appreciate depth.
  87287. * This is the best way to simulate real life cameras.
  87288. */
  87289. static readonly PERSPECTIVE_CAMERA: number;
  87290. /**
  87291. * This helps creating camera with an orthographic mode.
  87292. * 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.
  87293. */
  87294. static readonly ORTHOGRAPHIC_CAMERA: number;
  87295. /**
  87296. * This is the default FOV mode for perspective cameras.
  87297. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87298. */
  87299. static readonly FOVMODE_VERTICAL_FIXED: number;
  87300. /**
  87301. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87302. */
  87303. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87304. /**
  87305. * This specifies ther is no need for a camera rig.
  87306. * Basically only one eye is rendered corresponding to the camera.
  87307. */
  87308. static readonly RIG_MODE_NONE: number;
  87309. /**
  87310. * Simulates a camera Rig with one blue eye and one red eye.
  87311. * This can be use with 3d blue and red glasses.
  87312. */
  87313. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87314. /**
  87315. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87316. */
  87317. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87318. /**
  87319. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87320. */
  87321. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87322. /**
  87323. * Defines that both eyes of the camera will be rendered over under each other.
  87324. */
  87325. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87326. /**
  87327. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87328. */
  87329. static readonly RIG_MODE_VR: number;
  87330. /**
  87331. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87332. */
  87333. static readonly RIG_MODE_WEBVR: number;
  87334. /**
  87335. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87336. */
  87337. static readonly RIG_MODE_CUSTOM: number;
  87338. /**
  87339. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87340. */
  87341. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87342. /**
  87343. * @hidden
  87344. * Might be removed once multiview will be a thing
  87345. */
  87346. static UseAlternateWebVRRendering: boolean;
  87347. /**
  87348. * Define the input manager associated with the camera.
  87349. */
  87350. inputs: CameraInputsManager<Camera>;
  87351. /** @hidden */
  87352. _position: Vector3;
  87353. /**
  87354. * Define the current local position of the camera in the scene
  87355. */
  87356. position: Vector3;
  87357. /**
  87358. * The vector the camera should consider as up.
  87359. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87360. */
  87361. upVector: Vector3;
  87362. /**
  87363. * Define the current limit on the left side for an orthographic camera
  87364. * In scene unit
  87365. */
  87366. orthoLeft: Nullable<number>;
  87367. /**
  87368. * Define the current limit on the right side for an orthographic camera
  87369. * In scene unit
  87370. */
  87371. orthoRight: Nullable<number>;
  87372. /**
  87373. * Define the current limit on the bottom side for an orthographic camera
  87374. * In scene unit
  87375. */
  87376. orthoBottom: Nullable<number>;
  87377. /**
  87378. * Define the current limit on the top side for an orthographic camera
  87379. * In scene unit
  87380. */
  87381. orthoTop: Nullable<number>;
  87382. /**
  87383. * Field Of View is set in Radians. (default is 0.8)
  87384. */
  87385. fov: number;
  87386. /**
  87387. * Define the minimum distance the camera can see from.
  87388. * This is important to note that the depth buffer are not infinite and the closer it starts
  87389. * the more your scene might encounter depth fighting issue.
  87390. */
  87391. minZ: number;
  87392. /**
  87393. * Define the maximum distance the camera can see to.
  87394. * This is important to note that the depth buffer are not infinite and the further it end
  87395. * the more your scene might encounter depth fighting issue.
  87396. */
  87397. maxZ: number;
  87398. /**
  87399. * Define the default inertia of the camera.
  87400. * This helps giving a smooth feeling to the camera movement.
  87401. */
  87402. inertia: number;
  87403. /**
  87404. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87405. */
  87406. mode: number;
  87407. /**
  87408. * Define wether the camera is intermediate.
  87409. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87410. */
  87411. isIntermediate: boolean;
  87412. /**
  87413. * Define the viewport of the camera.
  87414. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87415. */
  87416. viewport: Viewport;
  87417. /**
  87418. * Restricts the camera to viewing objects with the same layerMask.
  87419. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87420. */
  87421. layerMask: number;
  87422. /**
  87423. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87424. */
  87425. fovMode: number;
  87426. /**
  87427. * Rig mode of the camera.
  87428. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87429. * This is normally controlled byt the camera themselves as internal use.
  87430. */
  87431. cameraRigMode: number;
  87432. /**
  87433. * Defines the distance between both "eyes" in case of a RIG
  87434. */
  87435. interaxialDistance: number;
  87436. /**
  87437. * Defines if stereoscopic rendering is done side by side or over under.
  87438. */
  87439. isStereoscopicSideBySide: boolean;
  87440. /**
  87441. * 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
  87442. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87443. * else in the scene.
  87444. */
  87445. customRenderTargets: RenderTargetTexture[];
  87446. /**
  87447. * When set, the camera will render to this render target instead of the default canvas
  87448. */
  87449. outputRenderTarget: Nullable<RenderTargetTexture>;
  87450. /**
  87451. * Observable triggered when the camera view matrix has changed.
  87452. */
  87453. onViewMatrixChangedObservable: Observable<Camera>;
  87454. /**
  87455. * Observable triggered when the camera Projection matrix has changed.
  87456. */
  87457. onProjectionMatrixChangedObservable: Observable<Camera>;
  87458. /**
  87459. * Observable triggered when the inputs have been processed.
  87460. */
  87461. onAfterCheckInputsObservable: Observable<Camera>;
  87462. /**
  87463. * Observable triggered when reset has been called and applied to the camera.
  87464. */
  87465. onRestoreStateObservable: Observable<Camera>;
  87466. /** @hidden */
  87467. _cameraRigParams: any;
  87468. /** @hidden */
  87469. _rigCameras: Camera[];
  87470. /** @hidden */
  87471. _rigPostProcess: Nullable<PostProcess>;
  87472. protected _webvrViewMatrix: Matrix;
  87473. /** @hidden */
  87474. _skipRendering: boolean;
  87475. /** @hidden */
  87476. _alternateCamera: Camera;
  87477. /** @hidden */
  87478. _projectionMatrix: Matrix;
  87479. /** @hidden */
  87480. _postProcesses: Nullable<PostProcess>[];
  87481. /** @hidden */
  87482. _activeMeshes: SmartArray<AbstractMesh>;
  87483. protected _globalPosition: Vector3;
  87484. /** hidden */
  87485. _computedViewMatrix: Matrix;
  87486. private _doNotComputeProjectionMatrix;
  87487. private _transformMatrix;
  87488. private _frustumPlanes;
  87489. private _refreshFrustumPlanes;
  87490. private _storedFov;
  87491. private _stateStored;
  87492. /**
  87493. * Instantiates a new camera object.
  87494. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87495. * @see http://doc.babylonjs.com/features/cameras
  87496. * @param name Defines the name of the camera in the scene
  87497. * @param position Defines the position of the camera
  87498. * @param scene Defines the scene the camera belongs too
  87499. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87500. */
  87501. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87502. /**
  87503. * Store current camera state (fov, position, etc..)
  87504. * @returns the camera
  87505. */
  87506. storeState(): Camera;
  87507. /**
  87508. * Restores the camera state values if it has been stored. You must call storeState() first
  87509. */
  87510. protected _restoreStateValues(): boolean;
  87511. /**
  87512. * Restored camera state. You must call storeState() first.
  87513. * @returns true if restored and false otherwise
  87514. */
  87515. restoreState(): boolean;
  87516. /**
  87517. * Gets the class name of the camera.
  87518. * @returns the class name
  87519. */
  87520. getClassName(): string;
  87521. /** @hidden */
  87522. readonly _isCamera: boolean;
  87523. /**
  87524. * Gets a string representation of the camera useful for debug purpose.
  87525. * @param fullDetails Defines that a more verboe level of logging is required
  87526. * @returns the string representation
  87527. */
  87528. toString(fullDetails?: boolean): string;
  87529. /**
  87530. * Gets the current world space position of the camera.
  87531. */
  87532. readonly globalPosition: Vector3;
  87533. /**
  87534. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87535. * @returns the active meshe list
  87536. */
  87537. getActiveMeshes(): SmartArray<AbstractMesh>;
  87538. /**
  87539. * Check wether a mesh is part of the current active mesh list of the camera
  87540. * @param mesh Defines the mesh to check
  87541. * @returns true if active, false otherwise
  87542. */
  87543. isActiveMesh(mesh: Mesh): boolean;
  87544. /**
  87545. * Is this camera ready to be used/rendered
  87546. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87547. * @return true if the camera is ready
  87548. */
  87549. isReady(completeCheck?: boolean): boolean;
  87550. /** @hidden */
  87551. _initCache(): void;
  87552. /** @hidden */
  87553. _updateCache(ignoreParentClass?: boolean): void;
  87554. /** @hidden */
  87555. _isSynchronized(): boolean;
  87556. /** @hidden */
  87557. _isSynchronizedViewMatrix(): boolean;
  87558. /** @hidden */
  87559. _isSynchronizedProjectionMatrix(): boolean;
  87560. /**
  87561. * Attach the input controls to a specific dom element to get the input from.
  87562. * @param element Defines the element the controls should be listened from
  87563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87564. */
  87565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87566. /**
  87567. * Detach the current controls from the specified dom element.
  87568. * @param element Defines the element to stop listening the inputs from
  87569. */
  87570. detachControl(element: HTMLElement): void;
  87571. /**
  87572. * Update the camera state according to the different inputs gathered during the frame.
  87573. */
  87574. update(): void;
  87575. /** @hidden */
  87576. _checkInputs(): void;
  87577. /** @hidden */
  87578. readonly rigCameras: Camera[];
  87579. /**
  87580. * Gets the post process used by the rig cameras
  87581. */
  87582. readonly rigPostProcess: Nullable<PostProcess>;
  87583. /**
  87584. * Internal, gets the first post proces.
  87585. * @returns the first post process to be run on this camera.
  87586. */
  87587. _getFirstPostProcess(): Nullable<PostProcess>;
  87588. private _cascadePostProcessesToRigCams;
  87589. /**
  87590. * Attach a post process to the camera.
  87591. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87592. * @param postProcess The post process to attach to the camera
  87593. * @param insertAt The position of the post process in case several of them are in use in the scene
  87594. * @returns the position the post process has been inserted at
  87595. */
  87596. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87597. /**
  87598. * Detach a post process to the camera.
  87599. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87600. * @param postProcess The post process to detach from the camera
  87601. */
  87602. detachPostProcess(postProcess: PostProcess): void;
  87603. /**
  87604. * Gets the current world matrix of the camera
  87605. */
  87606. getWorldMatrix(): Matrix;
  87607. /** @hidden */
  87608. _getViewMatrix(): Matrix;
  87609. /**
  87610. * Gets the current view matrix of the camera.
  87611. * @param force forces the camera to recompute the matrix without looking at the cached state
  87612. * @returns the view matrix
  87613. */
  87614. getViewMatrix(force?: boolean): Matrix;
  87615. /**
  87616. * Freeze the projection matrix.
  87617. * It will prevent the cache check of the camera projection compute and can speed up perf
  87618. * if no parameter of the camera are meant to change
  87619. * @param projection Defines manually a projection if necessary
  87620. */
  87621. freezeProjectionMatrix(projection?: Matrix): void;
  87622. /**
  87623. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87624. */
  87625. unfreezeProjectionMatrix(): void;
  87626. /**
  87627. * Gets the current projection matrix of the camera.
  87628. * @param force forces the camera to recompute the matrix without looking at the cached state
  87629. * @returns the projection matrix
  87630. */
  87631. getProjectionMatrix(force?: boolean): Matrix;
  87632. /**
  87633. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87634. * @returns a Matrix
  87635. */
  87636. getTransformationMatrix(): Matrix;
  87637. private _updateFrustumPlanes;
  87638. /**
  87639. * Checks if a cullable object (mesh...) is in the camera frustum
  87640. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87641. * @param target The object to check
  87642. * @returns true if the object is in frustum otherwise false
  87643. */
  87644. isInFrustum(target: ICullable): boolean;
  87645. /**
  87646. * Checks if a cullable object (mesh...) is in the camera frustum
  87647. * Unlike isInFrustum this cheks the full bounding box
  87648. * @param target The object to check
  87649. * @returns true if the object is in frustum otherwise false
  87650. */
  87651. isCompletelyInFrustum(target: ICullable): boolean;
  87652. /**
  87653. * Gets a ray in the forward direction from the camera.
  87654. * @param length Defines the length of the ray to create
  87655. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87656. * @param origin Defines the start point of the ray which defaults to the camera position
  87657. * @returns the forward ray
  87658. */
  87659. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87660. /**
  87661. * Releases resources associated with this node.
  87662. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87663. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87664. */
  87665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87666. /** @hidden */
  87667. _isLeftCamera: boolean;
  87668. /**
  87669. * Gets the left camera of a rig setup in case of Rigged Camera
  87670. */
  87671. readonly isLeftCamera: boolean;
  87672. /** @hidden */
  87673. _isRightCamera: boolean;
  87674. /**
  87675. * Gets the right camera of a rig setup in case of Rigged Camera
  87676. */
  87677. readonly isRightCamera: boolean;
  87678. /**
  87679. * Gets the left camera of a rig setup in case of Rigged Camera
  87680. */
  87681. readonly leftCamera: Nullable<FreeCamera>;
  87682. /**
  87683. * Gets the right camera of a rig setup in case of Rigged Camera
  87684. */
  87685. readonly rightCamera: Nullable<FreeCamera>;
  87686. /**
  87687. * Gets the left camera target of a rig setup in case of Rigged Camera
  87688. * @returns the target position
  87689. */
  87690. getLeftTarget(): Nullable<Vector3>;
  87691. /**
  87692. * Gets the right camera target of a rig setup in case of Rigged Camera
  87693. * @returns the target position
  87694. */
  87695. getRightTarget(): Nullable<Vector3>;
  87696. /**
  87697. * @hidden
  87698. */
  87699. setCameraRigMode(mode: number, rigParams: any): void;
  87700. /** @hidden */
  87701. static _setStereoscopicRigMode(camera: Camera): void;
  87702. /** @hidden */
  87703. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87704. /** @hidden */
  87705. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87706. /** @hidden */
  87707. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87708. /** @hidden */
  87709. _getVRProjectionMatrix(): Matrix;
  87710. protected _updateCameraRotationMatrix(): void;
  87711. protected _updateWebVRCameraRotationMatrix(): void;
  87712. /**
  87713. * This function MUST be overwritten by the different WebVR cameras available.
  87714. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87715. * @hidden
  87716. */
  87717. _getWebVRProjectionMatrix(): Matrix;
  87718. /**
  87719. * This function MUST be overwritten by the different WebVR cameras available.
  87720. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87721. * @hidden
  87722. */
  87723. _getWebVRViewMatrix(): Matrix;
  87724. /** @hidden */
  87725. setCameraRigParameter(name: string, value: any): void;
  87726. /**
  87727. * needs to be overridden by children so sub has required properties to be copied
  87728. * @hidden
  87729. */
  87730. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87731. /**
  87732. * May need to be overridden by children
  87733. * @hidden
  87734. */
  87735. _updateRigCameras(): void;
  87736. /** @hidden */
  87737. _setupInputs(): void;
  87738. /**
  87739. * Serialiaze the camera setup to a json represention
  87740. * @returns the JSON representation
  87741. */
  87742. serialize(): any;
  87743. /**
  87744. * Clones the current camera.
  87745. * @param name The cloned camera name
  87746. * @returns the cloned camera
  87747. */
  87748. clone(name: string): Camera;
  87749. /**
  87750. * Gets the direction of the camera relative to a given local axis.
  87751. * @param localAxis Defines the reference axis to provide a relative direction.
  87752. * @return the direction
  87753. */
  87754. getDirection(localAxis: Vector3): Vector3;
  87755. /**
  87756. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87757. * @param localAxis Defines the reference axis to provide a relative direction.
  87758. * @param result Defines the vector to store the result in
  87759. */
  87760. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87761. /**
  87762. * Gets a camera constructor for a given camera type
  87763. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87764. * @param name The name of the camera the result will be able to instantiate
  87765. * @param scene The scene the result will construct the camera in
  87766. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87767. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87768. * @returns a factory method to construc the camera
  87769. */
  87770. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87771. /**
  87772. * Compute the world matrix of the camera.
  87773. * @returns the camera workd matrix
  87774. */
  87775. computeWorldMatrix(): Matrix;
  87776. /**
  87777. * Parse a JSON and creates the camera from the parsed information
  87778. * @param parsedCamera The JSON to parse
  87779. * @param scene The scene to instantiate the camera in
  87780. * @returns the newly constructed camera
  87781. */
  87782. static Parse(parsedCamera: any, scene: Scene): Camera;
  87783. }
  87784. }
  87785. declare module BABYLON {
  87786. /**
  87787. * Interface for any object that can request an animation frame
  87788. */
  87789. export interface ICustomAnimationFrameRequester {
  87790. /**
  87791. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87792. */
  87793. renderFunction?: Function;
  87794. /**
  87795. * Called to request the next frame to render to
  87796. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87797. */
  87798. requestAnimationFrame: Function;
  87799. /**
  87800. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87801. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87802. */
  87803. requestID?: number;
  87804. }
  87805. /**
  87806. * Interface containing an array of animations
  87807. */
  87808. export interface IAnimatable {
  87809. /**
  87810. * Array of animations
  87811. */
  87812. animations: Array<Animation>;
  87813. }
  87814. /** Interface used by value gradients (color, factor, ...) */
  87815. export interface IValueGradient {
  87816. /**
  87817. * Gets or sets the gradient value (between 0 and 1)
  87818. */
  87819. gradient: number;
  87820. }
  87821. /** Class used to store color4 gradient */
  87822. export class ColorGradient implements IValueGradient {
  87823. /**
  87824. * Gets or sets the gradient value (between 0 and 1)
  87825. */
  87826. gradient: number;
  87827. /**
  87828. * Gets or sets first associated color
  87829. */
  87830. color1: Color4;
  87831. /**
  87832. * Gets or sets second associated color
  87833. */
  87834. color2?: Color4;
  87835. /**
  87836. * Will get a color picked randomly between color1 and color2.
  87837. * If color2 is undefined then color1 will be used
  87838. * @param result defines the target Color4 to store the result in
  87839. */
  87840. getColorToRef(result: Color4): void;
  87841. }
  87842. /** Class used to store color 3 gradient */
  87843. export class Color3Gradient implements IValueGradient {
  87844. /**
  87845. * Gets or sets the gradient value (between 0 and 1)
  87846. */
  87847. gradient: number;
  87848. /**
  87849. * Gets or sets the associated color
  87850. */
  87851. color: Color3;
  87852. }
  87853. /** Class used to store factor gradient */
  87854. export class FactorGradient implements IValueGradient {
  87855. /**
  87856. * Gets or sets the gradient value (between 0 and 1)
  87857. */
  87858. gradient: number;
  87859. /**
  87860. * Gets or sets first associated factor
  87861. */
  87862. factor1: number;
  87863. /**
  87864. * Gets or sets second associated factor
  87865. */
  87866. factor2?: number;
  87867. /**
  87868. * Will get a number picked randomly between factor1 and factor2.
  87869. * If factor2 is undefined then factor1 will be used
  87870. * @returns the picked number
  87871. */
  87872. getFactor(): number;
  87873. }
  87874. /**
  87875. * @ignore
  87876. * Application error to support additional information when loading a file
  87877. */
  87878. export class LoadFileError extends Error {
  87879. /** defines the optional web request */
  87880. request?: WebRequest | undefined;
  87881. private static _setPrototypeOf;
  87882. /**
  87883. * Creates a new LoadFileError
  87884. * @param message defines the message of the error
  87885. * @param request defines the optional web request
  87886. */
  87887. constructor(message: string,
  87888. /** defines the optional web request */
  87889. request?: WebRequest | undefined);
  87890. }
  87891. /**
  87892. * Class used to define a retry strategy when error happens while loading assets
  87893. */
  87894. export class RetryStrategy {
  87895. /**
  87896. * Function used to defines an exponential back off strategy
  87897. * @param maxRetries defines the maximum number of retries (3 by default)
  87898. * @param baseInterval defines the interval between retries
  87899. * @returns the strategy function to use
  87900. */
  87901. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  87902. }
  87903. /**
  87904. * File request interface
  87905. */
  87906. export interface IFileRequest {
  87907. /**
  87908. * Raised when the request is complete (success or error).
  87909. */
  87910. onCompleteObservable: Observable<IFileRequest>;
  87911. /**
  87912. * Aborts the request for a file.
  87913. */
  87914. abort: () => void;
  87915. }
  87916. /**
  87917. * Class containing a set of static utilities functions
  87918. */
  87919. export class Tools {
  87920. /**
  87921. * Gets or sets the base URL to use to load assets
  87922. */
  87923. static BaseUrl: string;
  87924. /**
  87925. * Enable/Disable Custom HTTP Request Headers globally.
  87926. * default = false
  87927. * @see CustomRequestHeaders
  87928. */
  87929. static UseCustomRequestHeaders: boolean;
  87930. /**
  87931. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87932. * i.e. when loading files, where the server/service expects an Authorization header
  87933. */
  87934. static CustomRequestHeaders: {
  87935. [key: string]: string;
  87936. };
  87937. /**
  87938. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87939. */
  87940. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  87941. /**
  87942. * Default behaviour for cors in the application.
  87943. * It can be a string if the expected behavior is identical in the entire app.
  87944. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87945. */
  87946. static CorsBehavior: string | ((url: string | string[]) => string);
  87947. /**
  87948. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87949. * @ignorenaming
  87950. */
  87951. static UseFallbackTexture: boolean;
  87952. /**
  87953. * Use this object to register external classes like custom textures or material
  87954. * to allow the laoders to instantiate them
  87955. */
  87956. static RegisteredExternalClasses: {
  87957. [key: string]: Object;
  87958. };
  87959. /**
  87960. * Texture content used if a texture cannot loaded
  87961. * @ignorenaming
  87962. */
  87963. static fallbackTexture: string;
  87964. /**
  87965. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87966. * @param u defines the coordinate on X axis
  87967. * @param v defines the coordinate on Y axis
  87968. * @param width defines the width of the source data
  87969. * @param height defines the height of the source data
  87970. * @param pixels defines the source byte array
  87971. * @param color defines the output color
  87972. */
  87973. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87974. /**
  87975. * Interpolates between a and b via alpha
  87976. * @param a The lower value (returned when alpha = 0)
  87977. * @param b The upper value (returned when alpha = 1)
  87978. * @param alpha The interpolation-factor
  87979. * @return The mixed value
  87980. */
  87981. static Mix(a: number, b: number, alpha: number): number;
  87982. /**
  87983. * Tries to instantiate a new object from a given class name
  87984. * @param className defines the class name to instantiate
  87985. * @returns the new object or null if the system was not able to do the instantiation
  87986. */
  87987. static Instantiate(className: string): any;
  87988. /**
  87989. * Provides a slice function that will work even on IE
  87990. * @param data defines the array to slice
  87991. * @param start defines the start of the data (optional)
  87992. * @param end defines the end of the data (optional)
  87993. * @returns the new sliced array
  87994. */
  87995. static Slice<T>(data: T, start?: number, end?: number): T;
  87996. /**
  87997. * Polyfill for setImmediate
  87998. * @param action defines the action to execute after the current execution block
  87999. */
  88000. static SetImmediate(action: () => void): void;
  88001. /**
  88002. * Function indicating if a number is an exponent of 2
  88003. * @param value defines the value to test
  88004. * @returns true if the value is an exponent of 2
  88005. */
  88006. static IsExponentOfTwo(value: number): boolean;
  88007. private static _tmpFloatArray;
  88008. /**
  88009. * Returns the nearest 32-bit single precision float representation of a Number
  88010. * @param value A Number. If the parameter is of a different type, it will get converted
  88011. * to a number or to NaN if it cannot be converted
  88012. * @returns number
  88013. */
  88014. static FloatRound(value: number): number;
  88015. /**
  88016. * Find the next highest power of two.
  88017. * @param x Number to start search from.
  88018. * @return Next highest power of two.
  88019. */
  88020. static CeilingPOT(x: number): number;
  88021. /**
  88022. * Find the next lowest power of two.
  88023. * @param x Number to start search from.
  88024. * @return Next lowest power of two.
  88025. */
  88026. static FloorPOT(x: number): number;
  88027. /**
  88028. * Find the nearest power of two.
  88029. * @param x Number to start search from.
  88030. * @return Next nearest power of two.
  88031. */
  88032. static NearestPOT(x: number): number;
  88033. /**
  88034. * Get the closest exponent of two
  88035. * @param value defines the value to approximate
  88036. * @param max defines the maximum value to return
  88037. * @param mode defines how to define the closest value
  88038. * @returns closest exponent of two of the given value
  88039. */
  88040. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  88041. /**
  88042. * Extracts the filename from a path
  88043. * @param path defines the path to use
  88044. * @returns the filename
  88045. */
  88046. static GetFilename(path: string): string;
  88047. /**
  88048. * Extracts the "folder" part of a path (everything before the filename).
  88049. * @param uri The URI to extract the info from
  88050. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  88051. * @returns The "folder" part of the path
  88052. */
  88053. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  88054. /**
  88055. * Extracts text content from a DOM element hierarchy
  88056. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  88057. */
  88058. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  88059. /**
  88060. * Convert an angle in radians to degrees
  88061. * @param angle defines the angle to convert
  88062. * @returns the angle in degrees
  88063. */
  88064. static ToDegrees(angle: number): number;
  88065. /**
  88066. * Convert an angle in degrees to radians
  88067. * @param angle defines the angle to convert
  88068. * @returns the angle in radians
  88069. */
  88070. static ToRadians(angle: number): number;
  88071. /**
  88072. * Encode a buffer to a base64 string
  88073. * @param buffer defines the buffer to encode
  88074. * @returns the encoded string
  88075. */
  88076. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  88077. /**
  88078. * Extracts minimum and maximum values from a list of indexed positions
  88079. * @param positions defines the positions to use
  88080. * @param indices defines the indices to the positions
  88081. * @param indexStart defines the start index
  88082. * @param indexCount defines the end index
  88083. * @param bias defines bias value to add to the result
  88084. * @return minimum and maximum values
  88085. */
  88086. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88087. minimum: Vector3;
  88088. maximum: Vector3;
  88089. };
  88090. /**
  88091. * Extracts minimum and maximum values from a list of positions
  88092. * @param positions defines the positions to use
  88093. * @param start defines the start index in the positions array
  88094. * @param count defines the number of positions to handle
  88095. * @param bias defines bias value to add to the result
  88096. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88097. * @return minimum and maximum values
  88098. */
  88099. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88100. minimum: Vector3;
  88101. maximum: Vector3;
  88102. };
  88103. /**
  88104. * Returns an array if obj is not an array
  88105. * @param obj defines the object to evaluate as an array
  88106. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  88107. * @returns either obj directly if obj is an array or a new array containing obj
  88108. */
  88109. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  88110. /**
  88111. * Gets the pointer prefix to use
  88112. * @returns "pointer" if touch is enabled. Else returns "mouse"
  88113. */
  88114. static GetPointerPrefix(): string;
  88115. /**
  88116. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  88117. * @param func - the function to be called
  88118. * @param requester - the object that will request the next frame. Falls back to window.
  88119. * @returns frame number
  88120. */
  88121. static QueueNewFrame(func: () => void, requester?: any): number;
  88122. /**
  88123. * Ask the browser to promote the current element to fullscreen rendering mode
  88124. * @param element defines the DOM element to promote
  88125. */
  88126. static RequestFullscreen(element: HTMLElement): void;
  88127. /**
  88128. * Asks the browser to exit fullscreen mode
  88129. */
  88130. static ExitFullscreen(): void;
  88131. /**
  88132. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  88133. * @param url define the url we are trying
  88134. * @param element define the dom element where to configure the cors policy
  88135. */
  88136. static SetCorsBehavior(url: string | string[], element: {
  88137. crossOrigin: string | null;
  88138. }): void;
  88139. /**
  88140. * Removes unwanted characters from an url
  88141. * @param url defines the url to clean
  88142. * @returns the cleaned url
  88143. */
  88144. static CleanUrl(url: string): string;
  88145. /**
  88146. * Gets or sets a function used to pre-process url before using them to load assets
  88147. */
  88148. static PreprocessUrl: (url: string) => string;
  88149. /**
  88150. * Loads an image as an HTMLImageElement.
  88151. * @param input url string, ArrayBuffer, or Blob to load
  88152. * @param onLoad callback called when the image successfully loads
  88153. * @param onError callback called when the image fails to load
  88154. * @param offlineProvider offline provider for caching
  88155. * @returns the HTMLImageElement of the loaded image
  88156. */
  88157. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  88158. /**
  88159. * Loads a file
  88160. * @param url url string, ArrayBuffer, or Blob to load
  88161. * @param onSuccess callback called when the file successfully loads
  88162. * @param onProgress callback called while file is loading (if the server supports this mode)
  88163. * @param offlineProvider defines the offline provider for caching
  88164. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  88165. * @param onError callback called when the file fails to load
  88166. * @returns a file request object
  88167. */
  88168. 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;
  88169. /**
  88170. * Load a script (identified by an url). When the url returns, the
  88171. * content of this file is added into a new script element, attached to the DOM (body element)
  88172. * @param scriptUrl defines the url of the script to laod
  88173. * @param onSuccess defines the callback called when the script is loaded
  88174. * @param onError defines the callback to call if an error occurs
  88175. */
  88176. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  88177. /**
  88178. * Loads a file from a blob
  88179. * @param fileToLoad defines the blob to use
  88180. * @param callback defines the callback to call when data is loaded
  88181. * @param progressCallback defines the callback to call during loading process
  88182. * @returns a file request object
  88183. */
  88184. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  88185. /**
  88186. * Loads a file
  88187. * @param fileToLoad defines the file to load
  88188. * @param callback defines the callback to call when data is loaded
  88189. * @param progressCallBack defines the callback to call during loading process
  88190. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  88191. * @returns a file request object
  88192. */
  88193. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  88194. /**
  88195. * Creates a data url from a given string content
  88196. * @param content defines the content to convert
  88197. * @returns the new data url link
  88198. */
  88199. static FileAsURL(content: string): string;
  88200. /**
  88201. * Format the given number to a specific decimal format
  88202. * @param value defines the number to format
  88203. * @param decimals defines the number of decimals to use
  88204. * @returns the formatted string
  88205. */
  88206. static Format(value: number, decimals?: number): string;
  88207. /**
  88208. * Checks if a given vector is inside a specific range
  88209. * @param v defines the vector to test
  88210. * @param min defines the minimum range
  88211. * @param max defines the maximum range
  88212. */
  88213. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88214. /**
  88215. * Tries to copy an object by duplicating every property
  88216. * @param source defines the source object
  88217. * @param destination defines the target object
  88218. * @param doNotCopyList defines a list of properties to avoid
  88219. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  88220. */
  88221. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88222. /**
  88223. * Gets a boolean indicating if the given object has no own property
  88224. * @param obj defines the object to test
  88225. * @returns true if object has no own property
  88226. */
  88227. static IsEmpty(obj: any): boolean;
  88228. /**
  88229. * Function used to register events at window level
  88230. * @param events defines the events to register
  88231. */
  88232. static RegisterTopRootEvents(events: {
  88233. name: string;
  88234. handler: Nullable<(e: FocusEvent) => any>;
  88235. }[]): void;
  88236. /**
  88237. * Function used to unregister events from window level
  88238. * @param events defines the events to unregister
  88239. */
  88240. static UnregisterTopRootEvents(events: {
  88241. name: string;
  88242. handler: Nullable<(e: FocusEvent) => any>;
  88243. }[]): void;
  88244. /**
  88245. * @ignore
  88246. */
  88247. static _ScreenshotCanvas: HTMLCanvasElement;
  88248. /**
  88249. * Dumps the current bound framebuffer
  88250. * @param width defines the rendering width
  88251. * @param height defines the rendering height
  88252. * @param engine defines the hosting engine
  88253. * @param successCallback defines the callback triggered once the data are available
  88254. * @param mimeType defines the mime type of the result
  88255. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88256. */
  88257. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88258. /**
  88259. * Converts the canvas data to blob.
  88260. * This acts as a polyfill for browsers not supporting the to blob function.
  88261. * @param canvas Defines the canvas to extract the data from
  88262. * @param successCallback Defines the callback triggered once the data are available
  88263. * @param mimeType Defines the mime type of the result
  88264. */
  88265. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88266. /**
  88267. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88268. * @param successCallback defines the callback triggered once the data are available
  88269. * @param mimeType defines the mime type of the result
  88270. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88271. */
  88272. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88273. /**
  88274. * Downloads a blob in the browser
  88275. * @param blob defines the blob to download
  88276. * @param fileName defines the name of the downloaded file
  88277. */
  88278. static Download(blob: Blob, fileName: string): void;
  88279. /**
  88280. * Captures a screenshot of the current rendering
  88281. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88282. * @param engine defines the rendering engine
  88283. * @param camera defines the source camera
  88284. * @param size This parameter can be set to a single number or to an object with the
  88285. * following (optional) properties: precision, width, height. If a single number is passed,
  88286. * it will be used for both width and height. If an object is passed, the screenshot size
  88287. * will be derived from the parameters. The precision property is a multiplier allowing
  88288. * rendering at a higher or lower resolution
  88289. * @param successCallback defines the callback receives a single parameter which contains the
  88290. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88291. * src parameter of an <img> to display it
  88292. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88293. * Check your browser for supported MIME types
  88294. */
  88295. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88296. /**
  88297. * Generates an image screenshot from the specified camera.
  88298. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88299. * @param engine The engine to use for rendering
  88300. * @param camera The camera to use for rendering
  88301. * @param size This parameter can be set to a single number or to an object with the
  88302. * following (optional) properties: precision, width, height. If a single number is passed,
  88303. * it will be used for both width and height. If an object is passed, the screenshot size
  88304. * will be derived from the parameters. The precision property is a multiplier allowing
  88305. * rendering at a higher or lower resolution
  88306. * @param successCallback The callback receives a single parameter which contains the
  88307. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88308. * src parameter of an <img> to display it
  88309. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88310. * Check your browser for supported MIME types
  88311. * @param samples Texture samples (default: 1)
  88312. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88313. * @param fileName A name for for the downloaded file.
  88314. */
  88315. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88316. /**
  88317. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88318. * Be aware Math.random() could cause collisions, but:
  88319. * "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"
  88320. * @returns a pseudo random id
  88321. */
  88322. static RandomId(): string;
  88323. /**
  88324. * Test if the given uri is a base64 string
  88325. * @param uri The uri to test
  88326. * @return True if the uri is a base64 string or false otherwise
  88327. */
  88328. static IsBase64(uri: string): boolean;
  88329. /**
  88330. * Decode the given base64 uri.
  88331. * @param uri The uri to decode
  88332. * @return The decoded base64 data.
  88333. */
  88334. static DecodeBase64(uri: string): ArrayBuffer;
  88335. /**
  88336. * No log
  88337. */
  88338. static readonly NoneLogLevel: number;
  88339. /**
  88340. * Only message logs
  88341. */
  88342. static readonly MessageLogLevel: number;
  88343. /**
  88344. * Only warning logs
  88345. */
  88346. static readonly WarningLogLevel: number;
  88347. /**
  88348. * Only error logs
  88349. */
  88350. static readonly ErrorLogLevel: number;
  88351. /**
  88352. * All logs
  88353. */
  88354. static readonly AllLogLevel: number;
  88355. /**
  88356. * Gets a value indicating the number of loading errors
  88357. * @ignorenaming
  88358. */
  88359. static readonly errorsCount: number;
  88360. /**
  88361. * Callback called when a new log is added
  88362. */
  88363. static OnNewCacheEntry: (entry: string) => void;
  88364. /**
  88365. * Log a message to the console
  88366. * @param message defines the message to log
  88367. */
  88368. static Log(message: string): void;
  88369. /**
  88370. * Write a warning message to the console
  88371. * @param message defines the message to log
  88372. */
  88373. static Warn(message: string): void;
  88374. /**
  88375. * Write an error message to the console
  88376. * @param message defines the message to log
  88377. */
  88378. static Error(message: string): void;
  88379. /**
  88380. * Gets current log cache (list of logs)
  88381. */
  88382. static readonly LogCache: string;
  88383. /**
  88384. * Clears the log cache
  88385. */
  88386. static ClearLogCache(): void;
  88387. /**
  88388. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88389. */
  88390. static LogLevels: number;
  88391. /**
  88392. * Checks if the loaded document was accessed via `file:`-Protocol.
  88393. * @returns boolean
  88394. */
  88395. static IsFileURL(): boolean;
  88396. /**
  88397. * Checks if the window object exists
  88398. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88399. */
  88400. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88401. /**
  88402. * No performance log
  88403. */
  88404. static readonly PerformanceNoneLogLevel: number;
  88405. /**
  88406. * Use user marks to log performance
  88407. */
  88408. static readonly PerformanceUserMarkLogLevel: number;
  88409. /**
  88410. * Log performance to the console
  88411. */
  88412. static readonly PerformanceConsoleLogLevel: number;
  88413. private static _performance;
  88414. /**
  88415. * Sets the current performance log level
  88416. */
  88417. static PerformanceLogLevel: number;
  88418. private static _StartPerformanceCounterDisabled;
  88419. private static _EndPerformanceCounterDisabled;
  88420. private static _StartUserMark;
  88421. private static _EndUserMark;
  88422. private static _StartPerformanceConsole;
  88423. private static _EndPerformanceConsole;
  88424. /**
  88425. * Starts a performance counter
  88426. */
  88427. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88428. /**
  88429. * Ends a specific performance coutner
  88430. */
  88431. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88432. /**
  88433. * Gets either window.performance.now() if supported or Date.now() else
  88434. */
  88435. static readonly Now: number;
  88436. /**
  88437. * This method will return the name of the class used to create the instance of the given object.
  88438. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88439. * @param object the object to get the class name from
  88440. * @param isType defines if the object is actually a type
  88441. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88442. */
  88443. static GetClassName(object: any, isType?: boolean): string;
  88444. /**
  88445. * Gets the first element of an array satisfying a given predicate
  88446. * @param array defines the array to browse
  88447. * @param predicate defines the predicate to use
  88448. * @returns null if not found or the element
  88449. */
  88450. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88451. /**
  88452. * This method will return the name of the full name of the class, including its owning module (if any).
  88453. * 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).
  88454. * @param object the object to get the class name from
  88455. * @param isType defines if the object is actually a type
  88456. * @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.
  88457. * @ignorenaming
  88458. */
  88459. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88460. /**
  88461. * Returns a promise that resolves after the given amount of time.
  88462. * @param delay Number of milliseconds to delay
  88463. * @returns Promise that resolves after the given amount of time
  88464. */
  88465. static DelayAsync(delay: number): Promise<void>;
  88466. /**
  88467. * Gets the current gradient from an array of IValueGradient
  88468. * @param ratio defines the current ratio to get
  88469. * @param gradients defines the array of IValueGradient
  88470. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88471. */
  88472. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88473. }
  88474. /**
  88475. * This class is used to track a performance counter which is number based.
  88476. * The user has access to many properties which give statistics of different nature.
  88477. *
  88478. * The implementer can track two kinds of Performance Counter: time and count.
  88479. * 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.
  88480. * 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.
  88481. */
  88482. export class PerfCounter {
  88483. /**
  88484. * Gets or sets a global boolean to turn on and off all the counters
  88485. */
  88486. static Enabled: boolean;
  88487. /**
  88488. * Returns the smallest value ever
  88489. */
  88490. readonly min: number;
  88491. /**
  88492. * Returns the biggest value ever
  88493. */
  88494. readonly max: number;
  88495. /**
  88496. * Returns the average value since the performance counter is running
  88497. */
  88498. readonly average: number;
  88499. /**
  88500. * Returns the average value of the last second the counter was monitored
  88501. */
  88502. readonly lastSecAverage: number;
  88503. /**
  88504. * Returns the current value
  88505. */
  88506. readonly current: number;
  88507. /**
  88508. * Gets the accumulated total
  88509. */
  88510. readonly total: number;
  88511. /**
  88512. * Gets the total value count
  88513. */
  88514. readonly count: number;
  88515. /**
  88516. * Creates a new counter
  88517. */
  88518. constructor();
  88519. /**
  88520. * Call this method to start monitoring a new frame.
  88521. * 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.
  88522. */
  88523. fetchNewFrame(): void;
  88524. /**
  88525. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88526. * @param newCount the count value to add to the monitored count
  88527. * @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.
  88528. */
  88529. addCount(newCount: number, fetchResult: boolean): void;
  88530. /**
  88531. * Start monitoring this performance counter
  88532. */
  88533. beginMonitoring(): void;
  88534. /**
  88535. * Compute the time lapsed since the previous beginMonitoring() call.
  88536. * @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
  88537. */
  88538. endMonitoring(newFrame?: boolean): void;
  88539. private _fetchResult;
  88540. private _startMonitoringTime;
  88541. private _min;
  88542. private _max;
  88543. private _average;
  88544. private _current;
  88545. private _totalValueCount;
  88546. private _totalAccumulated;
  88547. private _lastSecAverage;
  88548. private _lastSecAccumulated;
  88549. private _lastSecTime;
  88550. private _lastSecValueCount;
  88551. }
  88552. /**
  88553. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88554. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88555. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88556. * @param name The name of the class, case should be preserved
  88557. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88558. */
  88559. export function className(name: string, module?: string): (target: Object) => void;
  88560. /**
  88561. * An implementation of a loop for asynchronous functions.
  88562. */
  88563. export class AsyncLoop {
  88564. /**
  88565. * Defines the number of iterations for the loop
  88566. */
  88567. iterations: number;
  88568. /**
  88569. * Defines the current index of the loop.
  88570. */
  88571. index: number;
  88572. private _done;
  88573. private _fn;
  88574. private _successCallback;
  88575. /**
  88576. * Constructor.
  88577. * @param iterations the number of iterations.
  88578. * @param func the function to run each iteration
  88579. * @param successCallback the callback that will be called upon succesful execution
  88580. * @param offset starting offset.
  88581. */
  88582. constructor(
  88583. /**
  88584. * Defines the number of iterations for the loop
  88585. */
  88586. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88587. /**
  88588. * Execute the next iteration. Must be called after the last iteration was finished.
  88589. */
  88590. executeNext(): void;
  88591. /**
  88592. * Break the loop and run the success callback.
  88593. */
  88594. breakLoop(): void;
  88595. /**
  88596. * Create and run an async loop.
  88597. * @param iterations the number of iterations.
  88598. * @param fn the function to run each iteration
  88599. * @param successCallback the callback that will be called upon succesful execution
  88600. * @param offset starting offset.
  88601. * @returns the created async loop object
  88602. */
  88603. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88604. /**
  88605. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88606. * @param iterations total number of iterations
  88607. * @param syncedIterations number of synchronous iterations in each async iteration.
  88608. * @param fn the function to call each iteration.
  88609. * @param callback a success call back that will be called when iterating stops.
  88610. * @param breakFunction a break condition (optional)
  88611. * @param timeout timeout settings for the setTimeout function. default - 0.
  88612. * @returns the created async loop object
  88613. */
  88614. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88615. }
  88616. }
  88617. declare module BABYLON {
  88618. /** @hidden */
  88619. export interface ICollisionCoordinator {
  88620. createCollider(): Collider;
  88621. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88622. init(scene: Scene): void;
  88623. }
  88624. /** @hidden */
  88625. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88626. private _scene;
  88627. private _scaledPosition;
  88628. private _scaledVelocity;
  88629. private _finalPosition;
  88630. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88631. createCollider(): Collider;
  88632. init(scene: Scene): void;
  88633. private _collideWithWorld;
  88634. }
  88635. }
  88636. declare module BABYLON {
  88637. /**
  88638. * This class defines the direct association between an animation and a target
  88639. */
  88640. export class TargetedAnimation {
  88641. /**
  88642. * Animation to perform
  88643. */
  88644. animation: Animation;
  88645. /**
  88646. * Target to animate
  88647. */
  88648. target: any;
  88649. }
  88650. /**
  88651. * Use this class to create coordinated animations on multiple targets
  88652. */
  88653. export class AnimationGroup implements IDisposable {
  88654. /** The name of the animation group */
  88655. name: string;
  88656. private _scene;
  88657. private _targetedAnimations;
  88658. private _animatables;
  88659. private _from;
  88660. private _to;
  88661. private _isStarted;
  88662. private _isPaused;
  88663. private _speedRatio;
  88664. /**
  88665. * Gets or sets the unique id of the node
  88666. */
  88667. uniqueId: number;
  88668. /**
  88669. * This observable will notify when one animation have ended
  88670. */
  88671. onAnimationEndObservable: Observable<TargetedAnimation>;
  88672. /**
  88673. * Observer raised when one animation loops
  88674. */
  88675. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88676. /**
  88677. * This observable will notify when all animations have ended.
  88678. */
  88679. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88680. /**
  88681. * This observable will notify when all animations have paused.
  88682. */
  88683. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88684. /**
  88685. * This observable will notify when all animations are playing.
  88686. */
  88687. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88688. /**
  88689. * Gets the first frame
  88690. */
  88691. readonly from: number;
  88692. /**
  88693. * Gets the last frame
  88694. */
  88695. readonly to: number;
  88696. /**
  88697. * Define if the animations are started
  88698. */
  88699. readonly isStarted: boolean;
  88700. /**
  88701. * Gets a value indicating that the current group is playing
  88702. */
  88703. readonly isPlaying: boolean;
  88704. /**
  88705. * Gets or sets the speed ratio to use for all animations
  88706. */
  88707. /**
  88708. * Gets or sets the speed ratio to use for all animations
  88709. */
  88710. speedRatio: number;
  88711. /**
  88712. * Gets the targeted animations for this animation group
  88713. */
  88714. readonly targetedAnimations: Array<TargetedAnimation>;
  88715. /**
  88716. * returning the list of animatables controlled by this animation group.
  88717. */
  88718. readonly animatables: Array<Animatable>;
  88719. /**
  88720. * Instantiates a new Animation Group.
  88721. * This helps managing several animations at once.
  88722. * @see http://doc.babylonjs.com/how_to/group
  88723. * @param name Defines the name of the group
  88724. * @param scene Defines the scene the group belongs to
  88725. */
  88726. constructor(
  88727. /** The name of the animation group */
  88728. name: string, scene?: Nullable<Scene>);
  88729. /**
  88730. * Add an animation (with its target) in the group
  88731. * @param animation defines the animation we want to add
  88732. * @param target defines the target of the animation
  88733. * @returns the TargetedAnimation object
  88734. */
  88735. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88736. /**
  88737. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88738. * It can add constant keys at begin or end
  88739. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88740. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88741. * @returns the animation group
  88742. */
  88743. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88744. /**
  88745. * Start all animations on given targets
  88746. * @param loop defines if animations must loop
  88747. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88748. * @param from defines the from key (optional)
  88749. * @param to defines the to key (optional)
  88750. * @returns the current animation group
  88751. */
  88752. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88753. /**
  88754. * Pause all animations
  88755. * @returns the animation group
  88756. */
  88757. pause(): AnimationGroup;
  88758. /**
  88759. * Play all animations to initial state
  88760. * This function will start() the animations if they were not started or will restart() them if they were paused
  88761. * @param loop defines if animations must loop
  88762. * @returns the animation group
  88763. */
  88764. play(loop?: boolean): AnimationGroup;
  88765. /**
  88766. * Reset all animations to initial state
  88767. * @returns the animation group
  88768. */
  88769. reset(): AnimationGroup;
  88770. /**
  88771. * Restart animations from key 0
  88772. * @returns the animation group
  88773. */
  88774. restart(): AnimationGroup;
  88775. /**
  88776. * Stop all animations
  88777. * @returns the animation group
  88778. */
  88779. stop(): AnimationGroup;
  88780. /**
  88781. * Set animation weight for all animatables
  88782. * @param weight defines the weight to use
  88783. * @return the animationGroup
  88784. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88785. */
  88786. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88787. /**
  88788. * Synchronize and normalize all animatables with a source animatable
  88789. * @param root defines the root animatable to synchronize with
  88790. * @return the animationGroup
  88791. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88792. */
  88793. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88794. /**
  88795. * Goes to a specific frame in this animation group
  88796. * @param frame the frame number to go to
  88797. * @return the animationGroup
  88798. */
  88799. goToFrame(frame: number): AnimationGroup;
  88800. /**
  88801. * Dispose all associated resources
  88802. */
  88803. dispose(): void;
  88804. private _checkAnimationGroupEnded;
  88805. /**
  88806. * Clone the current animation group and returns a copy
  88807. * @param newName defines the name of the new group
  88808. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88809. * @returns the new aniamtion group
  88810. */
  88811. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88812. /**
  88813. * Returns a new AnimationGroup object parsed from the source provided.
  88814. * @param parsedAnimationGroup defines the source
  88815. * @param scene defines the scene that will receive the animationGroup
  88816. * @returns a new AnimationGroup
  88817. */
  88818. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88819. /**
  88820. * Returns the string "AnimationGroup"
  88821. * @returns "AnimationGroup"
  88822. */
  88823. getClassName(): string;
  88824. /**
  88825. * Creates a detailled string about the object
  88826. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88827. * @returns a string representing the object
  88828. */
  88829. toString(fullDetails?: boolean): string;
  88830. }
  88831. }
  88832. declare module BABYLON {
  88833. /**
  88834. * Define an interface for all classes that will hold resources
  88835. */
  88836. export interface IDisposable {
  88837. /**
  88838. * Releases all held resources
  88839. */
  88840. dispose(): void;
  88841. }
  88842. /** Interface defining initialization parameters for Scene class */
  88843. export interface SceneOptions {
  88844. /**
  88845. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88846. * It will improve performance when the number of geometries becomes important.
  88847. */
  88848. useGeometryUniqueIdsMap?: boolean;
  88849. /**
  88850. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88851. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88852. */
  88853. useMaterialMeshMap?: boolean;
  88854. /**
  88855. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88856. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88857. */
  88858. useClonedMeshhMap?: boolean;
  88859. }
  88860. /**
  88861. * Represents a scene to be rendered by the engine.
  88862. * @see http://doc.babylonjs.com/features/scene
  88863. */
  88864. export class Scene extends AbstractScene implements IAnimatable {
  88865. private static _uniqueIdCounter;
  88866. /** The fog is deactivated */
  88867. static readonly FOGMODE_NONE: number;
  88868. /** The fog density is following an exponential function */
  88869. static readonly FOGMODE_EXP: number;
  88870. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88871. static readonly FOGMODE_EXP2: number;
  88872. /** The fog density is following a linear function. */
  88873. static readonly FOGMODE_LINEAR: number;
  88874. /**
  88875. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88877. */
  88878. static MinDeltaTime: number;
  88879. /**
  88880. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88882. */
  88883. static MaxDeltaTime: number;
  88884. /**
  88885. * Factory used to create the default material.
  88886. * @param name The name of the material to create
  88887. * @param scene The scene to create the material for
  88888. * @returns The default material
  88889. */
  88890. static DefaultMaterialFactory(scene: Scene): Material;
  88891. /**
  88892. * Factory used to create the a collision coordinator.
  88893. * @returns The collision coordinator
  88894. */
  88895. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88896. /** @hidden */
  88897. readonly _isScene: boolean;
  88898. /**
  88899. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88900. */
  88901. autoClear: boolean;
  88902. /**
  88903. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88904. */
  88905. autoClearDepthAndStencil: boolean;
  88906. /**
  88907. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88908. */
  88909. clearColor: Color4;
  88910. /**
  88911. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88912. */
  88913. ambientColor: Color3;
  88914. /** @hidden */
  88915. _environmentBRDFTexture: BaseTexture;
  88916. /** @hidden */
  88917. protected _environmentTexture: Nullable<BaseTexture>;
  88918. /**
  88919. * Texture used in all pbr material as the reflection texture.
  88920. * As in the majority of the scene they are the same (exception for multi room and so on),
  88921. * this is easier to reference from here than from all the materials.
  88922. */
  88923. /**
  88924. * Texture used in all pbr material as the reflection texture.
  88925. * As in the majority of the scene they are the same (exception for multi room and so on),
  88926. * this is easier to set here than in all the materials.
  88927. */
  88928. environmentTexture: Nullable<BaseTexture>;
  88929. /** @hidden */
  88930. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88931. /**
  88932. * Default image processing configuration used either in the rendering
  88933. * Forward main pass or through the imageProcessingPostProcess if present.
  88934. * As in the majority of the scene they are the same (exception for multi camera),
  88935. * this is easier to reference from here than from all the materials and post process.
  88936. *
  88937. * No setter as we it is a shared configuration, you can set the values instead.
  88938. */
  88939. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88940. private _forceWireframe;
  88941. /**
  88942. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88943. */
  88944. forceWireframe: boolean;
  88945. private _forcePointsCloud;
  88946. /**
  88947. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88948. */
  88949. forcePointsCloud: boolean;
  88950. /**
  88951. * Gets or sets the active clipplane 1
  88952. */
  88953. clipPlane: Nullable<Plane>;
  88954. /**
  88955. * Gets or sets the active clipplane 2
  88956. */
  88957. clipPlane2: Nullable<Plane>;
  88958. /**
  88959. * Gets or sets the active clipplane 3
  88960. */
  88961. clipPlane3: Nullable<Plane>;
  88962. /**
  88963. * Gets or sets the active clipplane 4
  88964. */
  88965. clipPlane4: Nullable<Plane>;
  88966. /**
  88967. * Gets or sets a boolean indicating if animations are enabled
  88968. */
  88969. animationsEnabled: boolean;
  88970. private _animationPropertiesOverride;
  88971. /**
  88972. * Gets or sets the animation properties override
  88973. */
  88974. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88975. /**
  88976. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88977. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88978. */
  88979. useConstantAnimationDeltaTime: boolean;
  88980. /**
  88981. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88982. * Please note that it requires to run a ray cast through the scene on every frame
  88983. */
  88984. constantlyUpdateMeshUnderPointer: boolean;
  88985. /**
  88986. * Defines the HTML cursor to use when hovering over interactive elements
  88987. */
  88988. hoverCursor: string;
  88989. /**
  88990. * Defines the HTML default cursor to use (empty by default)
  88991. */
  88992. defaultCursor: string;
  88993. /**
  88994. * This is used to call preventDefault() on pointer down
  88995. * in order to block unwanted artifacts like system double clicks
  88996. */
  88997. preventDefaultOnPointerDown: boolean;
  88998. /**
  88999. * This is used to call preventDefault() on pointer up
  89000. * in order to block unwanted artifacts like system double clicks
  89001. */
  89002. preventDefaultOnPointerUp: boolean;
  89003. /**
  89004. * Gets or sets user defined metadata
  89005. */
  89006. metadata: any;
  89007. /**
  89008. * For internal use only. Please do not use.
  89009. */
  89010. reservedDataStore: any;
  89011. /**
  89012. * Gets the name of the plugin used to load this scene (null by default)
  89013. */
  89014. loadingPluginName: string;
  89015. /**
  89016. * Use this array to add regular expressions used to disable offline support for specific urls
  89017. */
  89018. disableOfflineSupportExceptionRules: RegExp[];
  89019. /**
  89020. * An event triggered when the scene is disposed.
  89021. */
  89022. onDisposeObservable: Observable<Scene>;
  89023. private _onDisposeObserver;
  89024. /** Sets a function to be executed when this scene is disposed. */
  89025. onDispose: () => void;
  89026. /**
  89027. * An event triggered before rendering the scene (right after animations and physics)
  89028. */
  89029. onBeforeRenderObservable: Observable<Scene>;
  89030. private _onBeforeRenderObserver;
  89031. /** Sets a function to be executed before rendering this scene */
  89032. beforeRender: Nullable<() => void>;
  89033. /**
  89034. * An event triggered after rendering the scene
  89035. */
  89036. onAfterRenderObservable: Observable<Scene>;
  89037. private _onAfterRenderObserver;
  89038. /** Sets a function to be executed after rendering this scene */
  89039. afterRender: Nullable<() => void>;
  89040. /**
  89041. * An event triggered before animating the scene
  89042. */
  89043. onBeforeAnimationsObservable: Observable<Scene>;
  89044. /**
  89045. * An event triggered after animations processing
  89046. */
  89047. onAfterAnimationsObservable: Observable<Scene>;
  89048. /**
  89049. * An event triggered before draw calls are ready to be sent
  89050. */
  89051. onBeforeDrawPhaseObservable: Observable<Scene>;
  89052. /**
  89053. * An event triggered after draw calls have been sent
  89054. */
  89055. onAfterDrawPhaseObservable: Observable<Scene>;
  89056. /**
  89057. * An event triggered when the scene is ready
  89058. */
  89059. onReadyObservable: Observable<Scene>;
  89060. /**
  89061. * An event triggered before rendering a camera
  89062. */
  89063. onBeforeCameraRenderObservable: Observable<Camera>;
  89064. private _onBeforeCameraRenderObserver;
  89065. /** Sets a function to be executed before rendering a camera*/
  89066. beforeCameraRender: () => void;
  89067. /**
  89068. * An event triggered after rendering a camera
  89069. */
  89070. onAfterCameraRenderObservable: Observable<Camera>;
  89071. private _onAfterCameraRenderObserver;
  89072. /** Sets a function to be executed after rendering a camera*/
  89073. afterCameraRender: () => void;
  89074. /**
  89075. * An event triggered when active meshes evaluation is about to start
  89076. */
  89077. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  89078. /**
  89079. * An event triggered when active meshes evaluation is done
  89080. */
  89081. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  89082. /**
  89083. * An event triggered when particles rendering is about to start
  89084. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89085. */
  89086. onBeforeParticlesRenderingObservable: Observable<Scene>;
  89087. /**
  89088. * An event triggered when particles rendering is done
  89089. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89090. */
  89091. onAfterParticlesRenderingObservable: Observable<Scene>;
  89092. /**
  89093. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  89094. */
  89095. onDataLoadedObservable: Observable<Scene>;
  89096. /**
  89097. * An event triggered when a camera is created
  89098. */
  89099. onNewCameraAddedObservable: Observable<Camera>;
  89100. /**
  89101. * An event triggered when a camera is removed
  89102. */
  89103. onCameraRemovedObservable: Observable<Camera>;
  89104. /**
  89105. * An event triggered when a light is created
  89106. */
  89107. onNewLightAddedObservable: Observable<Light>;
  89108. /**
  89109. * An event triggered when a light is removed
  89110. */
  89111. onLightRemovedObservable: Observable<Light>;
  89112. /**
  89113. * An event triggered when a geometry is created
  89114. */
  89115. onNewGeometryAddedObservable: Observable<Geometry>;
  89116. /**
  89117. * An event triggered when a geometry is removed
  89118. */
  89119. onGeometryRemovedObservable: Observable<Geometry>;
  89120. /**
  89121. * An event triggered when a transform node is created
  89122. */
  89123. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  89124. /**
  89125. * An event triggered when a transform node is removed
  89126. */
  89127. onTransformNodeRemovedObservable: Observable<TransformNode>;
  89128. /**
  89129. * An event triggered when a mesh is created
  89130. */
  89131. onNewMeshAddedObservable: Observable<AbstractMesh>;
  89132. /**
  89133. * An event triggered when a mesh is removed
  89134. */
  89135. onMeshRemovedObservable: Observable<AbstractMesh>;
  89136. /**
  89137. * An event triggered when a skeleton is created
  89138. */
  89139. onNewSkeletonAddedObservable: Observable<Skeleton>;
  89140. /**
  89141. * An event triggered when a skeleton is removed
  89142. */
  89143. onSkeletonRemovedObservable: Observable<Skeleton>;
  89144. /**
  89145. * An event triggered when a material is created
  89146. */
  89147. onNewMaterialAddedObservable: Observable<Material>;
  89148. /**
  89149. * An event triggered when a material is removed
  89150. */
  89151. onMaterialRemovedObservable: Observable<Material>;
  89152. /**
  89153. * An event triggered when a texture is created
  89154. */
  89155. onNewTextureAddedObservable: Observable<BaseTexture>;
  89156. /**
  89157. * An event triggered when a texture is removed
  89158. */
  89159. onTextureRemovedObservable: Observable<BaseTexture>;
  89160. /**
  89161. * An event triggered when render targets are about to be rendered
  89162. * Can happen multiple times per frame.
  89163. */
  89164. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  89165. /**
  89166. * An event triggered when render targets were rendered.
  89167. * Can happen multiple times per frame.
  89168. */
  89169. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  89170. /**
  89171. * An event triggered before calculating deterministic simulation step
  89172. */
  89173. onBeforeStepObservable: Observable<Scene>;
  89174. /**
  89175. * An event triggered after calculating deterministic simulation step
  89176. */
  89177. onAfterStepObservable: Observable<Scene>;
  89178. /**
  89179. * An event triggered when the activeCamera property is updated
  89180. */
  89181. onActiveCameraChanged: Observable<Scene>;
  89182. /**
  89183. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  89184. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89185. * 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)
  89186. */
  89187. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89188. /**
  89189. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  89190. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89191. * 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)
  89192. */
  89193. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89194. /**
  89195. * This Observable will when a mesh has been imported into the scene.
  89196. */
  89197. onMeshImportedObservable: Observable<AbstractMesh>;
  89198. /**
  89199. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  89200. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  89201. */
  89202. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  89203. /** @hidden */
  89204. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  89205. /**
  89206. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  89207. */
  89208. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  89209. /**
  89210. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  89211. */
  89212. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  89213. /**
  89214. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  89215. */
  89216. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  89217. private _onPointerMove;
  89218. private _onPointerDown;
  89219. private _onPointerUp;
  89220. /** Callback called when a pointer move is detected */
  89221. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89222. /** Callback called when a pointer down is detected */
  89223. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89224. /** Callback called when a pointer up is detected */
  89225. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89226. /** Callback called when a pointer pick is detected */
  89227. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89228. /**
  89229. * 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).
  89230. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89231. */
  89232. onPrePointerObservable: Observable<PointerInfoPre>;
  89233. /**
  89234. * Observable event triggered each time an input event is received from the rendering canvas
  89235. */
  89236. onPointerObservable: Observable<PointerInfo>;
  89237. /**
  89238. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89239. */
  89240. readonly unTranslatedPointer: Vector2;
  89241. /** The distance in pixel that you have to move to prevent some events */
  89242. static DragMovementThreshold: number;
  89243. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89244. static LongPressDelay: number;
  89245. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89246. static DoubleClickDelay: number;
  89247. /** If you need to check double click without raising a single click at first click, enable this flag */
  89248. static ExclusiveDoubleClickMode: boolean;
  89249. private _initClickEvent;
  89250. private _initActionManager;
  89251. private _delayedSimpleClick;
  89252. private _delayedSimpleClickTimeout;
  89253. private _previousDelayedSimpleClickTimeout;
  89254. private _meshPickProceed;
  89255. private _previousButtonPressed;
  89256. private _currentPickResult;
  89257. private _previousPickResult;
  89258. private _totalPointersPressed;
  89259. private _doubleClickOccured;
  89260. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89261. cameraToUseForPointers: Nullable<Camera>;
  89262. private _pointerX;
  89263. private _pointerY;
  89264. private _unTranslatedPointerX;
  89265. private _unTranslatedPointerY;
  89266. private _startingPointerPosition;
  89267. private _previousStartingPointerPosition;
  89268. private _startingPointerTime;
  89269. private _previousStartingPointerTime;
  89270. private _pointerCaptures;
  89271. private _timeAccumulator;
  89272. private _currentStepId;
  89273. private _currentInternalStep;
  89274. /** @hidden */
  89275. _mirroredCameraPosition: Nullable<Vector3>;
  89276. /**
  89277. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89278. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89279. */
  89280. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89281. /**
  89282. * Observable event triggered each time an keyboard event is received from the hosting window
  89283. */
  89284. onKeyboardObservable: Observable<KeyboardInfo>;
  89285. private _onKeyDown;
  89286. private _onKeyUp;
  89287. private _onCanvasFocusObserver;
  89288. private _onCanvasBlurObserver;
  89289. private _useRightHandedSystem;
  89290. /**
  89291. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89292. */
  89293. useRightHandedSystem: boolean;
  89294. /**
  89295. * Sets the step Id used by deterministic lock step
  89296. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89297. * @param newStepId defines the step Id
  89298. */
  89299. setStepId(newStepId: number): void;
  89300. /**
  89301. * Gets the step Id used by deterministic lock step
  89302. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89303. * @returns the step Id
  89304. */
  89305. getStepId(): number;
  89306. /**
  89307. * Gets the internal step used by deterministic lock step
  89308. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89309. * @returns the internal step
  89310. */
  89311. getInternalStep(): number;
  89312. private _fogEnabled;
  89313. /**
  89314. * Gets or sets a boolean indicating if fog is enabled on this scene
  89315. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89316. * (Default is true)
  89317. */
  89318. fogEnabled: boolean;
  89319. private _fogMode;
  89320. /**
  89321. * Gets or sets the fog mode to use
  89322. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89323. * | mode | value |
  89324. * | --- | --- |
  89325. * | FOGMODE_NONE | 0 |
  89326. * | FOGMODE_EXP | 1 |
  89327. * | FOGMODE_EXP2 | 2 |
  89328. * | FOGMODE_LINEAR | 3 |
  89329. */
  89330. fogMode: number;
  89331. /**
  89332. * Gets or sets the fog color to use
  89333. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89334. * (Default is Color3(0.2, 0.2, 0.3))
  89335. */
  89336. fogColor: Color3;
  89337. /**
  89338. * Gets or sets the fog density to use
  89339. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89340. * (Default is 0.1)
  89341. */
  89342. fogDensity: number;
  89343. /**
  89344. * Gets or sets the fog start distance to use
  89345. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89346. * (Default is 0)
  89347. */
  89348. fogStart: number;
  89349. /**
  89350. * Gets or sets the fog end distance to use
  89351. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89352. * (Default is 1000)
  89353. */
  89354. fogEnd: number;
  89355. private _shadowsEnabled;
  89356. /**
  89357. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89358. */
  89359. shadowsEnabled: boolean;
  89360. private _lightsEnabled;
  89361. /**
  89362. * Gets or sets a boolean indicating if lights are enabled on this scene
  89363. */
  89364. lightsEnabled: boolean;
  89365. /** All of the active cameras added to this scene. */
  89366. activeCameras: Camera[];
  89367. private _activeCamera;
  89368. /** Gets or sets the current active camera */
  89369. activeCamera: Nullable<Camera>;
  89370. private _defaultMaterial;
  89371. /** The default material used on meshes when no material is affected */
  89372. /** The default material used on meshes when no material is affected */
  89373. defaultMaterial: Material;
  89374. private _texturesEnabled;
  89375. /**
  89376. * Gets or sets a boolean indicating if textures are enabled on this scene
  89377. */
  89378. texturesEnabled: boolean;
  89379. /**
  89380. * Gets or sets a boolean indicating if particles are enabled on this scene
  89381. */
  89382. particlesEnabled: boolean;
  89383. /**
  89384. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89385. */
  89386. spritesEnabled: boolean;
  89387. private _skeletonsEnabled;
  89388. /**
  89389. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89390. */
  89391. skeletonsEnabled: boolean;
  89392. /**
  89393. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89394. */
  89395. lensFlaresEnabled: boolean;
  89396. /**
  89397. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89398. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89399. */
  89400. collisionsEnabled: boolean;
  89401. private _collisionCoordinator;
  89402. /** @hidden */
  89403. readonly collisionCoordinator: ICollisionCoordinator;
  89404. /**
  89405. * Defines the gravity applied to this scene (used only for collisions)
  89406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89407. */
  89408. gravity: Vector3;
  89409. /**
  89410. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89411. */
  89412. postProcessesEnabled: boolean;
  89413. /**
  89414. * The list of postprocesses added to the scene
  89415. */
  89416. postProcesses: PostProcess[];
  89417. /**
  89418. * Gets the current postprocess manager
  89419. */
  89420. postProcessManager: PostProcessManager;
  89421. /**
  89422. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89423. */
  89424. renderTargetsEnabled: boolean;
  89425. /**
  89426. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89427. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89428. */
  89429. dumpNextRenderTargets: boolean;
  89430. /**
  89431. * The list of user defined render targets added to the scene
  89432. */
  89433. customRenderTargets: RenderTargetTexture[];
  89434. /**
  89435. * Defines if texture loading must be delayed
  89436. * If true, textures will only be loaded when they need to be rendered
  89437. */
  89438. useDelayedTextureLoading: boolean;
  89439. /**
  89440. * Gets the list of meshes imported to the scene through SceneLoader
  89441. */
  89442. importedMeshesFiles: String[];
  89443. /**
  89444. * Gets or sets a boolean indicating if probes are enabled on this scene
  89445. */
  89446. probesEnabled: boolean;
  89447. /**
  89448. * Gets or sets the current offline provider to use to store scene data
  89449. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89450. */
  89451. offlineProvider: IOfflineProvider;
  89452. /**
  89453. * Gets or sets the action manager associated with the scene
  89454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89455. */
  89456. actionManager: AbstractActionManager;
  89457. private _meshesForIntersections;
  89458. /**
  89459. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89460. */
  89461. proceduralTexturesEnabled: boolean;
  89462. private _engine;
  89463. private _totalVertices;
  89464. /** @hidden */
  89465. _activeIndices: PerfCounter;
  89466. /** @hidden */
  89467. _activeParticles: PerfCounter;
  89468. /** @hidden */
  89469. _activeBones: PerfCounter;
  89470. private _animationRatio;
  89471. /** @hidden */
  89472. _animationTimeLast: number;
  89473. /** @hidden */
  89474. _animationTime: number;
  89475. /**
  89476. * Gets or sets a general scale for animation speed
  89477. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89478. */
  89479. animationTimeScale: number;
  89480. /** @hidden */
  89481. _cachedMaterial: Nullable<Material>;
  89482. /** @hidden */
  89483. _cachedEffect: Nullable<Effect>;
  89484. /** @hidden */
  89485. _cachedVisibility: Nullable<number>;
  89486. private _renderId;
  89487. private _frameId;
  89488. private _executeWhenReadyTimeoutId;
  89489. private _intermediateRendering;
  89490. private _viewUpdateFlag;
  89491. private _projectionUpdateFlag;
  89492. private _alternateViewUpdateFlag;
  89493. private _alternateProjectionUpdateFlag;
  89494. /** @hidden */
  89495. _toBeDisposed: Nullable<IDisposable>[];
  89496. private _activeRequests;
  89497. /** @hidden */
  89498. _pendingData: any[];
  89499. private _isDisposed;
  89500. /**
  89501. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89502. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89503. */
  89504. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89505. private _activeMeshes;
  89506. private _processedMaterials;
  89507. private _renderTargets;
  89508. /** @hidden */
  89509. _activeParticleSystems: SmartArray<IParticleSystem>;
  89510. private _activeSkeletons;
  89511. private _softwareSkinnedMeshes;
  89512. private _renderingManager;
  89513. /** @hidden */
  89514. _activeAnimatables: Animatable[];
  89515. private _transformMatrix;
  89516. private _sceneUbo;
  89517. private _alternateSceneUbo;
  89518. private _viewMatrix;
  89519. private _projectionMatrix;
  89520. private _alternateViewMatrix;
  89521. private _alternateProjectionMatrix;
  89522. private _alternateTransformMatrix;
  89523. private _useAlternateCameraConfiguration;
  89524. private _alternateRendering;
  89525. private _wheelEventName;
  89526. /** @hidden */
  89527. _forcedViewPosition: Nullable<Vector3>;
  89528. /** @hidden */
  89529. readonly _isAlternateRenderingEnabled: boolean;
  89530. private _frustumPlanes;
  89531. /**
  89532. * Gets the list of frustum planes (built from the active camera)
  89533. */
  89534. readonly frustumPlanes: Plane[];
  89535. /**
  89536. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89537. * This is useful if there are more lights that the maximum simulteanous authorized
  89538. */
  89539. requireLightSorting: boolean;
  89540. /** @hidden */
  89541. readonly useMaterialMeshMap: boolean;
  89542. /** @hidden */
  89543. readonly useClonedMeshhMap: boolean;
  89544. private _pointerOverMesh;
  89545. private _pickedDownMesh;
  89546. private _pickedUpMesh;
  89547. private _externalData;
  89548. private _uid;
  89549. /**
  89550. * @hidden
  89551. * Backing store of defined scene components.
  89552. */
  89553. _components: ISceneComponent[];
  89554. /**
  89555. * @hidden
  89556. * Backing store of defined scene components.
  89557. */
  89558. _serializableComponents: ISceneSerializableComponent[];
  89559. /**
  89560. * List of components to register on the next registration step.
  89561. */
  89562. private _transientComponents;
  89563. /**
  89564. * Registers the transient components if needed.
  89565. */
  89566. private _registerTransientComponents;
  89567. /**
  89568. * @hidden
  89569. * Add a component to the scene.
  89570. * Note that the ccomponent could be registered on th next frame if this is called after
  89571. * the register component stage.
  89572. * @param component Defines the component to add to the scene
  89573. */
  89574. _addComponent(component: ISceneComponent): void;
  89575. /**
  89576. * @hidden
  89577. * Gets a component from the scene.
  89578. * @param name defines the name of the component to retrieve
  89579. * @returns the component or null if not present
  89580. */
  89581. _getComponent(name: string): Nullable<ISceneComponent>;
  89582. /**
  89583. * @hidden
  89584. * Defines the actions happening before camera updates.
  89585. */
  89586. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89587. /**
  89588. * @hidden
  89589. * Defines the actions happening before clear the canvas.
  89590. */
  89591. _beforeClearStage: Stage<SimpleStageAction>;
  89592. /**
  89593. * @hidden
  89594. * Defines the actions when collecting render targets for the frame.
  89595. */
  89596. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89597. /**
  89598. * @hidden
  89599. * Defines the actions happening for one camera in the frame.
  89600. */
  89601. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89602. /**
  89603. * @hidden
  89604. * Defines the actions happening during the per mesh ready checks.
  89605. */
  89606. _isReadyForMeshStage: Stage<MeshStageAction>;
  89607. /**
  89608. * @hidden
  89609. * Defines the actions happening before evaluate active mesh checks.
  89610. */
  89611. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89612. /**
  89613. * @hidden
  89614. * Defines the actions happening during the evaluate sub mesh checks.
  89615. */
  89616. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89617. /**
  89618. * @hidden
  89619. * Defines the actions happening during the active mesh stage.
  89620. */
  89621. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89622. /**
  89623. * @hidden
  89624. * Defines the actions happening during the per camera render target step.
  89625. */
  89626. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89627. /**
  89628. * @hidden
  89629. * Defines the actions happening just before the active camera is drawing.
  89630. */
  89631. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89632. /**
  89633. * @hidden
  89634. * Defines the actions happening just before a render target is drawing.
  89635. */
  89636. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89637. /**
  89638. * @hidden
  89639. * Defines the actions happening just before a rendering group is drawing.
  89640. */
  89641. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89642. /**
  89643. * @hidden
  89644. * Defines the actions happening just before a mesh is drawing.
  89645. */
  89646. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89647. /**
  89648. * @hidden
  89649. * Defines the actions happening just after a mesh has been drawn.
  89650. */
  89651. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89652. /**
  89653. * @hidden
  89654. * Defines the actions happening just after a rendering group has been drawn.
  89655. */
  89656. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89657. /**
  89658. * @hidden
  89659. * Defines the actions happening just after the active camera has been drawn.
  89660. */
  89661. _afterCameraDrawStage: Stage<CameraStageAction>;
  89662. /**
  89663. * @hidden
  89664. * Defines the actions happening just after a render target has been drawn.
  89665. */
  89666. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89667. /**
  89668. * @hidden
  89669. * Defines the actions happening just after rendering all cameras and computing intersections.
  89670. */
  89671. _afterRenderStage: Stage<SimpleStageAction>;
  89672. /**
  89673. * @hidden
  89674. * Defines the actions happening when a pointer move event happens.
  89675. */
  89676. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89677. /**
  89678. * @hidden
  89679. * Defines the actions happening when a pointer down event happens.
  89680. */
  89681. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89682. /**
  89683. * @hidden
  89684. * Defines the actions happening when a pointer up event happens.
  89685. */
  89686. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89687. /**
  89688. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89689. */
  89690. private geometriesByUniqueId;
  89691. /**
  89692. * Creates a new Scene
  89693. * @param engine defines the engine to use to render this scene
  89694. * @param options defines the scene options
  89695. */
  89696. constructor(engine: Engine, options?: SceneOptions);
  89697. private _defaultMeshCandidates;
  89698. /**
  89699. * @hidden
  89700. */
  89701. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89702. private _defaultSubMeshCandidates;
  89703. /**
  89704. * @hidden
  89705. */
  89706. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89707. /**
  89708. * Sets the default candidate providers for the scene.
  89709. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89710. * and getCollidingSubMeshCandidates to their default function
  89711. */
  89712. setDefaultCandidateProviders(): void;
  89713. /**
  89714. * Gets the mesh that is currently under the pointer
  89715. */
  89716. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89717. /**
  89718. * Gets or sets the current on-screen X position of the pointer
  89719. */
  89720. pointerX: number;
  89721. /**
  89722. * Gets or sets the current on-screen Y position of the pointer
  89723. */
  89724. pointerY: number;
  89725. /**
  89726. * Gets the cached material (ie. the latest rendered one)
  89727. * @returns the cached material
  89728. */
  89729. getCachedMaterial(): Nullable<Material>;
  89730. /**
  89731. * Gets the cached effect (ie. the latest rendered one)
  89732. * @returns the cached effect
  89733. */
  89734. getCachedEffect(): Nullable<Effect>;
  89735. /**
  89736. * Gets the cached visibility state (ie. the latest rendered one)
  89737. * @returns the cached visibility state
  89738. */
  89739. getCachedVisibility(): Nullable<number>;
  89740. /**
  89741. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89742. * @param material defines the current material
  89743. * @param effect defines the current effect
  89744. * @param visibility defines the current visibility state
  89745. * @returns true if one parameter is not cached
  89746. */
  89747. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89748. /**
  89749. * Gets the engine associated with the scene
  89750. * @returns an Engine
  89751. */
  89752. getEngine(): Engine;
  89753. /**
  89754. * Gets the total number of vertices rendered per frame
  89755. * @returns the total number of vertices rendered per frame
  89756. */
  89757. getTotalVertices(): number;
  89758. /**
  89759. * Gets the performance counter for total vertices
  89760. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89761. */
  89762. readonly totalVerticesPerfCounter: PerfCounter;
  89763. /**
  89764. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89765. * @returns the total number of active indices rendered per frame
  89766. */
  89767. getActiveIndices(): number;
  89768. /**
  89769. * Gets the performance counter for active indices
  89770. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89771. */
  89772. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89773. /**
  89774. * Gets the total number of active particles rendered per frame
  89775. * @returns the total number of active particles rendered per frame
  89776. */
  89777. getActiveParticles(): number;
  89778. /**
  89779. * Gets the performance counter for active particles
  89780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89781. */
  89782. readonly activeParticlesPerfCounter: PerfCounter;
  89783. /**
  89784. * Gets the total number of active bones rendered per frame
  89785. * @returns the total number of active bones rendered per frame
  89786. */
  89787. getActiveBones(): number;
  89788. /**
  89789. * Gets the performance counter for active bones
  89790. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89791. */
  89792. readonly activeBonesPerfCounter: PerfCounter;
  89793. /**
  89794. * Gets the array of active meshes
  89795. * @returns an array of AbstractMesh
  89796. */
  89797. getActiveMeshes(): SmartArray<AbstractMesh>;
  89798. /**
  89799. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89800. * @returns a number
  89801. */
  89802. getAnimationRatio(): number;
  89803. /**
  89804. * Gets an unique Id for the current render phase
  89805. * @returns a number
  89806. */
  89807. getRenderId(): number;
  89808. /**
  89809. * Gets an unique Id for the current frame
  89810. * @returns a number
  89811. */
  89812. getFrameId(): number;
  89813. /** Call this function if you want to manually increment the render Id*/
  89814. incrementRenderId(): void;
  89815. private _updatePointerPosition;
  89816. private _createUbo;
  89817. private _createAlternateUbo;
  89818. private _setRayOnPointerInfo;
  89819. /**
  89820. * Use this method to simulate a pointer move on a mesh
  89821. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89822. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89823. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89824. * @returns the current scene
  89825. */
  89826. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89827. private _processPointerMove;
  89828. private _checkPrePointerObservable;
  89829. /**
  89830. * Use this method to simulate a pointer down on a mesh
  89831. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89832. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89833. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89834. * @returns the current scene
  89835. */
  89836. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89837. private _processPointerDown;
  89838. /**
  89839. * Use this method to simulate a pointer up on a mesh
  89840. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89841. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89842. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89843. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89844. * @returns the current scene
  89845. */
  89846. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89847. private _processPointerUp;
  89848. /**
  89849. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89850. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89851. * @returns true if the pointer was captured
  89852. */
  89853. isPointerCaptured(pointerId?: number): boolean;
  89854. /** @hidden */
  89855. _isPointerSwiping(): boolean;
  89856. /**
  89857. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89858. * @param attachUp defines if you want to attach events to pointerup
  89859. * @param attachDown defines if you want to attach events to pointerdown
  89860. * @param attachMove defines if you want to attach events to pointermove
  89861. */
  89862. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89863. /** Detaches all event handlers*/
  89864. detachControl(): void;
  89865. /**
  89866. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89867. * Delay loaded resources are not taking in account
  89868. * @return true if all required resources are ready
  89869. */
  89870. isReady(): boolean;
  89871. /** Resets all cached information relative to material (including effect and visibility) */
  89872. resetCachedMaterial(): void;
  89873. /**
  89874. * Registers a function to be called before every frame render
  89875. * @param func defines the function to register
  89876. */
  89877. registerBeforeRender(func: () => void): void;
  89878. /**
  89879. * Unregisters a function called before every frame render
  89880. * @param func defines the function to unregister
  89881. */
  89882. unregisterBeforeRender(func: () => void): void;
  89883. /**
  89884. * Registers a function to be called after every frame render
  89885. * @param func defines the function to register
  89886. */
  89887. registerAfterRender(func: () => void): void;
  89888. /**
  89889. * Unregisters a function called after every frame render
  89890. * @param func defines the function to unregister
  89891. */
  89892. unregisterAfterRender(func: () => void): void;
  89893. private _executeOnceBeforeRender;
  89894. /**
  89895. * The provided function will run before render once and will be disposed afterwards.
  89896. * A timeout delay can be provided so that the function will be executed in N ms.
  89897. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89898. * @param func The function to be executed.
  89899. * @param timeout optional delay in ms
  89900. */
  89901. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89902. /** @hidden */
  89903. _addPendingData(data: any): void;
  89904. /** @hidden */
  89905. _removePendingData(data: any): void;
  89906. /**
  89907. * Returns the number of items waiting to be loaded
  89908. * @returns the number of items waiting to be loaded
  89909. */
  89910. getWaitingItemsCount(): number;
  89911. /**
  89912. * Returns a boolean indicating if the scene is still loading data
  89913. */
  89914. readonly isLoading: boolean;
  89915. /**
  89916. * Registers a function to be executed when the scene is ready
  89917. * @param {Function} func - the function to be executed
  89918. */
  89919. executeWhenReady(func: () => void): void;
  89920. /**
  89921. * Returns a promise that resolves when the scene is ready
  89922. * @returns A promise that resolves when the scene is ready
  89923. */
  89924. whenReadyAsync(): Promise<void>;
  89925. /** @hidden */
  89926. _checkIsReady(): void;
  89927. /**
  89928. * Gets all animatable attached to the scene
  89929. */
  89930. readonly animatables: Animatable[];
  89931. /**
  89932. * Resets the last animation time frame.
  89933. * Useful to override when animations start running when loading a scene for the first time.
  89934. */
  89935. resetLastAnimationTimeFrame(): void;
  89936. /** @hidden */
  89937. _switchToAlternateCameraConfiguration(active: boolean): void;
  89938. /**
  89939. * Gets the current view matrix
  89940. * @returns a Matrix
  89941. */
  89942. getViewMatrix(): Matrix;
  89943. /**
  89944. * Gets the current projection matrix
  89945. * @returns a Matrix
  89946. */
  89947. getProjectionMatrix(): Matrix;
  89948. /**
  89949. * Gets the current transform matrix
  89950. * @returns a Matrix made of View * Projection
  89951. */
  89952. getTransformMatrix(): Matrix;
  89953. /**
  89954. * Sets the current transform matrix
  89955. * @param view defines the View matrix to use
  89956. * @param projection defines the Projection matrix to use
  89957. */
  89958. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89959. /** @hidden */
  89960. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89961. /**
  89962. * Gets the uniform buffer used to store scene data
  89963. * @returns a UniformBuffer
  89964. */
  89965. getSceneUniformBuffer(): UniformBuffer;
  89966. /**
  89967. * Gets an unique (relatively to the current scene) Id
  89968. * @returns an unique number for the scene
  89969. */
  89970. getUniqueId(): number;
  89971. /**
  89972. * Add a mesh to the list of scene's meshes
  89973. * @param newMesh defines the mesh to add
  89974. * @param recursive if all child meshes should also be added to the scene
  89975. */
  89976. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89977. /**
  89978. * Remove a mesh for the list of scene's meshes
  89979. * @param toRemove defines the mesh to remove
  89980. * @param recursive if all child meshes should also be removed from the scene
  89981. * @returns the index where the mesh was in the mesh list
  89982. */
  89983. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89984. /**
  89985. * Add a transform node to the list of scene's transform nodes
  89986. * @param newTransformNode defines the transform node to add
  89987. */
  89988. addTransformNode(newTransformNode: TransformNode): void;
  89989. /**
  89990. * Remove a transform node for the list of scene's transform nodes
  89991. * @param toRemove defines the transform node to remove
  89992. * @returns the index where the transform node was in the transform node list
  89993. */
  89994. removeTransformNode(toRemove: TransformNode): number;
  89995. /**
  89996. * Remove a skeleton for the list of scene's skeletons
  89997. * @param toRemove defines the skeleton to remove
  89998. * @returns the index where the skeleton was in the skeleton list
  89999. */
  90000. removeSkeleton(toRemove: Skeleton): number;
  90001. /**
  90002. * Remove a morph target for the list of scene's morph targets
  90003. * @param toRemove defines the morph target to remove
  90004. * @returns the index where the morph target was in the morph target list
  90005. */
  90006. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  90007. /**
  90008. * Remove a light for the list of scene's lights
  90009. * @param toRemove defines the light to remove
  90010. * @returns the index where the light was in the light list
  90011. */
  90012. removeLight(toRemove: Light): number;
  90013. /**
  90014. * Remove a camera for the list of scene's cameras
  90015. * @param toRemove defines the camera to remove
  90016. * @returns the index where the camera was in the camera list
  90017. */
  90018. removeCamera(toRemove: Camera): number;
  90019. /**
  90020. * Remove a particle system for the list of scene's particle systems
  90021. * @param toRemove defines the particle system to remove
  90022. * @returns the index where the particle system was in the particle system list
  90023. */
  90024. removeParticleSystem(toRemove: IParticleSystem): number;
  90025. /**
  90026. * Remove a animation for the list of scene's animations
  90027. * @param toRemove defines the animation to remove
  90028. * @returns the index where the animation was in the animation list
  90029. */
  90030. removeAnimation(toRemove: Animation): number;
  90031. /**
  90032. * Removes the given animation group from this scene.
  90033. * @param toRemove The animation group to remove
  90034. * @returns The index of the removed animation group
  90035. */
  90036. removeAnimationGroup(toRemove: AnimationGroup): number;
  90037. /**
  90038. * Removes the given multi-material from this scene.
  90039. * @param toRemove The multi-material to remove
  90040. * @returns The index of the removed multi-material
  90041. */
  90042. removeMultiMaterial(toRemove: MultiMaterial): number;
  90043. /**
  90044. * Removes the given material from this scene.
  90045. * @param toRemove The material to remove
  90046. * @returns The index of the removed material
  90047. */
  90048. removeMaterial(toRemove: Material): number;
  90049. /**
  90050. * Removes the given action manager from this scene.
  90051. * @param toRemove The action manager to remove
  90052. * @returns The index of the removed action manager
  90053. */
  90054. removeActionManager(toRemove: AbstractActionManager): number;
  90055. /**
  90056. * Removes the given texture from this scene.
  90057. * @param toRemove The texture to remove
  90058. * @returns The index of the removed texture
  90059. */
  90060. removeTexture(toRemove: BaseTexture): number;
  90061. /**
  90062. * Adds the given light to this scene
  90063. * @param newLight The light to add
  90064. */
  90065. addLight(newLight: Light): void;
  90066. /**
  90067. * Sorts the list list based on light priorities
  90068. */
  90069. sortLightsByPriority(): void;
  90070. /**
  90071. * Adds the given camera to this scene
  90072. * @param newCamera The camera to add
  90073. */
  90074. addCamera(newCamera: Camera): void;
  90075. /**
  90076. * Adds the given skeleton to this scene
  90077. * @param newSkeleton The skeleton to add
  90078. */
  90079. addSkeleton(newSkeleton: Skeleton): void;
  90080. /**
  90081. * Adds the given particle system to this scene
  90082. * @param newParticleSystem The particle system to add
  90083. */
  90084. addParticleSystem(newParticleSystem: IParticleSystem): void;
  90085. /**
  90086. * Adds the given animation to this scene
  90087. * @param newAnimation The animation to add
  90088. */
  90089. addAnimation(newAnimation: Animation): void;
  90090. /**
  90091. * Adds the given animation group to this scene.
  90092. * @param newAnimationGroup The animation group to add
  90093. */
  90094. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  90095. /**
  90096. * Adds the given multi-material to this scene
  90097. * @param newMultiMaterial The multi-material to add
  90098. */
  90099. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  90100. /**
  90101. * Adds the given material to this scene
  90102. * @param newMaterial The material to add
  90103. */
  90104. addMaterial(newMaterial: Material): void;
  90105. /**
  90106. * Adds the given morph target to this scene
  90107. * @param newMorphTargetManager The morph target to add
  90108. */
  90109. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  90110. /**
  90111. * Adds the given geometry to this scene
  90112. * @param newGeometry The geometry to add
  90113. */
  90114. addGeometry(newGeometry: Geometry): void;
  90115. /**
  90116. * Adds the given action manager to this scene
  90117. * @param newActionManager The action manager to add
  90118. */
  90119. addActionManager(newActionManager: AbstractActionManager): void;
  90120. /**
  90121. * Adds the given texture to this scene.
  90122. * @param newTexture The texture to add
  90123. */
  90124. addTexture(newTexture: BaseTexture): void;
  90125. /**
  90126. * Switch active camera
  90127. * @param newCamera defines the new active camera
  90128. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  90129. */
  90130. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  90131. /**
  90132. * sets the active camera of the scene using its ID
  90133. * @param id defines the camera's ID
  90134. * @return the new active camera or null if none found.
  90135. */
  90136. setActiveCameraByID(id: string): Nullable<Camera>;
  90137. /**
  90138. * sets the active camera of the scene using its name
  90139. * @param name defines the camera's name
  90140. * @returns the new active camera or null if none found.
  90141. */
  90142. setActiveCameraByName(name: string): Nullable<Camera>;
  90143. /**
  90144. * get an animation group using its name
  90145. * @param name defines the material's name
  90146. * @return the animation group or null if none found.
  90147. */
  90148. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  90149. /**
  90150. * get a material using its id
  90151. * @param id defines the material's ID
  90152. * @return the material or null if none found.
  90153. */
  90154. getMaterialByID(id: string): Nullable<Material>;
  90155. /**
  90156. * Gets a material using its name
  90157. * @param name defines the material's name
  90158. * @return the material or null if none found.
  90159. */
  90160. getMaterialByName(name: string): Nullable<Material>;
  90161. /**
  90162. * Gets a camera using its id
  90163. * @param id defines the id to look for
  90164. * @returns the camera or null if not found
  90165. */
  90166. getCameraByID(id: string): Nullable<Camera>;
  90167. /**
  90168. * Gets a camera using its unique id
  90169. * @param uniqueId defines the unique id to look for
  90170. * @returns the camera or null if not found
  90171. */
  90172. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  90173. /**
  90174. * Gets a camera using its name
  90175. * @param name defines the camera's name
  90176. * @return the camera or null if none found.
  90177. */
  90178. getCameraByName(name: string): Nullable<Camera>;
  90179. /**
  90180. * Gets a bone using its id
  90181. * @param id defines the bone's id
  90182. * @return the bone or null if not found
  90183. */
  90184. getBoneByID(id: string): Nullable<Bone>;
  90185. /**
  90186. * Gets a bone using its id
  90187. * @param name defines the bone's name
  90188. * @return the bone or null if not found
  90189. */
  90190. getBoneByName(name: string): Nullable<Bone>;
  90191. /**
  90192. * Gets a light node using its name
  90193. * @param name defines the the light's name
  90194. * @return the light or null if none found.
  90195. */
  90196. getLightByName(name: string): Nullable<Light>;
  90197. /**
  90198. * Gets a light node using its id
  90199. * @param id defines the light's id
  90200. * @return the light or null if none found.
  90201. */
  90202. getLightByID(id: string): Nullable<Light>;
  90203. /**
  90204. * Gets a light node using its scene-generated unique ID
  90205. * @param uniqueId defines the light's unique id
  90206. * @return the light or null if none found.
  90207. */
  90208. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  90209. /**
  90210. * Gets a particle system by id
  90211. * @param id defines the particle system id
  90212. * @return the corresponding system or null if none found
  90213. */
  90214. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  90215. /**
  90216. * Gets a geometry using its ID
  90217. * @param id defines the geometry's id
  90218. * @return the geometry or null if none found.
  90219. */
  90220. getGeometryByID(id: string): Nullable<Geometry>;
  90221. private _getGeometryByUniqueID;
  90222. /**
  90223. * Add a new geometry to this scene
  90224. * @param geometry defines the geometry to be added to the scene.
  90225. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90226. * @return a boolean defining if the geometry was added or not
  90227. */
  90228. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90229. /**
  90230. * Removes an existing geometry
  90231. * @param geometry defines the geometry to be removed from the scene
  90232. * @return a boolean defining if the geometry was removed or not
  90233. */
  90234. removeGeometry(geometry: Geometry): boolean;
  90235. /**
  90236. * Gets the list of geometries attached to the scene
  90237. * @returns an array of Geometry
  90238. */
  90239. getGeometries(): Geometry[];
  90240. /**
  90241. * Gets the first added mesh found of a given ID
  90242. * @param id defines the id to search for
  90243. * @return the mesh found or null if not found at all
  90244. */
  90245. getMeshByID(id: string): Nullable<AbstractMesh>;
  90246. /**
  90247. * Gets a list of meshes using their id
  90248. * @param id defines the id to search for
  90249. * @returns a list of meshes
  90250. */
  90251. getMeshesByID(id: string): Array<AbstractMesh>;
  90252. /**
  90253. * Gets the first added transform node found of a given ID
  90254. * @param id defines the id to search for
  90255. * @return the found transform node or null if not found at all.
  90256. */
  90257. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90258. /**
  90259. * Gets a list of transform nodes using their id
  90260. * @param id defines the id to search for
  90261. * @returns a list of transform nodes
  90262. */
  90263. getTransformNodesByID(id: string): Array<TransformNode>;
  90264. /**
  90265. * Gets a mesh with its auto-generated unique id
  90266. * @param uniqueId defines the unique id to search for
  90267. * @return the found mesh or null if not found at all.
  90268. */
  90269. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90270. /**
  90271. * Gets a the last added mesh using a given id
  90272. * @param id defines the id to search for
  90273. * @return the found mesh or null if not found at all.
  90274. */
  90275. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90276. /**
  90277. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90278. * @param id defines the id to search for
  90279. * @return the found node or null if not found at all
  90280. */
  90281. getLastEntryByID(id: string): Nullable<Node>;
  90282. /**
  90283. * Gets a node (Mesh, Camera, Light) using a given id
  90284. * @param id defines the id to search for
  90285. * @return the found node or null if not found at all
  90286. */
  90287. getNodeByID(id: string): Nullable<Node>;
  90288. /**
  90289. * Gets a node (Mesh, Camera, Light) using a given name
  90290. * @param name defines the name to search for
  90291. * @return the found node or null if not found at all.
  90292. */
  90293. getNodeByName(name: string): Nullable<Node>;
  90294. /**
  90295. * Gets a mesh using a given name
  90296. * @param name defines the name to search for
  90297. * @return the found mesh or null if not found at all.
  90298. */
  90299. getMeshByName(name: string): Nullable<AbstractMesh>;
  90300. /**
  90301. * Gets a transform node using a given name
  90302. * @param name defines the name to search for
  90303. * @return the found transform node or null if not found at all.
  90304. */
  90305. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90306. /**
  90307. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90308. * @param id defines the id to search for
  90309. * @return the found skeleton or null if not found at all.
  90310. */
  90311. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90312. /**
  90313. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90314. * @param id defines the id to search for
  90315. * @return the found skeleton or null if not found at all.
  90316. */
  90317. getSkeletonById(id: string): Nullable<Skeleton>;
  90318. /**
  90319. * Gets a skeleton using a given name
  90320. * @param name defines the name to search for
  90321. * @return the found skeleton or null if not found at all.
  90322. */
  90323. getSkeletonByName(name: string): Nullable<Skeleton>;
  90324. /**
  90325. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90326. * @param id defines the id to search for
  90327. * @return the found morph target manager or null if not found at all.
  90328. */
  90329. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90330. /**
  90331. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90332. * @param id defines the id to search for
  90333. * @return the found morph target or null if not found at all.
  90334. */
  90335. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90336. /**
  90337. * Gets a boolean indicating if the given mesh is active
  90338. * @param mesh defines the mesh to look for
  90339. * @returns true if the mesh is in the active list
  90340. */
  90341. isActiveMesh(mesh: AbstractMesh): boolean;
  90342. /**
  90343. * Return a unique id as a string which can serve as an identifier for the scene
  90344. */
  90345. readonly uid: string;
  90346. /**
  90347. * Add an externaly attached data from its key.
  90348. * This method call will fail and return false, if such key already exists.
  90349. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90350. * @param key the unique key that identifies the data
  90351. * @param data the data object to associate to the key for this Engine instance
  90352. * @return true if no such key were already present and the data was added successfully, false otherwise
  90353. */
  90354. addExternalData<T>(key: string, data: T): boolean;
  90355. /**
  90356. * Get an externaly attached data from its key
  90357. * @param key the unique key that identifies the data
  90358. * @return the associated data, if present (can be null), or undefined if not present
  90359. */
  90360. getExternalData<T>(key: string): Nullable<T>;
  90361. /**
  90362. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90363. * @param key the unique key that identifies the data
  90364. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90365. * @return the associated data, can be null if the factory returned null.
  90366. */
  90367. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90368. /**
  90369. * Remove an externaly attached data from the Engine instance
  90370. * @param key the unique key that identifies the data
  90371. * @return true if the data was successfully removed, false if it doesn't exist
  90372. */
  90373. removeExternalData(key: string): boolean;
  90374. private _evaluateSubMesh;
  90375. /**
  90376. * Clear the processed materials smart array preventing retention point in material dispose.
  90377. */
  90378. freeProcessedMaterials(): void;
  90379. private _preventFreeActiveMeshesAndRenderingGroups;
  90380. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90381. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90382. * when disposing several meshes in a row or a hierarchy of meshes.
  90383. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90384. */
  90385. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90386. /**
  90387. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90388. */
  90389. freeActiveMeshes(): void;
  90390. /**
  90391. * Clear the info related to rendering groups preventing retention points during dispose.
  90392. */
  90393. freeRenderingGroups(): void;
  90394. /** @hidden */
  90395. _isInIntermediateRendering(): boolean;
  90396. /**
  90397. * Lambda returning the list of potentially active meshes.
  90398. */
  90399. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90400. /**
  90401. * Lambda returning the list of potentially active sub meshes.
  90402. */
  90403. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90404. /**
  90405. * Lambda returning the list of potentially intersecting sub meshes.
  90406. */
  90407. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90408. /**
  90409. * Lambda returning the list of potentially colliding sub meshes.
  90410. */
  90411. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90412. private _activeMeshesFrozen;
  90413. /**
  90414. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90415. * @returns the current scene
  90416. */
  90417. freezeActiveMeshes(): Scene;
  90418. /**
  90419. * Use this function to restart evaluating active meshes on every frame
  90420. * @returns the current scene
  90421. */
  90422. unfreezeActiveMeshes(): Scene;
  90423. private _evaluateActiveMeshes;
  90424. private _activeMesh;
  90425. /**
  90426. * Update the transform matrix to update from the current active camera
  90427. * @param force defines a boolean used to force the update even if cache is up to date
  90428. */
  90429. updateTransformMatrix(force?: boolean): void;
  90430. /**
  90431. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  90432. * @param alternateCamera defines the camera to use
  90433. */
  90434. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90435. /** @hidden */
  90436. _allowPostProcessClearColor: boolean;
  90437. private _renderForCamera;
  90438. private _processSubCameras;
  90439. private _checkIntersections;
  90440. /** @hidden */
  90441. _advancePhysicsEngineStep(step: number): void;
  90442. /**
  90443. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90444. */
  90445. getDeterministicFrameTime: () => number;
  90446. /** @hidden */
  90447. _animate(): void;
  90448. /**
  90449. * Render the scene
  90450. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90451. */
  90452. render(updateCameras?: boolean): void;
  90453. /**
  90454. * Freeze all materials
  90455. * A frozen material will not be updatable but should be faster to render
  90456. */
  90457. freezeMaterials(): void;
  90458. /**
  90459. * Unfreeze all materials
  90460. * A frozen material will not be updatable but should be faster to render
  90461. */
  90462. unfreezeMaterials(): void;
  90463. /**
  90464. * Releases all held ressources
  90465. */
  90466. dispose(): void;
  90467. /**
  90468. * Gets if the scene is already disposed
  90469. */
  90470. readonly isDisposed: boolean;
  90471. /**
  90472. * Call this function to reduce memory footprint of the scene.
  90473. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90474. */
  90475. clearCachedVertexData(): void;
  90476. /**
  90477. * This function will remove the local cached buffer data from texture.
  90478. * It will save memory but will prevent the texture from being rebuilt
  90479. */
  90480. cleanCachedTextureBuffer(): void;
  90481. /**
  90482. * Get the world extend vectors with an optional filter
  90483. *
  90484. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90485. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90486. */
  90487. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90488. min: Vector3;
  90489. max: Vector3;
  90490. };
  90491. /**
  90492. * Creates a ray that can be used to pick in the scene
  90493. * @param x defines the x coordinate of the origin (on-screen)
  90494. * @param y defines the y coordinate of the origin (on-screen)
  90495. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90496. * @param camera defines the camera to use for the picking
  90497. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90498. * @returns a Ray
  90499. */
  90500. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90501. /**
  90502. * Creates a ray that can be used to pick in the scene
  90503. * @param x defines the x coordinate of the origin (on-screen)
  90504. * @param y defines the y coordinate of the origin (on-screen)
  90505. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90506. * @param result defines the ray where to store the picking ray
  90507. * @param camera defines the camera to use for the picking
  90508. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90509. * @returns the current scene
  90510. */
  90511. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90512. /**
  90513. * Creates a ray that can be used to pick in the scene
  90514. * @param x defines the x coordinate of the origin (on-screen)
  90515. * @param y defines the y coordinate of the origin (on-screen)
  90516. * @param camera defines the camera to use for the picking
  90517. * @returns a Ray
  90518. */
  90519. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90520. /**
  90521. * Creates a ray that can be used to pick in the scene
  90522. * @param x defines the x coordinate of the origin (on-screen)
  90523. * @param y defines the y coordinate of the origin (on-screen)
  90524. * @param result defines the ray where to store the picking ray
  90525. * @param camera defines the camera to use for the picking
  90526. * @returns the current scene
  90527. */
  90528. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90529. /** Launch a ray to try to pick a mesh in the scene
  90530. * @param x position on screen
  90531. * @param y position on screen
  90532. * @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
  90533. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90534. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90535. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90536. * @returns a PickingInfo
  90537. */
  90538. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90539. /** Use the given ray to pick a mesh in the scene
  90540. * @param ray The ray to use to pick meshes
  90541. * @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
  90542. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90543. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90544. * @returns a PickingInfo
  90545. */
  90546. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90547. /**
  90548. * Launch a ray to try to pick a mesh in the scene
  90549. * @param x X position on screen
  90550. * @param y Y position on screen
  90551. * @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
  90552. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90553. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90554. * @returns an array of PickingInfo
  90555. */
  90556. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90557. /**
  90558. * Launch a ray to try to pick a mesh in the scene
  90559. * @param ray Ray to use
  90560. * @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
  90561. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90562. * @returns an array of PickingInfo
  90563. */
  90564. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90565. /**
  90566. * Force the value of meshUnderPointer
  90567. * @param mesh defines the mesh to use
  90568. */
  90569. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90570. /**
  90571. * Gets the mesh under the pointer
  90572. * @returns a Mesh or null if no mesh is under the pointer
  90573. */
  90574. getPointerOverMesh(): Nullable<AbstractMesh>;
  90575. /** @hidden */
  90576. _rebuildGeometries(): void;
  90577. /** @hidden */
  90578. _rebuildTextures(): void;
  90579. private _getByTags;
  90580. /**
  90581. * Get a list of meshes by tags
  90582. * @param tagsQuery defines the tags query to use
  90583. * @param forEach defines a predicate used to filter results
  90584. * @returns an array of Mesh
  90585. */
  90586. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90587. /**
  90588. * Get a list of cameras by tags
  90589. * @param tagsQuery defines the tags query to use
  90590. * @param forEach defines a predicate used to filter results
  90591. * @returns an array of Camera
  90592. */
  90593. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90594. /**
  90595. * Get a list of lights by tags
  90596. * @param tagsQuery defines the tags query to use
  90597. * @param forEach defines a predicate used to filter results
  90598. * @returns an array of Light
  90599. */
  90600. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90601. /**
  90602. * Get a list of materials by tags
  90603. * @param tagsQuery defines the tags query to use
  90604. * @param forEach defines a predicate used to filter results
  90605. * @returns an array of Material
  90606. */
  90607. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90608. /**
  90609. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90610. * This allowed control for front to back rendering or reversly depending of the special needs.
  90611. *
  90612. * @param renderingGroupId The rendering group id corresponding to its index
  90613. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90614. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90615. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90616. */
  90617. 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;
  90618. /**
  90619. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90620. *
  90621. * @param renderingGroupId The rendering group id corresponding to its index
  90622. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90623. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90624. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90625. */
  90626. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90627. /**
  90628. * Gets the current auto clear configuration for one rendering group of the rendering
  90629. * manager.
  90630. * @param index the rendering group index to get the information for
  90631. * @returns The auto clear setup for the requested rendering group
  90632. */
  90633. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90634. private _blockMaterialDirtyMechanism;
  90635. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90636. blockMaterialDirtyMechanism: boolean;
  90637. /**
  90638. * Will flag all materials as dirty to trigger new shader compilation
  90639. * @param flag defines the flag used to specify which material part must be marked as dirty
  90640. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90641. */
  90642. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90643. /** @hidden */
  90644. _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;
  90645. /** @hidden */
  90646. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90647. }
  90648. }
  90649. declare module BABYLON {
  90650. /**
  90651. * Set of assets to keep when moving a scene into an asset container.
  90652. */
  90653. export class KeepAssets extends AbstractScene {
  90654. }
  90655. /**
  90656. * Container with a set of assets that can be added or removed from a scene.
  90657. */
  90658. export class AssetContainer extends AbstractScene {
  90659. /**
  90660. * The scene the AssetContainer belongs to.
  90661. */
  90662. scene: Scene;
  90663. /**
  90664. * Instantiates an AssetContainer.
  90665. * @param scene The scene the AssetContainer belongs to.
  90666. */
  90667. constructor(scene: Scene);
  90668. /**
  90669. * Adds all the assets from the container to the scene.
  90670. */
  90671. addAllToScene(): void;
  90672. /**
  90673. * Removes all the assets in the container from the scene
  90674. */
  90675. removeAllFromScene(): void;
  90676. /**
  90677. * Disposes all the assets in the container
  90678. */
  90679. dispose(): void;
  90680. private _moveAssets;
  90681. /**
  90682. * Removes all the assets contained in the scene and adds them to the container.
  90683. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90684. */
  90685. moveAllFromScene(keepAssets?: KeepAssets): void;
  90686. /**
  90687. * 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.
  90688. * @returns the root mesh
  90689. */
  90690. createRootMesh(): Mesh;
  90691. }
  90692. }
  90693. declare module BABYLON {
  90694. /**
  90695. * Defines how the parser contract is defined.
  90696. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90697. */
  90698. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90699. /**
  90700. * Defines how the individual parser contract is defined.
  90701. * These parser can parse an individual asset
  90702. */
  90703. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90704. /**
  90705. * Base class of the scene acting as a container for the different elements composing a scene.
  90706. * This class is dynamically extended by the different components of the scene increasing
  90707. * flexibility and reducing coupling
  90708. */
  90709. export abstract class AbstractScene {
  90710. /**
  90711. * Stores the list of available parsers in the application.
  90712. */
  90713. private static _BabylonFileParsers;
  90714. /**
  90715. * Stores the list of available individual parsers in the application.
  90716. */
  90717. private static _IndividualBabylonFileParsers;
  90718. /**
  90719. * Adds a parser in the list of available ones
  90720. * @param name Defines the name of the parser
  90721. * @param parser Defines the parser to add
  90722. */
  90723. static AddParser(name: string, parser: BabylonFileParser): void;
  90724. /**
  90725. * Gets a general parser from the list of avaialble ones
  90726. * @param name Defines the name of the parser
  90727. * @returns the requested parser or null
  90728. */
  90729. static GetParser(name: string): Nullable<BabylonFileParser>;
  90730. /**
  90731. * Adds n individual parser in the list of available ones
  90732. * @param name Defines the name of the parser
  90733. * @param parser Defines the parser to add
  90734. */
  90735. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90736. /**
  90737. * Gets an individual parser from the list of avaialble ones
  90738. * @param name Defines the name of the parser
  90739. * @returns the requested parser or null
  90740. */
  90741. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90742. /**
  90743. * Parser json data and populate both a scene and its associated container object
  90744. * @param jsonData Defines the data to parse
  90745. * @param scene Defines the scene to parse the data for
  90746. * @param container Defines the container attached to the parsing sequence
  90747. * @param rootUrl Defines the root url of the data
  90748. */
  90749. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90750. /**
  90751. * Gets the list of root nodes (ie. nodes with no parent)
  90752. */
  90753. rootNodes: Node[];
  90754. /** All of the cameras added to this scene
  90755. * @see http://doc.babylonjs.com/babylon101/cameras
  90756. */
  90757. cameras: Camera[];
  90758. /**
  90759. * All of the lights added to this scene
  90760. * @see http://doc.babylonjs.com/babylon101/lights
  90761. */
  90762. lights: Light[];
  90763. /**
  90764. * All of the (abstract) meshes added to this scene
  90765. */
  90766. meshes: AbstractMesh[];
  90767. /**
  90768. * The list of skeletons added to the scene
  90769. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90770. */
  90771. skeletons: Skeleton[];
  90772. /**
  90773. * All of the particle systems added to this scene
  90774. * @see http://doc.babylonjs.com/babylon101/particles
  90775. */
  90776. particleSystems: IParticleSystem[];
  90777. /**
  90778. * Gets a list of Animations associated with the scene
  90779. */
  90780. animations: Animation[];
  90781. /**
  90782. * All of the animation groups added to this scene
  90783. * @see http://doc.babylonjs.com/how_to/group
  90784. */
  90785. animationGroups: AnimationGroup[];
  90786. /**
  90787. * All of the multi-materials added to this scene
  90788. * @see http://doc.babylonjs.com/how_to/multi_materials
  90789. */
  90790. multiMaterials: MultiMaterial[];
  90791. /**
  90792. * All of the materials added to this scene
  90793. * In the context of a Scene, it is not supposed to be modified manually.
  90794. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90795. * Note also that the order of the Material wihin the array is not significant and might change.
  90796. * @see http://doc.babylonjs.com/babylon101/materials
  90797. */
  90798. materials: Material[];
  90799. /**
  90800. * The list of morph target managers added to the scene
  90801. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90802. */
  90803. morphTargetManagers: MorphTargetManager[];
  90804. /**
  90805. * The list of geometries used in the scene.
  90806. */
  90807. geometries: Geometry[];
  90808. /**
  90809. * All of the tranform nodes added to this scene
  90810. * In the context of a Scene, it is not supposed to be modified manually.
  90811. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90812. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90813. * @see http://doc.babylonjs.com/how_to/transformnode
  90814. */
  90815. transformNodes: TransformNode[];
  90816. /**
  90817. * ActionManagers available on the scene.
  90818. */
  90819. actionManagers: AbstractActionManager[];
  90820. /**
  90821. * Textures to keep.
  90822. */
  90823. textures: BaseTexture[];
  90824. }
  90825. }
  90826. declare module BABYLON {
  90827. /**
  90828. * Defines a sound that can be played in the application.
  90829. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90831. */
  90832. export class Sound {
  90833. /**
  90834. * The name of the sound in the scene.
  90835. */
  90836. name: string;
  90837. /**
  90838. * Does the sound autoplay once loaded.
  90839. */
  90840. autoplay: boolean;
  90841. /**
  90842. * Does the sound loop after it finishes playing once.
  90843. */
  90844. loop: boolean;
  90845. /**
  90846. * Does the sound use a custom attenuation curve to simulate the falloff
  90847. * happening when the source gets further away from the camera.
  90848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90849. */
  90850. useCustomAttenuation: boolean;
  90851. /**
  90852. * The sound track id this sound belongs to.
  90853. */
  90854. soundTrackId: number;
  90855. /**
  90856. * Is this sound currently played.
  90857. */
  90858. isPlaying: boolean;
  90859. /**
  90860. * Is this sound currently paused.
  90861. */
  90862. isPaused: boolean;
  90863. /**
  90864. * Does this sound enables spatial sound.
  90865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90866. */
  90867. spatialSound: boolean;
  90868. /**
  90869. * Define the reference distance the sound should be heard perfectly.
  90870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90871. */
  90872. refDistance: number;
  90873. /**
  90874. * Define the roll off factor of spatial sounds.
  90875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90876. */
  90877. rolloffFactor: number;
  90878. /**
  90879. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90881. */
  90882. maxDistance: number;
  90883. /**
  90884. * Define the distance attenuation model the sound will follow.
  90885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90886. */
  90887. distanceModel: string;
  90888. /**
  90889. * @hidden
  90890. * Back Compat
  90891. **/
  90892. onended: () => any;
  90893. /**
  90894. * Observable event when the current playing sound finishes.
  90895. */
  90896. onEndedObservable: Observable<Sound>;
  90897. private _panningModel;
  90898. private _playbackRate;
  90899. private _streaming;
  90900. private _startTime;
  90901. private _startOffset;
  90902. private _position;
  90903. /** @hidden */
  90904. _positionInEmitterSpace: boolean;
  90905. private _localDirection;
  90906. private _volume;
  90907. private _isReadyToPlay;
  90908. private _isDirectional;
  90909. private _readyToPlayCallback;
  90910. private _audioBuffer;
  90911. private _soundSource;
  90912. private _streamingSource;
  90913. private _soundPanner;
  90914. private _soundGain;
  90915. private _inputAudioNode;
  90916. private _outputAudioNode;
  90917. private _coneInnerAngle;
  90918. private _coneOuterAngle;
  90919. private _coneOuterGain;
  90920. private _scene;
  90921. private _connectedTransformNode;
  90922. private _customAttenuationFunction;
  90923. private _registerFunc;
  90924. private _isOutputConnected;
  90925. private _htmlAudioElement;
  90926. private _urlType;
  90927. /** @hidden */
  90928. static _SceneComponentInitialization: (scene: Scene) => void;
  90929. /**
  90930. * Create a sound and attach it to a scene
  90931. * @param name Name of your sound
  90932. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90933. * @param scene defines the scene the sound belongs to
  90934. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90935. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90936. */
  90937. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90938. /**
  90939. * Release the sound and its associated resources
  90940. */
  90941. dispose(): void;
  90942. /**
  90943. * Gets if the sounds is ready to be played or not.
  90944. * @returns true if ready, otherwise false
  90945. */
  90946. isReady(): boolean;
  90947. private _soundLoaded;
  90948. /**
  90949. * Sets the data of the sound from an audiobuffer
  90950. * @param audioBuffer The audioBuffer containing the data
  90951. */
  90952. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90953. /**
  90954. * Updates the current sounds options such as maxdistance, loop...
  90955. * @param options A JSON object containing values named as the object properties
  90956. */
  90957. updateOptions(options: any): void;
  90958. private _createSpatialParameters;
  90959. private _updateSpatialParameters;
  90960. /**
  90961. * Switch the panning model to HRTF:
  90962. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90964. */
  90965. switchPanningModelToHRTF(): void;
  90966. /**
  90967. * Switch the panning model to Equal Power:
  90968. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90970. */
  90971. switchPanningModelToEqualPower(): void;
  90972. private _switchPanningModel;
  90973. /**
  90974. * Connect this sound to a sound track audio node like gain...
  90975. * @param soundTrackAudioNode the sound track audio node to connect to
  90976. */
  90977. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90978. /**
  90979. * Transform this sound into a directional source
  90980. * @param coneInnerAngle Size of the inner cone in degree
  90981. * @param coneOuterAngle Size of the outer cone in degree
  90982. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90983. */
  90984. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90985. /**
  90986. * Gets or sets the inner angle for the directional cone.
  90987. */
  90988. /**
  90989. * Gets or sets the inner angle for the directional cone.
  90990. */
  90991. directionalConeInnerAngle: number;
  90992. /**
  90993. * Gets or sets the outer angle for the directional cone.
  90994. */
  90995. /**
  90996. * Gets or sets the outer angle for the directional cone.
  90997. */
  90998. directionalConeOuterAngle: number;
  90999. /**
  91000. * Sets the position of the emitter if spatial sound is enabled
  91001. * @param newPosition Defines the new posisiton
  91002. */
  91003. setPosition(newPosition: Vector3): void;
  91004. /**
  91005. * Sets the local direction of the emitter if spatial sound is enabled
  91006. * @param newLocalDirection Defines the new local direction
  91007. */
  91008. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  91009. private _updateDirection;
  91010. /** @hidden */
  91011. updateDistanceFromListener(): void;
  91012. /**
  91013. * Sets a new custom attenuation function for the sound.
  91014. * @param callback Defines the function used for the attenuation
  91015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91016. */
  91017. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  91018. /**
  91019. * Play the sound
  91020. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  91021. * @param offset (optional) Start the sound setting it at a specific time
  91022. */
  91023. play(time?: number, offset?: number): void;
  91024. private _onended;
  91025. /**
  91026. * Stop the sound
  91027. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  91028. */
  91029. stop(time?: number): void;
  91030. /**
  91031. * Put the sound in pause
  91032. */
  91033. pause(): void;
  91034. /**
  91035. * Sets a dedicated volume for this sounds
  91036. * @param newVolume Define the new volume of the sound
  91037. * @param time Define in how long the sound should be at this value
  91038. */
  91039. setVolume(newVolume: number, time?: number): void;
  91040. /**
  91041. * Set the sound play back rate
  91042. * @param newPlaybackRate Define the playback rate the sound should be played at
  91043. */
  91044. setPlaybackRate(newPlaybackRate: number): void;
  91045. /**
  91046. * Gets the volume of the sound.
  91047. * @returns the volume of the sound
  91048. */
  91049. getVolume(): number;
  91050. /**
  91051. * Attach the sound to a dedicated mesh
  91052. * @param transformNode The transform node to connect the sound with
  91053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91054. */
  91055. attachToMesh(transformNode: TransformNode): void;
  91056. /**
  91057. * Detach the sound from the previously attached mesh
  91058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91059. */
  91060. detachFromMesh(): void;
  91061. private _onRegisterAfterWorldMatrixUpdate;
  91062. /**
  91063. * Clone the current sound in the scene.
  91064. * @returns the new sound clone
  91065. */
  91066. clone(): Nullable<Sound>;
  91067. /**
  91068. * Gets the current underlying audio buffer containing the data
  91069. * @returns the audio buffer
  91070. */
  91071. getAudioBuffer(): Nullable<AudioBuffer>;
  91072. /**
  91073. * Serializes the Sound in a JSON representation
  91074. * @returns the JSON representation of the sound
  91075. */
  91076. serialize(): any;
  91077. /**
  91078. * Parse a JSON representation of a sound to innstantiate in a given scene
  91079. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  91080. * @param scene Define the scene the new parsed sound should be created in
  91081. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  91082. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  91083. * @returns the newly parsed sound
  91084. */
  91085. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  91086. }
  91087. }
  91088. declare module BABYLON {
  91089. /**
  91090. * This defines an action helpful to play a defined sound on a triggered action.
  91091. */
  91092. export class PlaySoundAction extends Action {
  91093. private _sound;
  91094. /**
  91095. * Instantiate the action
  91096. * @param triggerOptions defines the trigger options
  91097. * @param sound defines the sound to play
  91098. * @param condition defines the trigger related conditions
  91099. */
  91100. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91101. /** @hidden */
  91102. _prepare(): void;
  91103. /**
  91104. * Execute the action and play the sound.
  91105. */
  91106. execute(): void;
  91107. /**
  91108. * Serializes the actions and its related information.
  91109. * @param parent defines the object to serialize in
  91110. * @returns the serialized object
  91111. */
  91112. serialize(parent: any): any;
  91113. }
  91114. /**
  91115. * This defines an action helpful to stop a defined sound on a triggered action.
  91116. */
  91117. export class StopSoundAction extends Action {
  91118. private _sound;
  91119. /**
  91120. * Instantiate the action
  91121. * @param triggerOptions defines the trigger options
  91122. * @param sound defines the sound to stop
  91123. * @param condition defines the trigger related conditions
  91124. */
  91125. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91126. /** @hidden */
  91127. _prepare(): void;
  91128. /**
  91129. * Execute the action and stop the sound.
  91130. */
  91131. execute(): void;
  91132. /**
  91133. * Serializes the actions and its related information.
  91134. * @param parent defines the object to serialize in
  91135. * @returns the serialized object
  91136. */
  91137. serialize(parent: any): any;
  91138. }
  91139. }
  91140. declare module BABYLON {
  91141. /**
  91142. * This defines an action responsible to change the value of a property
  91143. * by interpolating between its current value and the newly set one once triggered.
  91144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91145. */
  91146. export class InterpolateValueAction extends Action {
  91147. /**
  91148. * Defines the path of the property where the value should be interpolated
  91149. */
  91150. propertyPath: string;
  91151. /**
  91152. * Defines the target value at the end of the interpolation.
  91153. */
  91154. value: any;
  91155. /**
  91156. * Defines the time it will take for the property to interpolate to the value.
  91157. */
  91158. duration: number;
  91159. /**
  91160. * Defines if the other scene animations should be stopped when the action has been triggered
  91161. */
  91162. stopOtherAnimations?: boolean;
  91163. /**
  91164. * Defines a callback raised once the interpolation animation has been done.
  91165. */
  91166. onInterpolationDone?: () => void;
  91167. /**
  91168. * Observable triggered once the interpolation animation has been done.
  91169. */
  91170. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  91171. private _target;
  91172. private _effectiveTarget;
  91173. private _property;
  91174. /**
  91175. * Instantiate the action
  91176. * @param triggerOptions defines the trigger options
  91177. * @param target defines the object containing the value to interpolate
  91178. * @param propertyPath defines the path to the property in the target object
  91179. * @param value defines the target value at the end of the interpolation
  91180. * @param duration deines the time it will take for the property to interpolate to the value.
  91181. * @param condition defines the trigger related conditions
  91182. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  91183. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  91184. */
  91185. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  91186. /** @hidden */
  91187. _prepare(): void;
  91188. /**
  91189. * Execute the action starts the value interpolation.
  91190. */
  91191. execute(): void;
  91192. /**
  91193. * Serializes the actions and its related information.
  91194. * @param parent defines the object to serialize in
  91195. * @returns the serialized object
  91196. */
  91197. serialize(parent: any): any;
  91198. }
  91199. }
  91200. declare module BABYLON {
  91201. /**
  91202. * Options allowed during the creation of a sound track.
  91203. */
  91204. export interface ISoundTrackOptions {
  91205. /**
  91206. * The volume the sound track should take during creation
  91207. */
  91208. volume?: number;
  91209. /**
  91210. * Define if the sound track is the main sound track of the scene
  91211. */
  91212. mainTrack?: boolean;
  91213. }
  91214. /**
  91215. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  91216. * It will be also used in a future release to apply effects on a specific track.
  91217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91218. */
  91219. export class SoundTrack {
  91220. /**
  91221. * The unique identifier of the sound track in the scene.
  91222. */
  91223. id: number;
  91224. /**
  91225. * The list of sounds included in the sound track.
  91226. */
  91227. soundCollection: Array<Sound>;
  91228. private _outputAudioNode;
  91229. private _scene;
  91230. private _isMainTrack;
  91231. private _connectedAnalyser;
  91232. private _options;
  91233. private _isInitialized;
  91234. /**
  91235. * Creates a new sound track.
  91236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91237. * @param scene Define the scene the sound track belongs to
  91238. * @param options
  91239. */
  91240. constructor(scene: Scene, options?: ISoundTrackOptions);
  91241. private _initializeSoundTrackAudioGraph;
  91242. /**
  91243. * Release the sound track and its associated resources
  91244. */
  91245. dispose(): void;
  91246. /**
  91247. * Adds a sound to this sound track
  91248. * @param sound define the cound to add
  91249. * @ignoreNaming
  91250. */
  91251. AddSound(sound: Sound): void;
  91252. /**
  91253. * Removes a sound to this sound track
  91254. * @param sound define the cound to remove
  91255. * @ignoreNaming
  91256. */
  91257. RemoveSound(sound: Sound): void;
  91258. /**
  91259. * Set a global volume for the full sound track.
  91260. * @param newVolume Define the new volume of the sound track
  91261. */
  91262. setVolume(newVolume: number): void;
  91263. /**
  91264. * Switch the panning model to HRTF:
  91265. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91267. */
  91268. switchPanningModelToHRTF(): void;
  91269. /**
  91270. * Switch the panning model to Equal Power:
  91271. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91273. */
  91274. switchPanningModelToEqualPower(): void;
  91275. /**
  91276. * Connect the sound track to an audio analyser allowing some amazing
  91277. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91279. * @param analyser The analyser to connect to the engine
  91280. */
  91281. connectToAnalyser(analyser: Analyser): void;
  91282. }
  91283. }
  91284. declare module BABYLON {
  91285. interface AbstractScene {
  91286. /**
  91287. * The list of sounds used in the scene.
  91288. */
  91289. sounds: Nullable<Array<Sound>>;
  91290. }
  91291. interface Scene {
  91292. /**
  91293. * @hidden
  91294. * Backing field
  91295. */
  91296. _mainSoundTrack: SoundTrack;
  91297. /**
  91298. * The main sound track played by the scene.
  91299. * It cotains your primary collection of sounds.
  91300. */
  91301. mainSoundTrack: SoundTrack;
  91302. /**
  91303. * The list of sound tracks added to the scene
  91304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91305. */
  91306. soundTracks: Nullable<Array<SoundTrack>>;
  91307. /**
  91308. * Gets a sound using a given name
  91309. * @param name defines the name to search for
  91310. * @return the found sound or null if not found at all.
  91311. */
  91312. getSoundByName(name: string): Nullable<Sound>;
  91313. /**
  91314. * Gets or sets if audio support is enabled
  91315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91316. */
  91317. audioEnabled: boolean;
  91318. /**
  91319. * Gets or sets if audio will be output to headphones
  91320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91321. */
  91322. headphone: boolean;
  91323. }
  91324. /**
  91325. * Defines the sound scene component responsible to manage any sounds
  91326. * in a given scene.
  91327. */
  91328. export class AudioSceneComponent implements ISceneSerializableComponent {
  91329. /**
  91330. * The component name helpfull to identify the component in the list of scene components.
  91331. */
  91332. readonly name: string;
  91333. /**
  91334. * The scene the component belongs to.
  91335. */
  91336. scene: Scene;
  91337. private _audioEnabled;
  91338. /**
  91339. * Gets whether audio is enabled or not.
  91340. * Please use related enable/disable method to switch state.
  91341. */
  91342. readonly audioEnabled: boolean;
  91343. private _headphone;
  91344. /**
  91345. * Gets whether audio is outputing to headphone or not.
  91346. * Please use the according Switch methods to change output.
  91347. */
  91348. readonly headphone: boolean;
  91349. /**
  91350. * Creates a new instance of the component for the given scene
  91351. * @param scene Defines the scene to register the component in
  91352. */
  91353. constructor(scene: Scene);
  91354. /**
  91355. * Registers the component in a given scene
  91356. */
  91357. register(): void;
  91358. /**
  91359. * Rebuilds the elements related to this component in case of
  91360. * context lost for instance.
  91361. */
  91362. rebuild(): void;
  91363. /**
  91364. * Serializes the component data to the specified json object
  91365. * @param serializationObject The object to serialize to
  91366. */
  91367. serialize(serializationObject: any): void;
  91368. /**
  91369. * Adds all the element from the container to the scene
  91370. * @param container the container holding the elements
  91371. */
  91372. addFromContainer(container: AbstractScene): void;
  91373. /**
  91374. * Removes all the elements in the container from the scene
  91375. * @param container contains the elements to remove
  91376. */
  91377. removeFromContainer(container: AbstractScene): void;
  91378. /**
  91379. * Disposes the component and the associated ressources.
  91380. */
  91381. dispose(): void;
  91382. /**
  91383. * Disables audio in the associated scene.
  91384. */
  91385. disableAudio(): void;
  91386. /**
  91387. * Enables audio in the associated scene.
  91388. */
  91389. enableAudio(): void;
  91390. /**
  91391. * Switch audio to headphone output.
  91392. */
  91393. switchAudioModeForHeadphones(): void;
  91394. /**
  91395. * Switch audio to normal speakers.
  91396. */
  91397. switchAudioModeForNormalSpeakers(): void;
  91398. private _afterRender;
  91399. }
  91400. }
  91401. declare module BABYLON {
  91402. /**
  91403. * Wraps one or more Sound objects and selects one with random weight for playback.
  91404. */
  91405. export class WeightedSound {
  91406. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91407. loop: boolean;
  91408. private _coneInnerAngle;
  91409. private _coneOuterAngle;
  91410. private _volume;
  91411. /** A Sound is currently playing. */
  91412. isPlaying: boolean;
  91413. /** A Sound is currently paused. */
  91414. isPaused: boolean;
  91415. private _sounds;
  91416. private _weights;
  91417. private _currentIndex?;
  91418. /**
  91419. * Creates a new WeightedSound from the list of sounds given.
  91420. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91421. * @param sounds Array of Sounds that will be selected from.
  91422. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91423. */
  91424. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91425. /**
  91426. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91427. */
  91428. /**
  91429. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91430. */
  91431. directionalConeInnerAngle: number;
  91432. /**
  91433. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91434. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91435. */
  91436. /**
  91437. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91438. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91439. */
  91440. directionalConeOuterAngle: number;
  91441. /**
  91442. * Playback volume.
  91443. */
  91444. /**
  91445. * Playback volume.
  91446. */
  91447. volume: number;
  91448. private _onended;
  91449. /**
  91450. * Suspend playback
  91451. */
  91452. pause(): void;
  91453. /**
  91454. * Stop playback
  91455. */
  91456. stop(): void;
  91457. /**
  91458. * Start playback.
  91459. * @param startOffset Position the clip head at a specific time in seconds.
  91460. */
  91461. play(startOffset?: number): void;
  91462. }
  91463. }
  91464. declare module BABYLON {
  91465. /**
  91466. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91467. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91468. */
  91469. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91470. /**
  91471. * Gets the name of the behavior.
  91472. */
  91473. readonly name: string;
  91474. /**
  91475. * The easing function used by animations
  91476. */
  91477. static EasingFunction: BackEase;
  91478. /**
  91479. * The easing mode used by animations
  91480. */
  91481. static EasingMode: number;
  91482. /**
  91483. * The duration of the animation, in milliseconds
  91484. */
  91485. transitionDuration: number;
  91486. /**
  91487. * Length of the distance animated by the transition when lower radius is reached
  91488. */
  91489. lowerRadiusTransitionRange: number;
  91490. /**
  91491. * Length of the distance animated by the transition when upper radius is reached
  91492. */
  91493. upperRadiusTransitionRange: number;
  91494. private _autoTransitionRange;
  91495. /**
  91496. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91497. */
  91498. /**
  91499. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91500. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91501. */
  91502. autoTransitionRange: boolean;
  91503. private _attachedCamera;
  91504. private _onAfterCheckInputsObserver;
  91505. private _onMeshTargetChangedObserver;
  91506. /**
  91507. * Initializes the behavior.
  91508. */
  91509. init(): void;
  91510. /**
  91511. * Attaches the behavior to its arc rotate camera.
  91512. * @param camera Defines the camera to attach the behavior to
  91513. */
  91514. attach(camera: ArcRotateCamera): void;
  91515. /**
  91516. * Detaches the behavior from its current arc rotate camera.
  91517. */
  91518. detach(): void;
  91519. private _radiusIsAnimating;
  91520. private _radiusBounceTransition;
  91521. private _animatables;
  91522. private _cachedWheelPrecision;
  91523. /**
  91524. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91525. * @param radiusLimit The limit to check against.
  91526. * @return Bool to indicate if at limit.
  91527. */
  91528. private _isRadiusAtLimit;
  91529. /**
  91530. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91531. * @param radiusDelta The delta by which to animate to. Can be negative.
  91532. */
  91533. private _applyBoundRadiusAnimation;
  91534. /**
  91535. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91536. */
  91537. protected _clearAnimationLocks(): void;
  91538. /**
  91539. * Stops and removes all animations that have been applied to the camera
  91540. */
  91541. stopAllAnimations(): void;
  91542. }
  91543. }
  91544. declare module BABYLON {
  91545. /**
  91546. * 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.
  91547. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91548. */
  91549. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91550. /**
  91551. * Gets the name of the behavior.
  91552. */
  91553. readonly name: string;
  91554. private _mode;
  91555. private _radiusScale;
  91556. private _positionScale;
  91557. private _defaultElevation;
  91558. private _elevationReturnTime;
  91559. private _elevationReturnWaitTime;
  91560. private _zoomStopsAnimation;
  91561. private _framingTime;
  91562. /**
  91563. * The easing function used by animations
  91564. */
  91565. static EasingFunction: ExponentialEase;
  91566. /**
  91567. * The easing mode used by animations
  91568. */
  91569. static EasingMode: number;
  91570. /**
  91571. * Sets the current mode used by the behavior
  91572. */
  91573. /**
  91574. * Gets current mode used by the behavior.
  91575. */
  91576. mode: number;
  91577. /**
  91578. * Sets the scale applied to the radius (1 by default)
  91579. */
  91580. /**
  91581. * Gets the scale applied to the radius
  91582. */
  91583. radiusScale: number;
  91584. /**
  91585. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91586. */
  91587. /**
  91588. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91589. */
  91590. positionScale: number;
  91591. /**
  91592. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91593. * behaviour is triggered, in radians.
  91594. */
  91595. /**
  91596. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91597. * behaviour is triggered, in radians.
  91598. */
  91599. defaultElevation: number;
  91600. /**
  91601. * Sets the time (in milliseconds) taken to return to the default beta position.
  91602. * Negative value indicates camera should not return to default.
  91603. */
  91604. /**
  91605. * Gets the time (in milliseconds) taken to return to the default beta position.
  91606. * Negative value indicates camera should not return to default.
  91607. */
  91608. elevationReturnTime: number;
  91609. /**
  91610. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91611. */
  91612. /**
  91613. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91614. */
  91615. elevationReturnWaitTime: number;
  91616. /**
  91617. * Sets the flag that indicates if user zooming should stop animation.
  91618. */
  91619. /**
  91620. * Gets the flag that indicates if user zooming should stop animation.
  91621. */
  91622. zoomStopsAnimation: boolean;
  91623. /**
  91624. * Sets the transition time when framing the mesh, in milliseconds
  91625. */
  91626. /**
  91627. * Gets the transition time when framing the mesh, in milliseconds
  91628. */
  91629. framingTime: number;
  91630. /**
  91631. * Define if the behavior should automatically change the configured
  91632. * camera limits and sensibilities.
  91633. */
  91634. autoCorrectCameraLimitsAndSensibility: boolean;
  91635. private _onPrePointerObservableObserver;
  91636. private _onAfterCheckInputsObserver;
  91637. private _onMeshTargetChangedObserver;
  91638. private _attachedCamera;
  91639. private _isPointerDown;
  91640. private _lastInteractionTime;
  91641. /**
  91642. * Initializes the behavior.
  91643. */
  91644. init(): void;
  91645. /**
  91646. * Attaches the behavior to its arc rotate camera.
  91647. * @param camera Defines the camera to attach the behavior to
  91648. */
  91649. attach(camera: ArcRotateCamera): void;
  91650. /**
  91651. * Detaches the behavior from its current arc rotate camera.
  91652. */
  91653. detach(): void;
  91654. private _animatables;
  91655. private _betaIsAnimating;
  91656. private _betaTransition;
  91657. private _radiusTransition;
  91658. private _vectorTransition;
  91659. /**
  91660. * Targets the given mesh and updates zoom level accordingly.
  91661. * @param mesh The mesh to target.
  91662. * @param radius Optional. If a cached radius position already exists, overrides default.
  91663. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91664. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91665. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91666. */
  91667. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91668. /**
  91669. * Targets the given mesh with its children and updates zoom level accordingly.
  91670. * @param mesh The mesh to target.
  91671. * @param radius Optional. If a cached radius position already exists, overrides default.
  91672. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91673. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91674. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91675. */
  91676. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91677. /**
  91678. * Targets the given meshes with their children and updates zoom level accordingly.
  91679. * @param meshes The mesh to target.
  91680. * @param radius Optional. If a cached radius position already exists, overrides default.
  91681. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91682. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91683. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91684. */
  91685. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91686. /**
  91687. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91688. * @param minimumWorld Determines the smaller position of the bounding box extend
  91689. * @param maximumWorld Determines the bigger position of the bounding box extend
  91690. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91691. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91692. */
  91693. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91694. /**
  91695. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91696. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91697. * frustum width.
  91698. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91699. * to fully enclose the mesh in the viewing frustum.
  91700. */
  91701. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91702. /**
  91703. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91704. * is automatically returned to its default position (expected to be above ground plane).
  91705. */
  91706. private _maintainCameraAboveGround;
  91707. /**
  91708. * Returns the frustum slope based on the canvas ratio and camera FOV
  91709. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91710. */
  91711. private _getFrustumSlope;
  91712. /**
  91713. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91714. */
  91715. private _clearAnimationLocks;
  91716. /**
  91717. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91718. */
  91719. private _applyUserInteraction;
  91720. /**
  91721. * Stops and removes all animations that have been applied to the camera
  91722. */
  91723. stopAllAnimations(): void;
  91724. /**
  91725. * Gets a value indicating if the user is moving the camera
  91726. */
  91727. readonly isUserIsMoving: boolean;
  91728. /**
  91729. * The camera can move all the way towards the mesh.
  91730. */
  91731. static IgnoreBoundsSizeMode: number;
  91732. /**
  91733. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91734. */
  91735. static FitFrustumSidesMode: number;
  91736. }
  91737. }
  91738. declare module BABYLON {
  91739. /**
  91740. * Base class for Camera Pointer Inputs.
  91741. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91742. * for example usage.
  91743. */
  91744. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91745. /**
  91746. * Defines the camera the input is attached to.
  91747. */
  91748. abstract camera: Camera;
  91749. /**
  91750. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91751. */
  91752. protected _altKey: boolean;
  91753. protected _ctrlKey: boolean;
  91754. protected _metaKey: boolean;
  91755. protected _shiftKey: boolean;
  91756. /**
  91757. * Which mouse buttons were pressed at time of last mouse event.
  91758. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91759. */
  91760. protected _buttonsPressed: number;
  91761. /**
  91762. * Defines the buttons associated with the input to handle camera move.
  91763. */
  91764. buttons: number[];
  91765. /**
  91766. * Attach the input controls to a specific dom element to get the input from.
  91767. * @param element Defines the element the controls should be listened from
  91768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91769. */
  91770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91771. /**
  91772. * Detach the current controls from the specified dom element.
  91773. * @param element Defines the element to stop listening the inputs from
  91774. */
  91775. detachControl(element: Nullable<HTMLElement>): void;
  91776. /**
  91777. * Gets the class name of the current input.
  91778. * @returns the class name
  91779. */
  91780. getClassName(): string;
  91781. /**
  91782. * Get the friendly name associated with the input class.
  91783. * @returns the input friendly name
  91784. */
  91785. getSimpleName(): string;
  91786. /**
  91787. * Called on pointer POINTERDOUBLETAP event.
  91788. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91789. */
  91790. protected onDoubleTap(type: string): void;
  91791. /**
  91792. * Called on pointer POINTERMOVE event if only a single touch is active.
  91793. * Override this method to provide functionality.
  91794. */
  91795. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91796. /**
  91797. * Called on pointer POINTERMOVE event if multiple touches are active.
  91798. * Override this method to provide functionality.
  91799. */
  91800. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91801. /**
  91802. * Called on JS contextmenu event.
  91803. * Override this method to provide functionality.
  91804. */
  91805. protected onContextMenu(evt: PointerEvent): void;
  91806. /**
  91807. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91808. * press.
  91809. * Override this method to provide functionality.
  91810. */
  91811. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91812. /**
  91813. * Called each time a new POINTERUP event occurs. Ie, for each button
  91814. * release.
  91815. * Override this method to provide functionality.
  91816. */
  91817. protected onButtonUp(evt: PointerEvent): void;
  91818. /**
  91819. * Called when window becomes inactive.
  91820. * Override this method to provide functionality.
  91821. */
  91822. protected onLostFocus(): void;
  91823. private _pointerInput;
  91824. private _observer;
  91825. private _onLostFocus;
  91826. }
  91827. }
  91828. declare module BABYLON {
  91829. /**
  91830. * Manage the pointers inputs to control an arc rotate camera.
  91831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91832. */
  91833. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91834. /**
  91835. * Defines the camera the input is attached to.
  91836. */
  91837. camera: ArcRotateCamera;
  91838. /**
  91839. * Gets the class name of the current input.
  91840. * @returns the class name
  91841. */
  91842. getClassName(): string;
  91843. /**
  91844. * Defines the buttons associated with the input to handle camera move.
  91845. */
  91846. buttons: number[];
  91847. /**
  91848. * Defines the pointer angular sensibility along the X axis or how fast is
  91849. * the camera rotating.
  91850. */
  91851. angularSensibilityX: number;
  91852. /**
  91853. * Defines the pointer angular sensibility along the Y axis or how fast is
  91854. * the camera rotating.
  91855. */
  91856. angularSensibilityY: number;
  91857. /**
  91858. * Defines the pointer pinch precision or how fast is the camera zooming.
  91859. */
  91860. pinchPrecision: number;
  91861. /**
  91862. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91863. * from 0.
  91864. * It defines the percentage of current camera.radius to use as delta when
  91865. * pinch zoom is used.
  91866. */
  91867. pinchDeltaPercentage: number;
  91868. /**
  91869. * Defines the pointer panning sensibility or how fast is the camera moving.
  91870. */
  91871. panningSensibility: number;
  91872. /**
  91873. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91874. */
  91875. multiTouchPanning: boolean;
  91876. /**
  91877. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91878. * zoom (pinch) through multitouch.
  91879. */
  91880. multiTouchPanAndZoom: boolean;
  91881. /**
  91882. * Revers pinch action direction.
  91883. */
  91884. pinchInwards: boolean;
  91885. private _isPanClick;
  91886. private _twoFingerActivityCount;
  91887. private _isPinching;
  91888. /**
  91889. * Called on pointer POINTERMOVE event if only a single touch is active.
  91890. */
  91891. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91892. /**
  91893. * Called on pointer POINTERDOUBLETAP event.
  91894. */
  91895. protected onDoubleTap(type: string): void;
  91896. /**
  91897. * Called on pointer POINTERMOVE event if multiple touches are active.
  91898. */
  91899. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91900. /**
  91901. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91902. * press.
  91903. */
  91904. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91905. /**
  91906. * Called each time a new POINTERUP event occurs. Ie, for each button
  91907. * release.
  91908. */
  91909. protected onButtonUp(evt: PointerEvent): void;
  91910. /**
  91911. * Called when window becomes inactive.
  91912. */
  91913. protected onLostFocus(): void;
  91914. }
  91915. }
  91916. declare module BABYLON {
  91917. /**
  91918. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91920. */
  91921. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91922. /**
  91923. * Defines the camera the input is attached to.
  91924. */
  91925. camera: ArcRotateCamera;
  91926. /**
  91927. * Defines the list of key codes associated with the up action (increase alpha)
  91928. */
  91929. keysUp: number[];
  91930. /**
  91931. * Defines the list of key codes associated with the down action (decrease alpha)
  91932. */
  91933. keysDown: number[];
  91934. /**
  91935. * Defines the list of key codes associated with the left action (increase beta)
  91936. */
  91937. keysLeft: number[];
  91938. /**
  91939. * Defines the list of key codes associated with the right action (decrease beta)
  91940. */
  91941. keysRight: number[];
  91942. /**
  91943. * Defines the list of key codes associated with the reset action.
  91944. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91945. */
  91946. keysReset: number[];
  91947. /**
  91948. * Defines the panning sensibility of the inputs.
  91949. * (How fast is the camera paning)
  91950. */
  91951. panningSensibility: number;
  91952. /**
  91953. * Defines the zooming sensibility of the inputs.
  91954. * (How fast is the camera zooming)
  91955. */
  91956. zoomingSensibility: number;
  91957. /**
  91958. * Defines wether maintaining the alt key down switch the movement mode from
  91959. * orientation to zoom.
  91960. */
  91961. useAltToZoom: boolean;
  91962. /**
  91963. * Rotation speed of the camera
  91964. */
  91965. angularSpeed: number;
  91966. private _keys;
  91967. private _ctrlPressed;
  91968. private _altPressed;
  91969. private _onCanvasBlurObserver;
  91970. private _onKeyboardObserver;
  91971. private _engine;
  91972. private _scene;
  91973. /**
  91974. * Attach the input controls to a specific dom element to get the input from.
  91975. * @param element Defines the element the controls should be listened from
  91976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91977. */
  91978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91979. /**
  91980. * Detach the current controls from the specified dom element.
  91981. * @param element Defines the element to stop listening the inputs from
  91982. */
  91983. detachControl(element: Nullable<HTMLElement>): void;
  91984. /**
  91985. * Update the current camera state depending on the inputs that have been used this frame.
  91986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91987. */
  91988. checkInputs(): void;
  91989. /**
  91990. * Gets the class name of the current intput.
  91991. * @returns the class name
  91992. */
  91993. getClassName(): string;
  91994. /**
  91995. * Get the friendly name associated with the input class.
  91996. * @returns the input friendly name
  91997. */
  91998. getSimpleName(): string;
  91999. }
  92000. }
  92001. declare module BABYLON {
  92002. /**
  92003. * Manage the mouse wheel inputs to control an arc rotate camera.
  92004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92005. */
  92006. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  92007. /**
  92008. * Defines the camera the input is attached to.
  92009. */
  92010. camera: ArcRotateCamera;
  92011. /**
  92012. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92013. */
  92014. wheelPrecision: number;
  92015. /**
  92016. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92017. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92018. */
  92019. wheelDeltaPercentage: number;
  92020. private _wheel;
  92021. private _observer;
  92022. /**
  92023. * Attach the input controls to a specific dom element to get the input from.
  92024. * @param element Defines the element the controls should be listened from
  92025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92026. */
  92027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92028. /**
  92029. * Detach the current controls from the specified dom element.
  92030. * @param element Defines the element to stop listening the inputs from
  92031. */
  92032. detachControl(element: Nullable<HTMLElement>): void;
  92033. /**
  92034. * Gets the class name of the current intput.
  92035. * @returns the class name
  92036. */
  92037. getClassName(): string;
  92038. /**
  92039. * Get the friendly name associated with the input class.
  92040. * @returns the input friendly name
  92041. */
  92042. getSimpleName(): string;
  92043. }
  92044. }
  92045. declare module BABYLON {
  92046. /**
  92047. * Default Inputs manager for the ArcRotateCamera.
  92048. * It groups all the default supported inputs for ease of use.
  92049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92050. */
  92051. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  92052. /**
  92053. * Instantiates a new ArcRotateCameraInputsManager.
  92054. * @param camera Defines the camera the inputs belong to
  92055. */
  92056. constructor(camera: ArcRotateCamera);
  92057. /**
  92058. * Add mouse wheel input support to the input manager.
  92059. * @returns the current input manager
  92060. */
  92061. addMouseWheel(): ArcRotateCameraInputsManager;
  92062. /**
  92063. * Add pointers input support to the input manager.
  92064. * @returns the current input manager
  92065. */
  92066. addPointers(): ArcRotateCameraInputsManager;
  92067. /**
  92068. * Add keyboard input support to the input manager.
  92069. * @returns the current input manager
  92070. */
  92071. addKeyboard(): ArcRotateCameraInputsManager;
  92072. }
  92073. }
  92074. declare module BABYLON {
  92075. /**
  92076. * This represents an orbital type of camera.
  92077. *
  92078. * 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.
  92079. * 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.
  92080. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  92081. */
  92082. export class ArcRotateCamera extends TargetCamera {
  92083. /**
  92084. * Defines the rotation angle of the camera along the longitudinal axis.
  92085. */
  92086. alpha: number;
  92087. /**
  92088. * Defines the rotation angle of the camera along the latitudinal axis.
  92089. */
  92090. beta: number;
  92091. /**
  92092. * Defines the radius of the camera from it s target point.
  92093. */
  92094. radius: number;
  92095. protected _target: Vector3;
  92096. protected _targetHost: Nullable<AbstractMesh>;
  92097. /**
  92098. * Defines the target point of the camera.
  92099. * The camera looks towards it form the radius distance.
  92100. */
  92101. target: Vector3;
  92102. /**
  92103. * Define the current local position of the camera in the scene
  92104. */
  92105. position: Vector3;
  92106. /**
  92107. * Current inertia value on the longitudinal axis.
  92108. * The bigger this number the longer it will take for the camera to stop.
  92109. */
  92110. inertialAlphaOffset: number;
  92111. /**
  92112. * Current inertia value on the latitudinal axis.
  92113. * The bigger this number the longer it will take for the camera to stop.
  92114. */
  92115. inertialBetaOffset: number;
  92116. /**
  92117. * Current inertia value on the radius axis.
  92118. * The bigger this number the longer it will take for the camera to stop.
  92119. */
  92120. inertialRadiusOffset: number;
  92121. /**
  92122. * Minimum allowed angle on the longitudinal axis.
  92123. * This can help limiting how the Camera is able to move in the scene.
  92124. */
  92125. lowerAlphaLimit: Nullable<number>;
  92126. /**
  92127. * Maximum allowed angle on the longitudinal axis.
  92128. * This can help limiting how the Camera is able to move in the scene.
  92129. */
  92130. upperAlphaLimit: Nullable<number>;
  92131. /**
  92132. * Minimum allowed angle on the latitudinal axis.
  92133. * This can help limiting how the Camera is able to move in the scene.
  92134. */
  92135. lowerBetaLimit: number;
  92136. /**
  92137. * Maximum allowed angle on the latitudinal axis.
  92138. * This can help limiting how the Camera is able to move in the scene.
  92139. */
  92140. upperBetaLimit: number;
  92141. /**
  92142. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  92143. * This can help limiting how the Camera is able to move in the scene.
  92144. */
  92145. lowerRadiusLimit: Nullable<number>;
  92146. /**
  92147. * Maximum allowed distance of the camera to the target (The camera can not get further).
  92148. * This can help limiting how the Camera is able to move in the scene.
  92149. */
  92150. upperRadiusLimit: Nullable<number>;
  92151. /**
  92152. * Defines the current inertia value used during panning of the camera along the X axis.
  92153. */
  92154. inertialPanningX: number;
  92155. /**
  92156. * Defines the current inertia value used during panning of the camera along the Y axis.
  92157. */
  92158. inertialPanningY: number;
  92159. /**
  92160. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  92161. * Basically if your fingers moves away from more than this distance you will be considered
  92162. * in pinch mode.
  92163. */
  92164. pinchToPanMaxDistance: number;
  92165. /**
  92166. * Defines the maximum distance the camera can pan.
  92167. * This could help keeping the cammera always in your scene.
  92168. */
  92169. panningDistanceLimit: Nullable<number>;
  92170. /**
  92171. * Defines the target of the camera before paning.
  92172. */
  92173. panningOriginTarget: Vector3;
  92174. /**
  92175. * Defines the value of the inertia used during panning.
  92176. * 0 would mean stop inertia and one would mean no decelleration at all.
  92177. */
  92178. panningInertia: number;
  92179. /**
  92180. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  92181. */
  92182. angularSensibilityX: number;
  92183. /**
  92184. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  92185. */
  92186. angularSensibilityY: number;
  92187. /**
  92188. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  92189. */
  92190. pinchPrecision: number;
  92191. /**
  92192. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  92193. * It will be used instead of pinchDeltaPrecision if different from 0.
  92194. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92195. */
  92196. pinchDeltaPercentage: number;
  92197. /**
  92198. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  92199. */
  92200. panningSensibility: number;
  92201. /**
  92202. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  92203. */
  92204. keysUp: number[];
  92205. /**
  92206. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  92207. */
  92208. keysDown: number[];
  92209. /**
  92210. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  92211. */
  92212. keysLeft: number[];
  92213. /**
  92214. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  92215. */
  92216. keysRight: number[];
  92217. /**
  92218. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92219. */
  92220. wheelPrecision: number;
  92221. /**
  92222. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  92223. * It will be used instead of pinchDeltaPrecision if different from 0.
  92224. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92225. */
  92226. wheelDeltaPercentage: number;
  92227. /**
  92228. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92229. */
  92230. zoomOnFactor: number;
  92231. /**
  92232. * Defines a screen offset for the camera position.
  92233. */
  92234. targetScreenOffset: Vector2;
  92235. /**
  92236. * Allows the camera to be completely reversed.
  92237. * If false the camera can not arrive upside down.
  92238. */
  92239. allowUpsideDown: boolean;
  92240. /**
  92241. * Define if double tap/click is used to restore the previously saved state of the camera.
  92242. */
  92243. useInputToRestoreState: boolean;
  92244. /** @hidden */
  92245. _viewMatrix: Matrix;
  92246. /** @hidden */
  92247. _useCtrlForPanning: boolean;
  92248. /** @hidden */
  92249. _panningMouseButton: number;
  92250. /**
  92251. * Defines the input associated to the camera.
  92252. */
  92253. inputs: ArcRotateCameraInputsManager;
  92254. /** @hidden */
  92255. _reset: () => void;
  92256. /**
  92257. * Defines the allowed panning axis.
  92258. */
  92259. panningAxis: Vector3;
  92260. protected _localDirection: Vector3;
  92261. protected _transformedDirection: Vector3;
  92262. private _bouncingBehavior;
  92263. /**
  92264. * Gets the bouncing behavior of the camera if it has been enabled.
  92265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92266. */
  92267. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92268. /**
  92269. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92270. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92271. */
  92272. useBouncingBehavior: boolean;
  92273. private _framingBehavior;
  92274. /**
  92275. * Gets the framing behavior of the camera if it has been enabled.
  92276. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92277. */
  92278. readonly framingBehavior: Nullable<FramingBehavior>;
  92279. /**
  92280. * Defines if the framing behavior of the camera is enabled on the camera.
  92281. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92282. */
  92283. useFramingBehavior: boolean;
  92284. private _autoRotationBehavior;
  92285. /**
  92286. * Gets the auto rotation behavior of the camera if it has been enabled.
  92287. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92288. */
  92289. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92290. /**
  92291. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92293. */
  92294. useAutoRotationBehavior: boolean;
  92295. /**
  92296. * Observable triggered when the mesh target has been changed on the camera.
  92297. */
  92298. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92299. /**
  92300. * Event raised when the camera is colliding with a mesh.
  92301. */
  92302. onCollide: (collidedMesh: AbstractMesh) => void;
  92303. /**
  92304. * Defines whether the camera should check collision with the objects oh the scene.
  92305. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92306. */
  92307. checkCollisions: boolean;
  92308. /**
  92309. * Defines the collision radius of the camera.
  92310. * This simulates a sphere around the camera.
  92311. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92312. */
  92313. collisionRadius: Vector3;
  92314. protected _collider: Collider;
  92315. protected _previousPosition: Vector3;
  92316. protected _collisionVelocity: Vector3;
  92317. protected _newPosition: Vector3;
  92318. protected _previousAlpha: number;
  92319. protected _previousBeta: number;
  92320. protected _previousRadius: number;
  92321. protected _collisionTriggered: boolean;
  92322. protected _targetBoundingCenter: Nullable<Vector3>;
  92323. private _computationVector;
  92324. private _tempAxisVector;
  92325. private _tempAxisRotationMatrix;
  92326. /**
  92327. * Instantiates a new ArcRotateCamera in a given scene
  92328. * @param name Defines the name of the camera
  92329. * @param alpha Defines the camera rotation along the logitudinal axis
  92330. * @param beta Defines the camera rotation along the latitudinal axis
  92331. * @param radius Defines the camera distance from its target
  92332. * @param target Defines the camera target
  92333. * @param scene Defines the scene the camera belongs to
  92334. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92335. */
  92336. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92337. /** @hidden */
  92338. _initCache(): void;
  92339. /** @hidden */
  92340. _updateCache(ignoreParentClass?: boolean): void;
  92341. protected _getTargetPosition(): Vector3;
  92342. private _storedAlpha;
  92343. private _storedBeta;
  92344. private _storedRadius;
  92345. private _storedTarget;
  92346. /**
  92347. * Stores the current state of the camera (alpha, beta, radius and target)
  92348. * @returns the camera itself
  92349. */
  92350. storeState(): Camera;
  92351. /**
  92352. * @hidden
  92353. * Restored camera state. You must call storeState() first
  92354. */
  92355. _restoreStateValues(): boolean;
  92356. /** @hidden */
  92357. _isSynchronizedViewMatrix(): boolean;
  92358. /**
  92359. * Attached controls to the current camera.
  92360. * @param element Defines the element the controls should be listened from
  92361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92362. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92363. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92364. */
  92365. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92366. /**
  92367. * Detach the current controls from the camera.
  92368. * The camera will stop reacting to inputs.
  92369. * @param element Defines the element to stop listening the inputs from
  92370. */
  92371. detachControl(element: HTMLElement): void;
  92372. /** @hidden */
  92373. _checkInputs(): void;
  92374. protected _checkLimits(): void;
  92375. /**
  92376. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92377. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92378. */
  92379. rebuildAnglesAndRadius(updateView?: boolean): void;
  92380. /**
  92381. * Use a position to define the current camera related information like aplha, beta and radius
  92382. * @param position Defines the position to set the camera at
  92383. */
  92384. setPosition(position: Vector3): void;
  92385. /**
  92386. * Defines the target the camera should look at.
  92387. * This will automatically adapt alpha beta and radius to fit within the new target.
  92388. * @param target Defines the new target as a Vector or a mesh
  92389. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92390. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92391. */
  92392. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92393. /** @hidden */
  92394. _getViewMatrix(): Matrix;
  92395. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92396. /**
  92397. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92398. * @param meshes Defines the mesh to zoom on
  92399. * @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)
  92400. */
  92401. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92402. /**
  92403. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92404. * The target will be changed but the radius
  92405. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92406. * @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)
  92407. */
  92408. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92409. min: Vector3;
  92410. max: Vector3;
  92411. distance: number;
  92412. }, doNotUpdateMaxZ?: boolean): void;
  92413. /**
  92414. * @override
  92415. * Override Camera.createRigCamera
  92416. */
  92417. createRigCamera(name: string, cameraIndex: number): Camera;
  92418. /**
  92419. * @hidden
  92420. * @override
  92421. * Override Camera._updateRigCameras
  92422. */
  92423. _updateRigCameras(): void;
  92424. /**
  92425. * Destroy the camera and release the current resources hold by it.
  92426. */
  92427. dispose(): void;
  92428. /**
  92429. * Gets the current object class name.
  92430. * @return the class name
  92431. */
  92432. getClassName(): string;
  92433. }
  92434. }
  92435. declare module BABYLON {
  92436. /**
  92437. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92438. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92439. */
  92440. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92441. /**
  92442. * Gets the name of the behavior.
  92443. */
  92444. readonly name: string;
  92445. private _zoomStopsAnimation;
  92446. private _idleRotationSpeed;
  92447. private _idleRotationWaitTime;
  92448. private _idleRotationSpinupTime;
  92449. /**
  92450. * Sets the flag that indicates if user zooming should stop animation.
  92451. */
  92452. /**
  92453. * Gets the flag that indicates if user zooming should stop animation.
  92454. */
  92455. zoomStopsAnimation: boolean;
  92456. /**
  92457. * Sets the default speed at which the camera rotates around the model.
  92458. */
  92459. /**
  92460. * Gets the default speed at which the camera rotates around the model.
  92461. */
  92462. idleRotationSpeed: number;
  92463. /**
  92464. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92465. */
  92466. /**
  92467. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92468. */
  92469. idleRotationWaitTime: number;
  92470. /**
  92471. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92472. */
  92473. /**
  92474. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92475. */
  92476. idleRotationSpinupTime: number;
  92477. /**
  92478. * Gets a value indicating if the camera is currently rotating because of this behavior
  92479. */
  92480. readonly rotationInProgress: boolean;
  92481. private _onPrePointerObservableObserver;
  92482. private _onAfterCheckInputsObserver;
  92483. private _attachedCamera;
  92484. private _isPointerDown;
  92485. private _lastFrameTime;
  92486. private _lastInteractionTime;
  92487. private _cameraRotationSpeed;
  92488. /**
  92489. * Initializes the behavior.
  92490. */
  92491. init(): void;
  92492. /**
  92493. * Attaches the behavior to its arc rotate camera.
  92494. * @param camera Defines the camera to attach the behavior to
  92495. */
  92496. attach(camera: ArcRotateCamera): void;
  92497. /**
  92498. * Detaches the behavior from its current arc rotate camera.
  92499. */
  92500. detach(): void;
  92501. /**
  92502. * Returns true if user is scrolling.
  92503. * @return true if user is scrolling.
  92504. */
  92505. private _userIsZooming;
  92506. private _lastFrameRadius;
  92507. private _shouldAnimationStopForInteraction;
  92508. /**
  92509. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92510. */
  92511. private _applyUserInteraction;
  92512. private _userIsMoving;
  92513. }
  92514. }
  92515. declare module BABYLON {
  92516. /**
  92517. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92518. */
  92519. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92520. private ui;
  92521. /**
  92522. * The name of the behavior
  92523. */
  92524. name: string;
  92525. /**
  92526. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92527. */
  92528. distanceAwayFromFace: number;
  92529. /**
  92530. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92531. */
  92532. distanceAwayFromBottomOfFace: number;
  92533. private _faceVectors;
  92534. private _target;
  92535. private _scene;
  92536. private _onRenderObserver;
  92537. private _tmpMatrix;
  92538. private _tmpVector;
  92539. /**
  92540. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92541. * @param ui The transform node that should be attched to the mesh
  92542. */
  92543. constructor(ui: TransformNode);
  92544. /**
  92545. * Initializes the behavior
  92546. */
  92547. init(): void;
  92548. private _closestFace;
  92549. private _zeroVector;
  92550. private _lookAtTmpMatrix;
  92551. private _lookAtToRef;
  92552. /**
  92553. * Attaches the AttachToBoxBehavior to the passed in mesh
  92554. * @param target The mesh that the specified node will be attached to
  92555. */
  92556. attach(target: Mesh): void;
  92557. /**
  92558. * Detaches the behavior from the mesh
  92559. */
  92560. detach(): void;
  92561. }
  92562. }
  92563. declare module BABYLON {
  92564. /**
  92565. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92566. */
  92567. export class FadeInOutBehavior implements Behavior<Mesh> {
  92568. /**
  92569. * Time in milliseconds to delay before fading in (Default: 0)
  92570. */
  92571. delay: number;
  92572. /**
  92573. * Time in milliseconds for the mesh to fade in (Default: 300)
  92574. */
  92575. fadeInTime: number;
  92576. private _millisecondsPerFrame;
  92577. private _hovered;
  92578. private _hoverValue;
  92579. private _ownerNode;
  92580. /**
  92581. * Instatiates the FadeInOutBehavior
  92582. */
  92583. constructor();
  92584. /**
  92585. * The name of the behavior
  92586. */
  92587. readonly name: string;
  92588. /**
  92589. * Initializes the behavior
  92590. */
  92591. init(): void;
  92592. /**
  92593. * Attaches the fade behavior on the passed in mesh
  92594. * @param ownerNode The mesh that will be faded in/out once attached
  92595. */
  92596. attach(ownerNode: Mesh): void;
  92597. /**
  92598. * Detaches the behavior from the mesh
  92599. */
  92600. detach(): void;
  92601. /**
  92602. * Triggers the mesh to begin fading in or out
  92603. * @param value if the object should fade in or out (true to fade in)
  92604. */
  92605. fadeIn(value: boolean): void;
  92606. private _update;
  92607. private _setAllVisibility;
  92608. }
  92609. }
  92610. declare module BABYLON {
  92611. /**
  92612. * Class containing a set of static utilities functions for managing Pivots
  92613. * @hidden
  92614. */
  92615. export class PivotTools {
  92616. private static _PivotCached;
  92617. private static _OldPivotPoint;
  92618. private static _PivotTranslation;
  92619. private static _PivotTmpVector;
  92620. /** @hidden */
  92621. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92622. /** @hidden */
  92623. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92624. }
  92625. }
  92626. declare module BABYLON {
  92627. /**
  92628. * Class containing static functions to help procedurally build meshes
  92629. */
  92630. export class PlaneBuilder {
  92631. /**
  92632. * Creates a plane mesh
  92633. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92634. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92635. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92639. * @param name defines the name of the mesh
  92640. * @param options defines the options used to create the mesh
  92641. * @param scene defines the hosting scene
  92642. * @returns the plane mesh
  92643. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92644. */
  92645. static CreatePlane(name: string, options: {
  92646. size?: number;
  92647. width?: number;
  92648. height?: number;
  92649. sideOrientation?: number;
  92650. frontUVs?: Vector4;
  92651. backUVs?: Vector4;
  92652. updatable?: boolean;
  92653. sourcePlane?: Plane;
  92654. }, scene: Scene): Mesh;
  92655. }
  92656. }
  92657. declare module BABYLON {
  92658. /**
  92659. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92660. */
  92661. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92662. private static _AnyMouseID;
  92663. private _attachedNode;
  92664. private _dragPlane;
  92665. private _scene;
  92666. private _pointerObserver;
  92667. private _beforeRenderObserver;
  92668. private static _planeScene;
  92669. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92670. /**
  92671. * 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)
  92672. */
  92673. maxDragAngle: number;
  92674. /**
  92675. * @hidden
  92676. */
  92677. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92678. /**
  92679. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92680. */
  92681. currentDraggingPointerID: number;
  92682. /**
  92683. * The last position where the pointer hit the drag plane in world space
  92684. */
  92685. lastDragPosition: Vector3;
  92686. /**
  92687. * If the behavior is currently in a dragging state
  92688. */
  92689. dragging: boolean;
  92690. /**
  92691. * 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)
  92692. */
  92693. dragDeltaRatio: number;
  92694. /**
  92695. * If the drag plane orientation should be updated during the dragging (Default: true)
  92696. */
  92697. updateDragPlane: boolean;
  92698. private _debugMode;
  92699. private _moving;
  92700. /**
  92701. * Fires each time the attached mesh is dragged with the pointer
  92702. * * delta between last drag position and current drag position in world space
  92703. * * dragDistance along the drag axis
  92704. * * dragPlaneNormal normal of the current drag plane used during the drag
  92705. * * dragPlanePoint in world space where the drag intersects the drag plane
  92706. */
  92707. onDragObservable: Observable<{
  92708. delta: Vector3;
  92709. dragPlanePoint: Vector3;
  92710. dragPlaneNormal: Vector3;
  92711. dragDistance: number;
  92712. pointerId: number;
  92713. }>;
  92714. /**
  92715. * Fires each time a drag begins (eg. mouse down on mesh)
  92716. */
  92717. onDragStartObservable: Observable<{
  92718. dragPlanePoint: Vector3;
  92719. pointerId: number;
  92720. }>;
  92721. /**
  92722. * Fires each time a drag ends (eg. mouse release after drag)
  92723. */
  92724. onDragEndObservable: Observable<{
  92725. dragPlanePoint: Vector3;
  92726. pointerId: number;
  92727. }>;
  92728. /**
  92729. * If the attached mesh should be moved when dragged
  92730. */
  92731. moveAttached: boolean;
  92732. /**
  92733. * If the drag behavior will react to drag events (Default: true)
  92734. */
  92735. enabled: boolean;
  92736. /**
  92737. * If camera controls should be detached during the drag
  92738. */
  92739. detachCameraControls: boolean;
  92740. /**
  92741. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92742. */
  92743. useObjectOrienationForDragging: boolean;
  92744. private _options;
  92745. /**
  92746. * Creates a pointer drag behavior that can be attached to a mesh
  92747. * @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)
  92748. */
  92749. constructor(options?: {
  92750. dragAxis?: Vector3;
  92751. dragPlaneNormal?: Vector3;
  92752. });
  92753. /**
  92754. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92755. */
  92756. validateDrag: (targetPosition: Vector3) => boolean;
  92757. /**
  92758. * The name of the behavior
  92759. */
  92760. readonly name: string;
  92761. /**
  92762. * Initializes the behavior
  92763. */
  92764. init(): void;
  92765. private _tmpVector;
  92766. private _alternatePickedPoint;
  92767. private _worldDragAxis;
  92768. private _targetPosition;
  92769. private _attachedElement;
  92770. /**
  92771. * Attaches the drag behavior the passed in mesh
  92772. * @param ownerNode The mesh that will be dragged around once attached
  92773. */
  92774. attach(ownerNode: AbstractMesh): void;
  92775. /**
  92776. * Force relase the drag action by code.
  92777. */
  92778. releaseDrag(): void;
  92779. private _startDragRay;
  92780. private _lastPointerRay;
  92781. /**
  92782. * Simulates the start of a pointer drag event on the behavior
  92783. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92784. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92785. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92786. */
  92787. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92788. private _startDrag;
  92789. private _dragDelta;
  92790. private _moveDrag;
  92791. private _pickWithRayOnDragPlane;
  92792. private _pointA;
  92793. private _pointB;
  92794. private _pointC;
  92795. private _lineA;
  92796. private _lineB;
  92797. private _localAxis;
  92798. private _lookAt;
  92799. private _updateDragPlanePosition;
  92800. /**
  92801. * Detaches the behavior from the mesh
  92802. */
  92803. detach(): void;
  92804. }
  92805. }
  92806. declare module BABYLON {
  92807. /**
  92808. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92809. */
  92810. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92811. private _dragBehaviorA;
  92812. private _dragBehaviorB;
  92813. private _startDistance;
  92814. private _initialScale;
  92815. private _targetScale;
  92816. private _ownerNode;
  92817. private _sceneRenderObserver;
  92818. /**
  92819. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92820. */
  92821. constructor();
  92822. /**
  92823. * The name of the behavior
  92824. */
  92825. readonly name: string;
  92826. /**
  92827. * Initializes the behavior
  92828. */
  92829. init(): void;
  92830. private _getCurrentDistance;
  92831. /**
  92832. * Attaches the scale behavior the passed in mesh
  92833. * @param ownerNode The mesh that will be scaled around once attached
  92834. */
  92835. attach(ownerNode: Mesh): void;
  92836. /**
  92837. * Detaches the behavior from the mesh
  92838. */
  92839. detach(): void;
  92840. }
  92841. }
  92842. declare module BABYLON {
  92843. /**
  92844. * 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
  92845. */
  92846. export class SixDofDragBehavior implements Behavior<Mesh> {
  92847. private static _virtualScene;
  92848. private _ownerNode;
  92849. private _sceneRenderObserver;
  92850. private _scene;
  92851. private _targetPosition;
  92852. private _virtualOriginMesh;
  92853. private _virtualDragMesh;
  92854. private _pointerObserver;
  92855. private _moving;
  92856. private _startingOrientation;
  92857. /**
  92858. * 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)
  92859. */
  92860. private zDragFactor;
  92861. /**
  92862. * If the object should rotate to face the drag origin
  92863. */
  92864. rotateDraggedObject: boolean;
  92865. /**
  92866. * If the behavior is currently in a dragging state
  92867. */
  92868. dragging: boolean;
  92869. /**
  92870. * 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)
  92871. */
  92872. dragDeltaRatio: number;
  92873. /**
  92874. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92875. */
  92876. currentDraggingPointerID: number;
  92877. /**
  92878. * If camera controls should be detached during the drag
  92879. */
  92880. detachCameraControls: boolean;
  92881. /**
  92882. * Fires each time a drag starts
  92883. */
  92884. onDragStartObservable: Observable<{}>;
  92885. /**
  92886. * Fires each time a drag ends (eg. mouse release after drag)
  92887. */
  92888. onDragEndObservable: Observable<{}>;
  92889. /**
  92890. * 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
  92891. */
  92892. constructor();
  92893. /**
  92894. * The name of the behavior
  92895. */
  92896. readonly name: string;
  92897. /**
  92898. * Initializes the behavior
  92899. */
  92900. init(): void;
  92901. /**
  92902. * Attaches the scale behavior the passed in mesh
  92903. * @param ownerNode The mesh that will be scaled around once attached
  92904. */
  92905. attach(ownerNode: Mesh): void;
  92906. /**
  92907. * Detaches the behavior from the mesh
  92908. */
  92909. detach(): void;
  92910. }
  92911. }
  92912. declare module BABYLON {
  92913. /**
  92914. * Class used to apply inverse kinematics to bones
  92915. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92916. */
  92917. export class BoneIKController {
  92918. private static _tmpVecs;
  92919. private static _tmpQuat;
  92920. private static _tmpMats;
  92921. /**
  92922. * Gets or sets the target mesh
  92923. */
  92924. targetMesh: AbstractMesh;
  92925. /** Gets or sets the mesh used as pole */
  92926. poleTargetMesh: AbstractMesh;
  92927. /**
  92928. * Gets or sets the bone used as pole
  92929. */
  92930. poleTargetBone: Nullable<Bone>;
  92931. /**
  92932. * Gets or sets the target position
  92933. */
  92934. targetPosition: Vector3;
  92935. /**
  92936. * Gets or sets the pole target position
  92937. */
  92938. poleTargetPosition: Vector3;
  92939. /**
  92940. * Gets or sets the pole target local offset
  92941. */
  92942. poleTargetLocalOffset: Vector3;
  92943. /**
  92944. * Gets or sets the pole angle
  92945. */
  92946. poleAngle: number;
  92947. /**
  92948. * Gets or sets the mesh associated with the controller
  92949. */
  92950. mesh: AbstractMesh;
  92951. /**
  92952. * 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)
  92953. */
  92954. slerpAmount: number;
  92955. private _bone1Quat;
  92956. private _bone1Mat;
  92957. private _bone2Ang;
  92958. private _bone1;
  92959. private _bone2;
  92960. private _bone1Length;
  92961. private _bone2Length;
  92962. private _maxAngle;
  92963. private _maxReach;
  92964. private _rightHandedSystem;
  92965. private _bendAxis;
  92966. private _slerping;
  92967. private _adjustRoll;
  92968. /**
  92969. * Gets or sets maximum allowed angle
  92970. */
  92971. maxAngle: number;
  92972. /**
  92973. * Creates a new BoneIKController
  92974. * @param mesh defines the mesh to control
  92975. * @param bone defines the bone to control
  92976. * @param options defines options to set up the controller
  92977. */
  92978. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92979. targetMesh?: AbstractMesh;
  92980. poleTargetMesh?: AbstractMesh;
  92981. poleTargetBone?: Bone;
  92982. poleTargetLocalOffset?: Vector3;
  92983. poleAngle?: number;
  92984. bendAxis?: Vector3;
  92985. maxAngle?: number;
  92986. slerpAmount?: number;
  92987. });
  92988. private _setMaxAngle;
  92989. /**
  92990. * Force the controller to update the bones
  92991. */
  92992. update(): void;
  92993. }
  92994. }
  92995. declare module BABYLON {
  92996. /**
  92997. * Class used to make a bone look toward a point in space
  92998. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92999. */
  93000. export class BoneLookController {
  93001. private static _tmpVecs;
  93002. private static _tmpQuat;
  93003. private static _tmpMats;
  93004. /**
  93005. * The target Vector3 that the bone will look at
  93006. */
  93007. target: Vector3;
  93008. /**
  93009. * The mesh that the bone is attached to
  93010. */
  93011. mesh: AbstractMesh;
  93012. /**
  93013. * The bone that will be looking to the target
  93014. */
  93015. bone: Bone;
  93016. /**
  93017. * The up axis of the coordinate system that is used when the bone is rotated
  93018. */
  93019. upAxis: Vector3;
  93020. /**
  93021. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  93022. */
  93023. upAxisSpace: Space;
  93024. /**
  93025. * Used to make an adjustment to the yaw of the bone
  93026. */
  93027. adjustYaw: number;
  93028. /**
  93029. * Used to make an adjustment to the pitch of the bone
  93030. */
  93031. adjustPitch: number;
  93032. /**
  93033. * Used to make an adjustment to the roll of the bone
  93034. */
  93035. adjustRoll: number;
  93036. /**
  93037. * 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)
  93038. */
  93039. slerpAmount: number;
  93040. private _minYaw;
  93041. private _maxYaw;
  93042. private _minPitch;
  93043. private _maxPitch;
  93044. private _minYawSin;
  93045. private _minYawCos;
  93046. private _maxYawSin;
  93047. private _maxYawCos;
  93048. private _midYawConstraint;
  93049. private _minPitchTan;
  93050. private _maxPitchTan;
  93051. private _boneQuat;
  93052. private _slerping;
  93053. private _transformYawPitch;
  93054. private _transformYawPitchInv;
  93055. private _firstFrameSkipped;
  93056. private _yawRange;
  93057. private _fowardAxis;
  93058. /**
  93059. * Gets or sets the minimum yaw angle that the bone can look to
  93060. */
  93061. minYaw: number;
  93062. /**
  93063. * Gets or sets the maximum yaw angle that the bone can look to
  93064. */
  93065. maxYaw: number;
  93066. /**
  93067. * Gets or sets the minimum pitch angle that the bone can look to
  93068. */
  93069. minPitch: number;
  93070. /**
  93071. * Gets or sets the maximum pitch angle that the bone can look to
  93072. */
  93073. maxPitch: number;
  93074. /**
  93075. * Create a BoneLookController
  93076. * @param mesh the mesh that the bone belongs to
  93077. * @param bone the bone that will be looking to the target
  93078. * @param target the target Vector3 to look at
  93079. * @param options optional settings:
  93080. * * maxYaw: the maximum angle the bone will yaw to
  93081. * * minYaw: the minimum angle the bone will yaw to
  93082. * * maxPitch: the maximum angle the bone will pitch to
  93083. * * minPitch: the minimum angle the bone will yaw to
  93084. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  93085. * * upAxis: the up axis of the coordinate system
  93086. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  93087. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  93088. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  93089. * * adjustYaw: used to make an adjustment to the yaw of the bone
  93090. * * adjustPitch: used to make an adjustment to the pitch of the bone
  93091. * * adjustRoll: used to make an adjustment to the roll of the bone
  93092. **/
  93093. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  93094. maxYaw?: number;
  93095. minYaw?: number;
  93096. maxPitch?: number;
  93097. minPitch?: number;
  93098. slerpAmount?: number;
  93099. upAxis?: Vector3;
  93100. upAxisSpace?: Space;
  93101. yawAxis?: Vector3;
  93102. pitchAxis?: Vector3;
  93103. adjustYaw?: number;
  93104. adjustPitch?: number;
  93105. adjustRoll?: number;
  93106. });
  93107. /**
  93108. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  93109. */
  93110. update(): void;
  93111. private _getAngleDiff;
  93112. private _getAngleBetween;
  93113. private _isAngleBetween;
  93114. }
  93115. }
  93116. declare module BABYLON {
  93117. /**
  93118. * Manage the gamepad inputs to control an arc rotate camera.
  93119. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93120. */
  93121. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  93122. /**
  93123. * Defines the camera the input is attached to.
  93124. */
  93125. camera: ArcRotateCamera;
  93126. /**
  93127. * Defines the gamepad the input is gathering event from.
  93128. */
  93129. gamepad: Nullable<Gamepad>;
  93130. /**
  93131. * Defines the gamepad rotation sensiblity.
  93132. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93133. */
  93134. gamepadRotationSensibility: number;
  93135. /**
  93136. * Defines the gamepad move sensiblity.
  93137. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93138. */
  93139. gamepadMoveSensibility: number;
  93140. private _onGamepadConnectedObserver;
  93141. private _onGamepadDisconnectedObserver;
  93142. /**
  93143. * Attach the input controls to a specific dom element to get the input from.
  93144. * @param element Defines the element the controls should be listened from
  93145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93146. */
  93147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93148. /**
  93149. * Detach the current controls from the specified dom element.
  93150. * @param element Defines the element to stop listening the inputs from
  93151. */
  93152. detachControl(element: Nullable<HTMLElement>): void;
  93153. /**
  93154. * Update the current camera state depending on the inputs that have been used this frame.
  93155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93156. */
  93157. checkInputs(): void;
  93158. /**
  93159. * Gets the class name of the current intput.
  93160. * @returns the class name
  93161. */
  93162. getClassName(): string;
  93163. /**
  93164. * Get the friendly name associated with the input class.
  93165. * @returns the input friendly name
  93166. */
  93167. getSimpleName(): string;
  93168. }
  93169. }
  93170. declare module BABYLON {
  93171. interface ArcRotateCameraInputsManager {
  93172. /**
  93173. * Add orientation input support to the input manager.
  93174. * @returns the current input manager
  93175. */
  93176. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  93177. }
  93178. /**
  93179. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  93180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93181. */
  93182. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  93183. /**
  93184. * Defines the camera the input is attached to.
  93185. */
  93186. camera: ArcRotateCamera;
  93187. /**
  93188. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  93189. */
  93190. alphaCorrection: number;
  93191. /**
  93192. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  93193. */
  93194. gammaCorrection: number;
  93195. private _alpha;
  93196. private _gamma;
  93197. private _dirty;
  93198. private _deviceOrientationHandler;
  93199. /**
  93200. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  93201. */
  93202. constructor();
  93203. /**
  93204. * Attach the input controls to a specific dom element to get the input from.
  93205. * @param element Defines the element the controls should be listened from
  93206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93207. */
  93208. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93209. /** @hidden */
  93210. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  93211. /**
  93212. * Update the current camera state depending on the inputs that have been used this frame.
  93213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93214. */
  93215. checkInputs(): void;
  93216. /**
  93217. * Detach the current controls from the specified dom element.
  93218. * @param element Defines the element to stop listening the inputs from
  93219. */
  93220. detachControl(element: Nullable<HTMLElement>): void;
  93221. /**
  93222. * Gets the class name of the current intput.
  93223. * @returns the class name
  93224. */
  93225. getClassName(): string;
  93226. /**
  93227. * Get the friendly name associated with the input class.
  93228. * @returns the input friendly name
  93229. */
  93230. getSimpleName(): string;
  93231. }
  93232. }
  93233. declare module BABYLON {
  93234. /**
  93235. * Listen to mouse events to control the camera.
  93236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93237. */
  93238. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93239. /**
  93240. * Defines the camera the input is attached to.
  93241. */
  93242. camera: FlyCamera;
  93243. /**
  93244. * Defines if touch is enabled. (Default is true.)
  93245. */
  93246. touchEnabled: boolean;
  93247. /**
  93248. * Defines the buttons associated with the input to handle camera rotation.
  93249. */
  93250. buttons: number[];
  93251. /**
  93252. * Assign buttons for Yaw control.
  93253. */
  93254. buttonsYaw: number[];
  93255. /**
  93256. * Assign buttons for Pitch control.
  93257. */
  93258. buttonsPitch: number[];
  93259. /**
  93260. * Assign buttons for Roll control.
  93261. */
  93262. buttonsRoll: number[];
  93263. /**
  93264. * Detect if any button is being pressed while mouse is moved.
  93265. * -1 = Mouse locked.
  93266. * 0 = Left button.
  93267. * 1 = Middle Button.
  93268. * 2 = Right Button.
  93269. */
  93270. activeButton: number;
  93271. /**
  93272. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93273. * Higher values reduce its sensitivity.
  93274. */
  93275. angularSensibility: number;
  93276. private _mousemoveCallback;
  93277. private _observer;
  93278. private _rollObserver;
  93279. private previousPosition;
  93280. private noPreventDefault;
  93281. private element;
  93282. /**
  93283. * Listen to mouse events to control the camera.
  93284. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93286. */
  93287. constructor(touchEnabled?: boolean);
  93288. /**
  93289. * Attach the mouse control to the HTML DOM element.
  93290. * @param element Defines the element that listens to the input events.
  93291. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93292. */
  93293. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93294. /**
  93295. * Detach the current controls from the specified dom element.
  93296. * @param element Defines the element to stop listening the inputs from
  93297. */
  93298. detachControl(element: Nullable<HTMLElement>): void;
  93299. /**
  93300. * Gets the class name of the current input.
  93301. * @returns the class name.
  93302. */
  93303. getClassName(): string;
  93304. /**
  93305. * Get the friendly name associated with the input class.
  93306. * @returns the input's friendly name.
  93307. */
  93308. getSimpleName(): string;
  93309. private _pointerInput;
  93310. private _onMouseMove;
  93311. /**
  93312. * Rotate camera by mouse offset.
  93313. */
  93314. private rotateCamera;
  93315. }
  93316. }
  93317. declare module BABYLON {
  93318. /**
  93319. * Default Inputs manager for the FlyCamera.
  93320. * It groups all the default supported inputs for ease of use.
  93321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93322. */
  93323. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93324. /**
  93325. * Instantiates a new FlyCameraInputsManager.
  93326. * @param camera Defines the camera the inputs belong to.
  93327. */
  93328. constructor(camera: FlyCamera);
  93329. /**
  93330. * Add keyboard input support to the input manager.
  93331. * @returns the new FlyCameraKeyboardMoveInput().
  93332. */
  93333. addKeyboard(): FlyCameraInputsManager;
  93334. /**
  93335. * Add mouse input support to the input manager.
  93336. * @param touchEnabled Enable touch screen support.
  93337. * @returns the new FlyCameraMouseInput().
  93338. */
  93339. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93340. }
  93341. }
  93342. declare module BABYLON {
  93343. /**
  93344. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93345. * such as in a 3D Space Shooter or a Flight Simulator.
  93346. */
  93347. export class FlyCamera extends TargetCamera {
  93348. /**
  93349. * Define the collision ellipsoid of the camera.
  93350. * This is helpful for simulating a camera body, like a player's body.
  93351. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93352. */
  93353. ellipsoid: Vector3;
  93354. /**
  93355. * Define an offset for the position of the ellipsoid around the camera.
  93356. * This can be helpful if the camera is attached away from the player's body center,
  93357. * such as at its head.
  93358. */
  93359. ellipsoidOffset: Vector3;
  93360. /**
  93361. * Enable or disable collisions of the camera with the rest of the scene objects.
  93362. */
  93363. checkCollisions: boolean;
  93364. /**
  93365. * Enable or disable gravity on the camera.
  93366. */
  93367. applyGravity: boolean;
  93368. /**
  93369. * Define the current direction the camera is moving to.
  93370. */
  93371. cameraDirection: Vector3;
  93372. /**
  93373. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93374. * This overrides and empties cameraRotation.
  93375. */
  93376. rotationQuaternion: Quaternion;
  93377. /**
  93378. * Track Roll to maintain the wanted Rolling when looking around.
  93379. */
  93380. _trackRoll: number;
  93381. /**
  93382. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93383. */
  93384. rollCorrect: number;
  93385. /**
  93386. * Mimic a banked turn, Rolling the camera when Yawing.
  93387. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93388. */
  93389. bankedTurn: boolean;
  93390. /**
  93391. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93392. */
  93393. bankedTurnLimit: number;
  93394. /**
  93395. * Value of 0 disables the banked Roll.
  93396. * Value of 1 is equal to the Yaw angle in radians.
  93397. */
  93398. bankedTurnMultiplier: number;
  93399. /**
  93400. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93401. */
  93402. inputs: FlyCameraInputsManager;
  93403. /**
  93404. * Gets the input sensibility for mouse input.
  93405. * Higher values reduce sensitivity.
  93406. */
  93407. /**
  93408. * Sets the input sensibility for a mouse input.
  93409. * Higher values reduce sensitivity.
  93410. */
  93411. angularSensibility: number;
  93412. /**
  93413. * Get the keys for camera movement forward.
  93414. */
  93415. /**
  93416. * Set the keys for camera movement forward.
  93417. */
  93418. keysForward: number[];
  93419. /**
  93420. * Get the keys for camera movement backward.
  93421. */
  93422. keysBackward: number[];
  93423. /**
  93424. * Get the keys for camera movement up.
  93425. */
  93426. /**
  93427. * Set the keys for camera movement up.
  93428. */
  93429. keysUp: number[];
  93430. /**
  93431. * Get the keys for camera movement down.
  93432. */
  93433. /**
  93434. * Set the keys for camera movement down.
  93435. */
  93436. keysDown: number[];
  93437. /**
  93438. * Get the keys for camera movement left.
  93439. */
  93440. /**
  93441. * Set the keys for camera movement left.
  93442. */
  93443. keysLeft: number[];
  93444. /**
  93445. * Set the keys for camera movement right.
  93446. */
  93447. /**
  93448. * Set the keys for camera movement right.
  93449. */
  93450. keysRight: number[];
  93451. /**
  93452. * Event raised when the camera collides with a mesh in the scene.
  93453. */
  93454. onCollide: (collidedMesh: AbstractMesh) => void;
  93455. private _collider;
  93456. private _needMoveForGravity;
  93457. private _oldPosition;
  93458. private _diffPosition;
  93459. private _newPosition;
  93460. /** @hidden */
  93461. _localDirection: Vector3;
  93462. /** @hidden */
  93463. _transformedDirection: Vector3;
  93464. /**
  93465. * Instantiates a FlyCamera.
  93466. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93467. * such as in a 3D Space Shooter or a Flight Simulator.
  93468. * @param name Define the name of the camera in the scene.
  93469. * @param position Define the starting position of the camera in the scene.
  93470. * @param scene Define the scene the camera belongs to.
  93471. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93472. */
  93473. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93474. /**
  93475. * Attach a control to the HTML DOM element.
  93476. * @param element Defines the element that listens to the input events.
  93477. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93478. */
  93479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93480. /**
  93481. * Detach a control from the HTML DOM element.
  93482. * The camera will stop reacting to that input.
  93483. * @param element Defines the element that listens to the input events.
  93484. */
  93485. detachControl(element: HTMLElement): void;
  93486. private _collisionMask;
  93487. /**
  93488. * Get the mask that the camera ignores in collision events.
  93489. */
  93490. /**
  93491. * Set the mask that the camera ignores in collision events.
  93492. */
  93493. collisionMask: number;
  93494. /** @hidden */
  93495. _collideWithWorld(displacement: Vector3): void;
  93496. /** @hidden */
  93497. private _onCollisionPositionChange;
  93498. /** @hidden */
  93499. _checkInputs(): void;
  93500. /** @hidden */
  93501. _decideIfNeedsToMove(): boolean;
  93502. /** @hidden */
  93503. _updatePosition(): void;
  93504. /**
  93505. * Restore the Roll to its target value at the rate specified.
  93506. * @param rate - Higher means slower restoring.
  93507. * @hidden
  93508. */
  93509. restoreRoll(rate: number): void;
  93510. /**
  93511. * Destroy the camera and release the current resources held by it.
  93512. */
  93513. dispose(): void;
  93514. /**
  93515. * Get the current object class name.
  93516. * @returns the class name.
  93517. */
  93518. getClassName(): string;
  93519. }
  93520. }
  93521. declare module BABYLON {
  93522. /**
  93523. * Listen to keyboard events to control the camera.
  93524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93525. */
  93526. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93527. /**
  93528. * Defines the camera the input is attached to.
  93529. */
  93530. camera: FlyCamera;
  93531. /**
  93532. * The list of keyboard keys used to control the forward move of the camera.
  93533. */
  93534. keysForward: number[];
  93535. /**
  93536. * The list of keyboard keys used to control the backward move of the camera.
  93537. */
  93538. keysBackward: number[];
  93539. /**
  93540. * The list of keyboard keys used to control the forward move of the camera.
  93541. */
  93542. keysUp: number[];
  93543. /**
  93544. * The list of keyboard keys used to control the backward move of the camera.
  93545. */
  93546. keysDown: number[];
  93547. /**
  93548. * The list of keyboard keys used to control the right strafe move of the camera.
  93549. */
  93550. keysRight: number[];
  93551. /**
  93552. * The list of keyboard keys used to control the left strafe move of the camera.
  93553. */
  93554. keysLeft: number[];
  93555. private _keys;
  93556. private _onCanvasBlurObserver;
  93557. private _onKeyboardObserver;
  93558. private _engine;
  93559. private _scene;
  93560. /**
  93561. * Attach the input controls to a specific dom element to get the input from.
  93562. * @param element Defines the element the controls should be listened from
  93563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93564. */
  93565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93566. /**
  93567. * Detach the current controls from the specified dom element.
  93568. * @param element Defines the element to stop listening the inputs from
  93569. */
  93570. detachControl(element: Nullable<HTMLElement>): void;
  93571. /**
  93572. * Gets the class name of the current intput.
  93573. * @returns the class name
  93574. */
  93575. getClassName(): string;
  93576. /** @hidden */
  93577. _onLostFocus(e: FocusEvent): void;
  93578. /**
  93579. * Get the friendly name associated with the input class.
  93580. * @returns the input friendly name
  93581. */
  93582. getSimpleName(): string;
  93583. /**
  93584. * Update the current camera state depending on the inputs that have been used this frame.
  93585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93586. */
  93587. checkInputs(): void;
  93588. }
  93589. }
  93590. declare module BABYLON {
  93591. /**
  93592. * Manage the mouse wheel inputs to control a follow camera.
  93593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93594. */
  93595. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93596. /**
  93597. * Defines the camera the input is attached to.
  93598. */
  93599. camera: FollowCamera;
  93600. /**
  93601. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93602. */
  93603. axisControlRadius: boolean;
  93604. /**
  93605. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93606. */
  93607. axisControlHeight: boolean;
  93608. /**
  93609. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93610. */
  93611. axisControlRotation: boolean;
  93612. /**
  93613. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93614. * relation to mouseWheel events.
  93615. */
  93616. wheelPrecision: number;
  93617. /**
  93618. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93619. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93620. */
  93621. wheelDeltaPercentage: number;
  93622. private _wheel;
  93623. private _observer;
  93624. /**
  93625. * Attach the input controls to a specific dom element to get the input from.
  93626. * @param element Defines the element the controls should be listened from
  93627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93628. */
  93629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93630. /**
  93631. * Detach the current controls from the specified dom element.
  93632. * @param element Defines the element to stop listening the inputs from
  93633. */
  93634. detachControl(element: Nullable<HTMLElement>): void;
  93635. /**
  93636. * Gets the class name of the current intput.
  93637. * @returns the class name
  93638. */
  93639. getClassName(): string;
  93640. /**
  93641. * Get the friendly name associated with the input class.
  93642. * @returns the input friendly name
  93643. */
  93644. getSimpleName(): string;
  93645. }
  93646. }
  93647. declare module BABYLON {
  93648. /**
  93649. * Manage the pointers inputs to control an follow camera.
  93650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93651. */
  93652. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93653. /**
  93654. * Defines the camera the input is attached to.
  93655. */
  93656. camera: FollowCamera;
  93657. /**
  93658. * Gets the class name of the current input.
  93659. * @returns the class name
  93660. */
  93661. getClassName(): string;
  93662. /**
  93663. * Defines the pointer angular sensibility along the X axis or how fast is
  93664. * the camera rotating.
  93665. * A negative number will reverse the axis direction.
  93666. */
  93667. angularSensibilityX: number;
  93668. /**
  93669. * Defines the pointer angular sensibility along the Y axis or how fast is
  93670. * the camera rotating.
  93671. * A negative number will reverse the axis direction.
  93672. */
  93673. angularSensibilityY: number;
  93674. /**
  93675. * Defines the pointer pinch precision or how fast is the camera zooming.
  93676. * A negative number will reverse the axis direction.
  93677. */
  93678. pinchPrecision: number;
  93679. /**
  93680. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93681. * from 0.
  93682. * It defines the percentage of current camera.radius to use as delta when
  93683. * pinch zoom is used.
  93684. */
  93685. pinchDeltaPercentage: number;
  93686. /**
  93687. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93688. */
  93689. axisXControlRadius: boolean;
  93690. /**
  93691. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93692. */
  93693. axisXControlHeight: boolean;
  93694. /**
  93695. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93696. */
  93697. axisXControlRotation: boolean;
  93698. /**
  93699. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93700. */
  93701. axisYControlRadius: boolean;
  93702. /**
  93703. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93704. */
  93705. axisYControlHeight: boolean;
  93706. /**
  93707. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93708. */
  93709. axisYControlRotation: boolean;
  93710. /**
  93711. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93712. */
  93713. axisPinchControlRadius: boolean;
  93714. /**
  93715. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93716. */
  93717. axisPinchControlHeight: boolean;
  93718. /**
  93719. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93720. */
  93721. axisPinchControlRotation: boolean;
  93722. /**
  93723. * Log error messages if basic misconfiguration has occurred.
  93724. */
  93725. warningEnable: boolean;
  93726. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93727. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93728. private _warningCounter;
  93729. private _warning;
  93730. }
  93731. }
  93732. declare module BABYLON {
  93733. /**
  93734. * Default Inputs manager for the FollowCamera.
  93735. * It groups all the default supported inputs for ease of use.
  93736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93737. */
  93738. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93739. /**
  93740. * Instantiates a new FollowCameraInputsManager.
  93741. * @param camera Defines the camera the inputs belong to
  93742. */
  93743. constructor(camera: FollowCamera);
  93744. /**
  93745. * Add keyboard input support to the input manager.
  93746. * @returns the current input manager
  93747. */
  93748. addKeyboard(): FollowCameraInputsManager;
  93749. /**
  93750. * Add mouse wheel input support to the input manager.
  93751. * @returns the current input manager
  93752. */
  93753. addMouseWheel(): FollowCameraInputsManager;
  93754. /**
  93755. * Add pointers input support to the input manager.
  93756. * @returns the current input manager
  93757. */
  93758. addPointers(): FollowCameraInputsManager;
  93759. /**
  93760. * Add orientation input support to the input manager.
  93761. * @returns the current input manager
  93762. */
  93763. addVRDeviceOrientation(): FollowCameraInputsManager;
  93764. }
  93765. }
  93766. declare module BABYLON {
  93767. /**
  93768. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93769. * an arc rotate version arcFollowCamera are available.
  93770. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93771. */
  93772. export class FollowCamera extends TargetCamera {
  93773. /**
  93774. * Distance the follow camera should follow an object at
  93775. */
  93776. radius: number;
  93777. /**
  93778. * Minimum allowed distance of the camera to the axis of rotation
  93779. * (The camera can not get closer).
  93780. * This can help limiting how the Camera is able to move in the scene.
  93781. */
  93782. lowerRadiusLimit: Nullable<number>;
  93783. /**
  93784. * Maximum allowed distance of the camera to the axis of rotation
  93785. * (The camera can not get further).
  93786. * This can help limiting how the Camera is able to move in the scene.
  93787. */
  93788. upperRadiusLimit: Nullable<number>;
  93789. /**
  93790. * Define a rotation offset between the camera and the object it follows
  93791. */
  93792. rotationOffset: number;
  93793. /**
  93794. * Minimum allowed angle to camera position relative to target object.
  93795. * This can help limiting how the Camera is able to move in the scene.
  93796. */
  93797. lowerRotationOffsetLimit: Nullable<number>;
  93798. /**
  93799. * Maximum allowed angle to camera position relative to target object.
  93800. * This can help limiting how the Camera is able to move in the scene.
  93801. */
  93802. upperRotationOffsetLimit: Nullable<number>;
  93803. /**
  93804. * Define a height offset between the camera and the object it follows.
  93805. * It can help following an object from the top (like a car chaing a plane)
  93806. */
  93807. heightOffset: number;
  93808. /**
  93809. * Minimum allowed height of camera position relative to target object.
  93810. * This can help limiting how the Camera is able to move in the scene.
  93811. */
  93812. lowerHeightOffsetLimit: Nullable<number>;
  93813. /**
  93814. * Maximum allowed height of camera position relative to target object.
  93815. * This can help limiting how the Camera is able to move in the scene.
  93816. */
  93817. upperHeightOffsetLimit: Nullable<number>;
  93818. /**
  93819. * Define how fast the camera can accelerate to follow it s target.
  93820. */
  93821. cameraAcceleration: number;
  93822. /**
  93823. * Define the speed limit of the camera following an object.
  93824. */
  93825. maxCameraSpeed: number;
  93826. /**
  93827. * Define the target of the camera.
  93828. */
  93829. lockedTarget: Nullable<AbstractMesh>;
  93830. /**
  93831. * Defines the input associated with the camera.
  93832. */
  93833. inputs: FollowCameraInputsManager;
  93834. /**
  93835. * Instantiates the follow camera.
  93836. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93837. * @param name Define the name of the camera in the scene
  93838. * @param position Define the position of the camera
  93839. * @param scene Define the scene the camera belong to
  93840. * @param lockedTarget Define the target of the camera
  93841. */
  93842. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93843. private _follow;
  93844. /**
  93845. * Attached controls to the current camera.
  93846. * @param element Defines the element the controls should be listened from
  93847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93848. */
  93849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93850. /**
  93851. * Detach the current controls from the camera.
  93852. * The camera will stop reacting to inputs.
  93853. * @param element Defines the element to stop listening the inputs from
  93854. */
  93855. detachControl(element: HTMLElement): void;
  93856. /** @hidden */
  93857. _checkInputs(): void;
  93858. private _checkLimits;
  93859. /**
  93860. * Gets the camera class name.
  93861. * @returns the class name
  93862. */
  93863. getClassName(): string;
  93864. }
  93865. /**
  93866. * Arc Rotate version of the follow camera.
  93867. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93868. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93869. */
  93870. export class ArcFollowCamera extends TargetCamera {
  93871. /** The longitudinal angle of the camera */
  93872. alpha: number;
  93873. /** The latitudinal angle of the camera */
  93874. beta: number;
  93875. /** The radius of the camera from its target */
  93876. radius: number;
  93877. /** Define the camera target (the messh it should follow) */
  93878. target: Nullable<AbstractMesh>;
  93879. private _cartesianCoordinates;
  93880. /**
  93881. * Instantiates a new ArcFollowCamera
  93882. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93883. * @param name Define the name of the camera
  93884. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93885. * @param beta Define the rotation angle of the camera around the elevation axis
  93886. * @param radius Define the radius of the camera from its target point
  93887. * @param target Define the target of the camera
  93888. * @param scene Define the scene the camera belongs to
  93889. */
  93890. constructor(name: string,
  93891. /** The longitudinal angle of the camera */
  93892. alpha: number,
  93893. /** The latitudinal angle of the camera */
  93894. beta: number,
  93895. /** The radius of the camera from its target */
  93896. radius: number,
  93897. /** Define the camera target (the messh it should follow) */
  93898. target: Nullable<AbstractMesh>, scene: Scene);
  93899. private _follow;
  93900. /** @hidden */
  93901. _checkInputs(): void;
  93902. /**
  93903. * Returns the class name of the object.
  93904. * It is mostly used internally for serialization purposes.
  93905. */
  93906. getClassName(): string;
  93907. }
  93908. }
  93909. declare module BABYLON {
  93910. /**
  93911. * Manage the keyboard inputs to control the movement of a follow camera.
  93912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93913. */
  93914. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93915. /**
  93916. * Defines the camera the input is attached to.
  93917. */
  93918. camera: FollowCamera;
  93919. /**
  93920. * Defines the list of key codes associated with the up action (increase heightOffset)
  93921. */
  93922. keysHeightOffsetIncr: number[];
  93923. /**
  93924. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93925. */
  93926. keysHeightOffsetDecr: number[];
  93927. /**
  93928. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93929. */
  93930. keysHeightOffsetModifierAlt: boolean;
  93931. /**
  93932. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93933. */
  93934. keysHeightOffsetModifierCtrl: boolean;
  93935. /**
  93936. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93937. */
  93938. keysHeightOffsetModifierShift: boolean;
  93939. /**
  93940. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93941. */
  93942. keysRotationOffsetIncr: number[];
  93943. /**
  93944. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93945. */
  93946. keysRotationOffsetDecr: number[];
  93947. /**
  93948. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93949. */
  93950. keysRotationOffsetModifierAlt: boolean;
  93951. /**
  93952. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93953. */
  93954. keysRotationOffsetModifierCtrl: boolean;
  93955. /**
  93956. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93957. */
  93958. keysRotationOffsetModifierShift: boolean;
  93959. /**
  93960. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93961. */
  93962. keysRadiusIncr: number[];
  93963. /**
  93964. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93965. */
  93966. keysRadiusDecr: number[];
  93967. /**
  93968. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93969. */
  93970. keysRadiusModifierAlt: boolean;
  93971. /**
  93972. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93973. */
  93974. keysRadiusModifierCtrl: boolean;
  93975. /**
  93976. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93977. */
  93978. keysRadiusModifierShift: boolean;
  93979. /**
  93980. * Defines the rate of change of heightOffset.
  93981. */
  93982. heightSensibility: number;
  93983. /**
  93984. * Defines the rate of change of rotationOffset.
  93985. */
  93986. rotationSensibility: number;
  93987. /**
  93988. * Defines the rate of change of radius.
  93989. */
  93990. radiusSensibility: number;
  93991. private _keys;
  93992. private _ctrlPressed;
  93993. private _altPressed;
  93994. private _shiftPressed;
  93995. private _onCanvasBlurObserver;
  93996. private _onKeyboardObserver;
  93997. private _engine;
  93998. private _scene;
  93999. /**
  94000. * Attach the input controls to a specific dom element to get the input from.
  94001. * @param element Defines the element the controls should be listened from
  94002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94003. */
  94004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94005. /**
  94006. * Detach the current controls from the specified dom element.
  94007. * @param element Defines the element to stop listening the inputs from
  94008. */
  94009. detachControl(element: Nullable<HTMLElement>): void;
  94010. /**
  94011. * Update the current camera state depending on the inputs that have been used this frame.
  94012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94013. */
  94014. checkInputs(): void;
  94015. /**
  94016. * Gets the class name of the current input.
  94017. * @returns the class name
  94018. */
  94019. getClassName(): string;
  94020. /**
  94021. * Get the friendly name associated with the input class.
  94022. * @returns the input friendly name
  94023. */
  94024. getSimpleName(): string;
  94025. /**
  94026. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94027. * allow modification of the heightOffset value.
  94028. */
  94029. private _modifierHeightOffset;
  94030. /**
  94031. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94032. * allow modification of the rotationOffset value.
  94033. */
  94034. private _modifierRotationOffset;
  94035. /**
  94036. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94037. * allow modification of the radius value.
  94038. */
  94039. private _modifierRadius;
  94040. }
  94041. }
  94042. declare module BABYLON {
  94043. interface FreeCameraInputsManager {
  94044. /**
  94045. * Add orientation input support to the input manager.
  94046. * @returns the current input manager
  94047. */
  94048. addDeviceOrientation(): FreeCameraInputsManager;
  94049. }
  94050. /**
  94051. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  94052. * Screen rotation is taken into account.
  94053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94054. */
  94055. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  94056. private _camera;
  94057. private _screenOrientationAngle;
  94058. private _constantTranform;
  94059. private _screenQuaternion;
  94060. private _alpha;
  94061. private _beta;
  94062. private _gamma;
  94063. /**
  94064. * Instantiates a new input
  94065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94066. */
  94067. constructor();
  94068. /**
  94069. * Define the camera controlled by the input.
  94070. */
  94071. camera: FreeCamera;
  94072. /**
  94073. * Attach the input controls to a specific dom element to get the input from.
  94074. * @param element Defines the element the controls should be listened from
  94075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94076. */
  94077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94078. private _orientationChanged;
  94079. private _deviceOrientation;
  94080. /**
  94081. * Detach the current controls from the specified dom element.
  94082. * @param element Defines the element to stop listening the inputs from
  94083. */
  94084. detachControl(element: Nullable<HTMLElement>): void;
  94085. /**
  94086. * Update the current camera state depending on the inputs that have been used this frame.
  94087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94088. */
  94089. checkInputs(): void;
  94090. /**
  94091. * Gets the class name of the current intput.
  94092. * @returns the class name
  94093. */
  94094. getClassName(): string;
  94095. /**
  94096. * Get the friendly name associated with the input class.
  94097. * @returns the input friendly name
  94098. */
  94099. getSimpleName(): string;
  94100. }
  94101. }
  94102. declare module BABYLON {
  94103. /**
  94104. * Manage the gamepad inputs to control a free camera.
  94105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94106. */
  94107. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  94108. /**
  94109. * Define the camera the input is attached to.
  94110. */
  94111. camera: FreeCamera;
  94112. /**
  94113. * Define the Gamepad controlling the input
  94114. */
  94115. gamepad: Nullable<Gamepad>;
  94116. /**
  94117. * Defines the gamepad rotation sensiblity.
  94118. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94119. */
  94120. gamepadAngularSensibility: number;
  94121. /**
  94122. * Defines the gamepad move sensiblity.
  94123. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94124. */
  94125. gamepadMoveSensibility: number;
  94126. private _onGamepadConnectedObserver;
  94127. private _onGamepadDisconnectedObserver;
  94128. private _cameraTransform;
  94129. private _deltaTransform;
  94130. private _vector3;
  94131. private _vector2;
  94132. /**
  94133. * Attach the input controls to a specific dom element to get the input from.
  94134. * @param element Defines the element the controls should be listened from
  94135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94136. */
  94137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94138. /**
  94139. * Detach the current controls from the specified dom element.
  94140. * @param element Defines the element to stop listening the inputs from
  94141. */
  94142. detachControl(element: Nullable<HTMLElement>): void;
  94143. /**
  94144. * Update the current camera state depending on the inputs that have been used this frame.
  94145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94146. */
  94147. checkInputs(): void;
  94148. /**
  94149. * Gets the class name of the current intput.
  94150. * @returns the class name
  94151. */
  94152. getClassName(): string;
  94153. /**
  94154. * Get the friendly name associated with the input class.
  94155. * @returns the input friendly name
  94156. */
  94157. getSimpleName(): string;
  94158. }
  94159. }
  94160. declare module BABYLON {
  94161. /**
  94162. * Defines the potential axis of a Joystick
  94163. */
  94164. export enum JoystickAxis {
  94165. /** X axis */
  94166. X = 0,
  94167. /** Y axis */
  94168. Y = 1,
  94169. /** Z axis */
  94170. Z = 2
  94171. }
  94172. /**
  94173. * Class used to define virtual joystick (used in touch mode)
  94174. */
  94175. export class VirtualJoystick {
  94176. /**
  94177. * Gets or sets a boolean indicating that left and right values must be inverted
  94178. */
  94179. reverseLeftRight: boolean;
  94180. /**
  94181. * Gets or sets a boolean indicating that up and down values must be inverted
  94182. */
  94183. reverseUpDown: boolean;
  94184. /**
  94185. * Gets the offset value for the position (ie. the change of the position value)
  94186. */
  94187. deltaPosition: Vector3;
  94188. /**
  94189. * Gets a boolean indicating if the virtual joystick was pressed
  94190. */
  94191. pressed: boolean;
  94192. /**
  94193. * Canvas the virtual joystick will render onto, default z-index of this is 5
  94194. */
  94195. static Canvas: Nullable<HTMLCanvasElement>;
  94196. private static _globalJoystickIndex;
  94197. private static vjCanvasContext;
  94198. private static vjCanvasWidth;
  94199. private static vjCanvasHeight;
  94200. private static halfWidth;
  94201. private _action;
  94202. private _axisTargetedByLeftAndRight;
  94203. private _axisTargetedByUpAndDown;
  94204. private _joystickSensibility;
  94205. private _inversedSensibility;
  94206. private _joystickPointerID;
  94207. private _joystickColor;
  94208. private _joystickPointerPos;
  94209. private _joystickPreviousPointerPos;
  94210. private _joystickPointerStartPos;
  94211. private _deltaJoystickVector;
  94212. private _leftJoystick;
  94213. private _touches;
  94214. private _onPointerDownHandlerRef;
  94215. private _onPointerMoveHandlerRef;
  94216. private _onPointerUpHandlerRef;
  94217. private _onResize;
  94218. /**
  94219. * Creates a new virtual joystick
  94220. * @param leftJoystick defines that the joystick is for left hand (false by default)
  94221. */
  94222. constructor(leftJoystick?: boolean);
  94223. /**
  94224. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94225. * @param newJoystickSensibility defines the new sensibility
  94226. */
  94227. setJoystickSensibility(newJoystickSensibility: number): void;
  94228. private _onPointerDown;
  94229. private _onPointerMove;
  94230. private _onPointerUp;
  94231. /**
  94232. * Change the color of the virtual joystick
  94233. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94234. */
  94235. setJoystickColor(newColor: string): void;
  94236. /**
  94237. * Defines a callback to call when the joystick is touched
  94238. * @param action defines the callback
  94239. */
  94240. setActionOnTouch(action: () => any): void;
  94241. /**
  94242. * Defines which axis you'd like to control for left & right
  94243. * @param axis defines the axis to use
  94244. */
  94245. setAxisForLeftRight(axis: JoystickAxis): void;
  94246. /**
  94247. * Defines which axis you'd like to control for up & down
  94248. * @param axis defines the axis to use
  94249. */
  94250. setAxisForUpDown(axis: JoystickAxis): void;
  94251. private _drawVirtualJoystick;
  94252. /**
  94253. * Release internal HTML canvas
  94254. */
  94255. releaseCanvas(): void;
  94256. }
  94257. }
  94258. declare module BABYLON {
  94259. interface FreeCameraInputsManager {
  94260. /**
  94261. * Add virtual joystick input support to the input manager.
  94262. * @returns the current input manager
  94263. */
  94264. addVirtualJoystick(): FreeCameraInputsManager;
  94265. }
  94266. /**
  94267. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94269. */
  94270. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94271. /**
  94272. * Defines the camera the input is attached to.
  94273. */
  94274. camera: FreeCamera;
  94275. private _leftjoystick;
  94276. private _rightjoystick;
  94277. /**
  94278. * Gets the left stick of the virtual joystick.
  94279. * @returns The virtual Joystick
  94280. */
  94281. getLeftJoystick(): VirtualJoystick;
  94282. /**
  94283. * Gets the right stick of the virtual joystick.
  94284. * @returns The virtual Joystick
  94285. */
  94286. getRightJoystick(): VirtualJoystick;
  94287. /**
  94288. * Update the current camera state depending on the inputs that have been used this frame.
  94289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94290. */
  94291. checkInputs(): void;
  94292. /**
  94293. * Attach the input controls to a specific dom element to get the input from.
  94294. * @param element Defines the element the controls should be listened from
  94295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94296. */
  94297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94298. /**
  94299. * Detach the current controls from the specified dom element.
  94300. * @param element Defines the element to stop listening the inputs from
  94301. */
  94302. detachControl(element: Nullable<HTMLElement>): void;
  94303. /**
  94304. * Gets the class name of the current intput.
  94305. * @returns the class name
  94306. */
  94307. getClassName(): string;
  94308. /**
  94309. * Get the friendly name associated with the input class.
  94310. * @returns the input friendly name
  94311. */
  94312. getSimpleName(): string;
  94313. }
  94314. }
  94315. declare module BABYLON {
  94316. /**
  94317. * This represents a FPS type of camera controlled by touch.
  94318. * This is like a universal camera minus the Gamepad controls.
  94319. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94320. */
  94321. export class TouchCamera extends FreeCamera {
  94322. /**
  94323. * Defines the touch sensibility for rotation.
  94324. * The higher the faster.
  94325. */
  94326. touchAngularSensibility: number;
  94327. /**
  94328. * Defines the touch sensibility for move.
  94329. * The higher the faster.
  94330. */
  94331. touchMoveSensibility: number;
  94332. /**
  94333. * Instantiates a new touch camera.
  94334. * This represents a FPS type of camera controlled by touch.
  94335. * This is like a universal camera minus the Gamepad controls.
  94336. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94337. * @param name Define the name of the camera in the scene
  94338. * @param position Define the start position of the camera in the scene
  94339. * @param scene Define the scene the camera belongs to
  94340. */
  94341. constructor(name: string, position: Vector3, scene: Scene);
  94342. /**
  94343. * Gets the current object class name.
  94344. * @return the class name
  94345. */
  94346. getClassName(): string;
  94347. /** @hidden */
  94348. _setupInputs(): void;
  94349. }
  94350. }
  94351. declare module BABYLON {
  94352. /**
  94353. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94354. * being tilted forward or back and left or right.
  94355. */
  94356. export class DeviceOrientationCamera extends FreeCamera {
  94357. private _initialQuaternion;
  94358. private _quaternionCache;
  94359. /**
  94360. * Creates a new device orientation camera
  94361. * @param name The name of the camera
  94362. * @param position The start position camera
  94363. * @param scene The scene the camera belongs to
  94364. */
  94365. constructor(name: string, position: Vector3, scene: Scene);
  94366. /**
  94367. * Gets the current instance class name ("DeviceOrientationCamera").
  94368. * This helps avoiding instanceof at run time.
  94369. * @returns the class name
  94370. */
  94371. getClassName(): string;
  94372. /**
  94373. * @hidden
  94374. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94375. */
  94376. _checkInputs(): void;
  94377. /**
  94378. * Reset the camera to its default orientation on the specified axis only.
  94379. * @param axis The axis to reset
  94380. */
  94381. resetToCurrentRotation(axis?: Axis): void;
  94382. }
  94383. }
  94384. declare module BABYLON {
  94385. /**
  94386. * 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,
  94387. * which still works and will still be found in many Playgrounds.
  94388. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94389. */
  94390. export class UniversalCamera extends TouchCamera {
  94391. /**
  94392. * Defines the gamepad rotation sensiblity.
  94393. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94394. */
  94395. gamepadAngularSensibility: number;
  94396. /**
  94397. * Defines the gamepad move sensiblity.
  94398. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94399. */
  94400. gamepadMoveSensibility: number;
  94401. /**
  94402. * 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,
  94403. * which still works and will still be found in many Playgrounds.
  94404. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94405. * @param name Define the name of the camera in the scene
  94406. * @param position Define the start position of the camera in the scene
  94407. * @param scene Define the scene the camera belongs to
  94408. */
  94409. constructor(name: string, position: Vector3, scene: Scene);
  94410. /**
  94411. * Gets the current object class name.
  94412. * @return the class name
  94413. */
  94414. getClassName(): string;
  94415. }
  94416. }
  94417. declare module BABYLON {
  94418. /**
  94419. * This represents a FPS type of camera. This is only here for back compat purpose.
  94420. * Please use the UniversalCamera instead as both are identical.
  94421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94422. */
  94423. export class GamepadCamera extends UniversalCamera {
  94424. /**
  94425. * Instantiates a new Gamepad Camera
  94426. * This represents a FPS type of camera. This is only here for back compat purpose.
  94427. * Please use the UniversalCamera instead as both are identical.
  94428. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94429. * @param name Define the name of the camera in the scene
  94430. * @param position Define the start position of the camera in the scene
  94431. * @param scene Define the scene the camera belongs to
  94432. */
  94433. constructor(name: string, position: Vector3, scene: Scene);
  94434. /**
  94435. * Gets the current object class name.
  94436. * @return the class name
  94437. */
  94438. getClassName(): string;
  94439. }
  94440. }
  94441. declare module BABYLON {
  94442. /** @hidden */
  94443. export var passPixelShader: {
  94444. name: string;
  94445. shader: string;
  94446. };
  94447. }
  94448. declare module BABYLON {
  94449. /** @hidden */
  94450. export var passCubePixelShader: {
  94451. name: string;
  94452. shader: string;
  94453. };
  94454. }
  94455. declare module BABYLON {
  94456. /**
  94457. * PassPostProcess which produces an output the same as it's input
  94458. */
  94459. export class PassPostProcess extends PostProcess {
  94460. /**
  94461. * Creates the PassPostProcess
  94462. * @param name The name of the effect.
  94463. * @param options The required width/height ratio to downsize to before computing the render pass.
  94464. * @param camera The camera to apply the render pass to.
  94465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94466. * @param engine The engine which the post process will be applied. (default: current engine)
  94467. * @param reusable If the post process can be reused on the same frame. (default: false)
  94468. * @param textureType The type of texture to be used when performing the post processing.
  94469. * @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)
  94470. */
  94471. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94472. }
  94473. /**
  94474. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94475. */
  94476. export class PassCubePostProcess extends PostProcess {
  94477. private _face;
  94478. /**
  94479. * Gets or sets the cube face to display.
  94480. * * 0 is +X
  94481. * * 1 is -X
  94482. * * 2 is +Y
  94483. * * 3 is -Y
  94484. * * 4 is +Z
  94485. * * 5 is -Z
  94486. */
  94487. face: number;
  94488. /**
  94489. * Creates the PassCubePostProcess
  94490. * @param name The name of the effect.
  94491. * @param options The required width/height ratio to downsize to before computing the render pass.
  94492. * @param camera The camera to apply the render pass to.
  94493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94494. * @param engine The engine which the post process will be applied. (default: current engine)
  94495. * @param reusable If the post process can be reused on the same frame. (default: false)
  94496. * @param textureType The type of texture to be used when performing the post processing.
  94497. * @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)
  94498. */
  94499. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94500. }
  94501. }
  94502. declare module BABYLON {
  94503. /** @hidden */
  94504. export var anaglyphPixelShader: {
  94505. name: string;
  94506. shader: string;
  94507. };
  94508. }
  94509. declare module BABYLON {
  94510. /**
  94511. * Postprocess used to generate anaglyphic rendering
  94512. */
  94513. export class AnaglyphPostProcess extends PostProcess {
  94514. private _passedProcess;
  94515. /**
  94516. * Creates a new AnaglyphPostProcess
  94517. * @param name defines postprocess name
  94518. * @param options defines creation options or target ratio scale
  94519. * @param rigCameras defines cameras using this postprocess
  94520. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94521. * @param engine defines hosting engine
  94522. * @param reusable defines if the postprocess will be reused multiple times per frame
  94523. */
  94524. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94525. }
  94526. }
  94527. declare module BABYLON {
  94528. /**
  94529. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94530. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94531. */
  94532. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94533. /**
  94534. * Creates a new AnaglyphArcRotateCamera
  94535. * @param name defines camera name
  94536. * @param alpha defines alpha angle (in radians)
  94537. * @param beta defines beta angle (in radians)
  94538. * @param radius defines radius
  94539. * @param target defines camera target
  94540. * @param interaxialDistance defines distance between each color axis
  94541. * @param scene defines the hosting scene
  94542. */
  94543. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94544. /**
  94545. * Gets camera class name
  94546. * @returns AnaglyphArcRotateCamera
  94547. */
  94548. getClassName(): string;
  94549. }
  94550. }
  94551. declare module BABYLON {
  94552. /**
  94553. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94554. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94555. */
  94556. export class AnaglyphFreeCamera extends FreeCamera {
  94557. /**
  94558. * Creates a new AnaglyphFreeCamera
  94559. * @param name defines camera name
  94560. * @param position defines initial position
  94561. * @param interaxialDistance defines distance between each color axis
  94562. * @param scene defines the hosting scene
  94563. */
  94564. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94565. /**
  94566. * Gets camera class name
  94567. * @returns AnaglyphFreeCamera
  94568. */
  94569. getClassName(): string;
  94570. }
  94571. }
  94572. declare module BABYLON {
  94573. /**
  94574. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94575. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94576. */
  94577. export class AnaglyphGamepadCamera extends GamepadCamera {
  94578. /**
  94579. * Creates a new AnaglyphGamepadCamera
  94580. * @param name defines camera name
  94581. * @param position defines initial position
  94582. * @param interaxialDistance defines distance between each color axis
  94583. * @param scene defines the hosting scene
  94584. */
  94585. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94586. /**
  94587. * Gets camera class name
  94588. * @returns AnaglyphGamepadCamera
  94589. */
  94590. getClassName(): string;
  94591. }
  94592. }
  94593. declare module BABYLON {
  94594. /**
  94595. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94596. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94597. */
  94598. export class AnaglyphUniversalCamera extends UniversalCamera {
  94599. /**
  94600. * Creates a new AnaglyphUniversalCamera
  94601. * @param name defines camera name
  94602. * @param position defines initial position
  94603. * @param interaxialDistance defines distance between each color axis
  94604. * @param scene defines the hosting scene
  94605. */
  94606. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94607. /**
  94608. * Gets camera class name
  94609. * @returns AnaglyphUniversalCamera
  94610. */
  94611. getClassName(): string;
  94612. }
  94613. }
  94614. declare module BABYLON {
  94615. /** @hidden */
  94616. export var stereoscopicInterlacePixelShader: {
  94617. name: string;
  94618. shader: string;
  94619. };
  94620. }
  94621. declare module BABYLON {
  94622. /**
  94623. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94624. */
  94625. export class StereoscopicInterlacePostProcess extends PostProcess {
  94626. private _stepSize;
  94627. private _passedProcess;
  94628. /**
  94629. * Initializes a StereoscopicInterlacePostProcess
  94630. * @param name The name of the effect.
  94631. * @param rigCameras The rig cameras to be appled to the post process
  94632. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94634. * @param engine The engine which the post process will be applied. (default: current engine)
  94635. * @param reusable If the post process can be reused on the same frame. (default: false)
  94636. */
  94637. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94638. }
  94639. }
  94640. declare module BABYLON {
  94641. /**
  94642. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94643. * @see http://doc.babylonjs.com/features/cameras
  94644. */
  94645. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94646. /**
  94647. * Creates a new StereoscopicArcRotateCamera
  94648. * @param name defines camera name
  94649. * @param alpha defines alpha angle (in radians)
  94650. * @param beta defines beta angle (in radians)
  94651. * @param radius defines radius
  94652. * @param target defines camera target
  94653. * @param interaxialDistance defines distance between each color axis
  94654. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94655. * @param scene defines the hosting scene
  94656. */
  94657. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94658. /**
  94659. * Gets camera class name
  94660. * @returns StereoscopicArcRotateCamera
  94661. */
  94662. getClassName(): string;
  94663. }
  94664. }
  94665. declare module BABYLON {
  94666. /**
  94667. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94668. * @see http://doc.babylonjs.com/features/cameras
  94669. */
  94670. export class StereoscopicFreeCamera extends FreeCamera {
  94671. /**
  94672. * Creates a new StereoscopicFreeCamera
  94673. * @param name defines camera name
  94674. * @param position defines initial position
  94675. * @param interaxialDistance defines distance between each color axis
  94676. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94677. * @param scene defines the hosting scene
  94678. */
  94679. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94680. /**
  94681. * Gets camera class name
  94682. * @returns StereoscopicFreeCamera
  94683. */
  94684. getClassName(): string;
  94685. }
  94686. }
  94687. declare module BABYLON {
  94688. /**
  94689. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94690. * @see http://doc.babylonjs.com/features/cameras
  94691. */
  94692. export class StereoscopicGamepadCamera extends GamepadCamera {
  94693. /**
  94694. * Creates a new StereoscopicGamepadCamera
  94695. * @param name defines camera name
  94696. * @param position defines initial position
  94697. * @param interaxialDistance defines distance between each color axis
  94698. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94699. * @param scene defines the hosting scene
  94700. */
  94701. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94702. /**
  94703. * Gets camera class name
  94704. * @returns StereoscopicGamepadCamera
  94705. */
  94706. getClassName(): string;
  94707. }
  94708. }
  94709. declare module BABYLON {
  94710. /**
  94711. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94712. * @see http://doc.babylonjs.com/features/cameras
  94713. */
  94714. export class StereoscopicUniversalCamera extends UniversalCamera {
  94715. /**
  94716. * Creates a new StereoscopicUniversalCamera
  94717. * @param name defines camera name
  94718. * @param position defines initial position
  94719. * @param interaxialDistance defines distance between each color axis
  94720. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94721. * @param scene defines the hosting scene
  94722. */
  94723. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94724. /**
  94725. * Gets camera class name
  94726. * @returns StereoscopicUniversalCamera
  94727. */
  94728. getClassName(): string;
  94729. }
  94730. }
  94731. declare module BABYLON {
  94732. /**
  94733. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94734. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94735. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94736. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94737. */
  94738. export class VirtualJoysticksCamera extends FreeCamera {
  94739. /**
  94740. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94741. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94742. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94743. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94744. * @param name Define the name of the camera in the scene
  94745. * @param position Define the start position of the camera in the scene
  94746. * @param scene Define the scene the camera belongs to
  94747. */
  94748. constructor(name: string, position: Vector3, scene: Scene);
  94749. /**
  94750. * Gets the current object class name.
  94751. * @return the class name
  94752. */
  94753. getClassName(): string;
  94754. }
  94755. }
  94756. declare module BABYLON {
  94757. /**
  94758. * This represents all the required metrics to create a VR camera.
  94759. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94760. */
  94761. export class VRCameraMetrics {
  94762. /**
  94763. * Define the horizontal resolution off the screen.
  94764. */
  94765. hResolution: number;
  94766. /**
  94767. * Define the vertical resolution off the screen.
  94768. */
  94769. vResolution: number;
  94770. /**
  94771. * Define the horizontal screen size.
  94772. */
  94773. hScreenSize: number;
  94774. /**
  94775. * Define the vertical screen size.
  94776. */
  94777. vScreenSize: number;
  94778. /**
  94779. * Define the vertical screen center position.
  94780. */
  94781. vScreenCenter: number;
  94782. /**
  94783. * Define the distance of the eyes to the screen.
  94784. */
  94785. eyeToScreenDistance: number;
  94786. /**
  94787. * Define the distance between both lenses
  94788. */
  94789. lensSeparationDistance: number;
  94790. /**
  94791. * Define the distance between both viewer's eyes.
  94792. */
  94793. interpupillaryDistance: number;
  94794. /**
  94795. * Define the distortion factor of the VR postprocess.
  94796. * Please, touch with care.
  94797. */
  94798. distortionK: number[];
  94799. /**
  94800. * Define the chromatic aberration correction factors for the VR post process.
  94801. */
  94802. chromaAbCorrection: number[];
  94803. /**
  94804. * Define the scale factor of the post process.
  94805. * The smaller the better but the slower.
  94806. */
  94807. postProcessScaleFactor: number;
  94808. /**
  94809. * Define an offset for the lens center.
  94810. */
  94811. lensCenterOffset: number;
  94812. /**
  94813. * Define if the current vr camera should compensate the distortion of the lense or not.
  94814. */
  94815. compensateDistortion: boolean;
  94816. /**
  94817. * Gets the rendering aspect ratio based on the provided resolutions.
  94818. */
  94819. readonly aspectRatio: number;
  94820. /**
  94821. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94822. */
  94823. readonly aspectRatioFov: number;
  94824. /**
  94825. * @hidden
  94826. */
  94827. readonly leftHMatrix: Matrix;
  94828. /**
  94829. * @hidden
  94830. */
  94831. readonly rightHMatrix: Matrix;
  94832. /**
  94833. * @hidden
  94834. */
  94835. readonly leftPreViewMatrix: Matrix;
  94836. /**
  94837. * @hidden
  94838. */
  94839. readonly rightPreViewMatrix: Matrix;
  94840. /**
  94841. * Get the default VRMetrics based on the most generic setup.
  94842. * @returns the default vr metrics
  94843. */
  94844. static GetDefault(): VRCameraMetrics;
  94845. }
  94846. }
  94847. declare module BABYLON {
  94848. /** @hidden */
  94849. export var vrDistortionCorrectionPixelShader: {
  94850. name: string;
  94851. shader: string;
  94852. };
  94853. }
  94854. declare module BABYLON {
  94855. /**
  94856. * VRDistortionCorrectionPostProcess used for mobile VR
  94857. */
  94858. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94859. private _isRightEye;
  94860. private _distortionFactors;
  94861. private _postProcessScaleFactor;
  94862. private _lensCenterOffset;
  94863. private _scaleIn;
  94864. private _scaleFactor;
  94865. private _lensCenter;
  94866. /**
  94867. * Initializes the VRDistortionCorrectionPostProcess
  94868. * @param name The name of the effect.
  94869. * @param camera The camera to apply the render pass to.
  94870. * @param isRightEye If this is for the right eye distortion
  94871. * @param vrMetrics All the required metrics for the VR camera
  94872. */
  94873. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94874. }
  94875. }
  94876. declare module BABYLON {
  94877. /**
  94878. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94879. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94880. */
  94881. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94882. /**
  94883. * Creates a new VRDeviceOrientationArcRotateCamera
  94884. * @param name defines camera name
  94885. * @param alpha defines the camera rotation along the logitudinal axis
  94886. * @param beta defines the camera rotation along the latitudinal axis
  94887. * @param radius defines the camera distance from its target
  94888. * @param target defines the camera target
  94889. * @param scene defines the scene the camera belongs to
  94890. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94891. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94892. */
  94893. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94894. /**
  94895. * Gets camera class name
  94896. * @returns VRDeviceOrientationArcRotateCamera
  94897. */
  94898. getClassName(): string;
  94899. }
  94900. }
  94901. declare module BABYLON {
  94902. /**
  94903. * Camera used to simulate VR rendering (based on FreeCamera)
  94904. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94905. */
  94906. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94907. /**
  94908. * Creates a new VRDeviceOrientationFreeCamera
  94909. * @param name defines camera name
  94910. * @param position defines the start position of the camera
  94911. * @param scene defines the scene the camera belongs to
  94912. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94913. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94914. */
  94915. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94916. /**
  94917. * Gets camera class name
  94918. * @returns VRDeviceOrientationFreeCamera
  94919. */
  94920. getClassName(): string;
  94921. }
  94922. }
  94923. declare module BABYLON {
  94924. /**
  94925. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94926. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94927. */
  94928. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94929. /**
  94930. * Creates a new VRDeviceOrientationGamepadCamera
  94931. * @param name defines camera name
  94932. * @param position defines the start position of the camera
  94933. * @param scene defines the scene the camera belongs to
  94934. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94935. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94936. */
  94937. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94938. /**
  94939. * Gets camera class name
  94940. * @returns VRDeviceOrientationGamepadCamera
  94941. */
  94942. getClassName(): string;
  94943. }
  94944. }
  94945. declare module BABYLON {
  94946. /**
  94947. * Defines supported buttons for XBox360 compatible gamepads
  94948. */
  94949. export enum Xbox360Button {
  94950. /** A */
  94951. A = 0,
  94952. /** B */
  94953. B = 1,
  94954. /** X */
  94955. X = 2,
  94956. /** Y */
  94957. Y = 3,
  94958. /** Start */
  94959. Start = 4,
  94960. /** Back */
  94961. Back = 5,
  94962. /** Left button */
  94963. LB = 6,
  94964. /** Right button */
  94965. RB = 7,
  94966. /** Left stick */
  94967. LeftStick = 8,
  94968. /** Right stick */
  94969. RightStick = 9
  94970. }
  94971. /** Defines values for XBox360 DPad */
  94972. export enum Xbox360Dpad {
  94973. /** Up */
  94974. Up = 0,
  94975. /** Down */
  94976. Down = 1,
  94977. /** Left */
  94978. Left = 2,
  94979. /** Right */
  94980. Right = 3
  94981. }
  94982. /**
  94983. * Defines a XBox360 gamepad
  94984. */
  94985. export class Xbox360Pad extends Gamepad {
  94986. private _leftTrigger;
  94987. private _rightTrigger;
  94988. private _onlefttriggerchanged;
  94989. private _onrighttriggerchanged;
  94990. private _onbuttondown;
  94991. private _onbuttonup;
  94992. private _ondpaddown;
  94993. private _ondpadup;
  94994. /** Observable raised when a button is pressed */
  94995. onButtonDownObservable: Observable<Xbox360Button>;
  94996. /** Observable raised when a button is released */
  94997. onButtonUpObservable: Observable<Xbox360Button>;
  94998. /** Observable raised when a pad is pressed */
  94999. onPadDownObservable: Observable<Xbox360Dpad>;
  95000. /** Observable raised when a pad is released */
  95001. onPadUpObservable: Observable<Xbox360Dpad>;
  95002. private _buttonA;
  95003. private _buttonB;
  95004. private _buttonX;
  95005. private _buttonY;
  95006. private _buttonBack;
  95007. private _buttonStart;
  95008. private _buttonLB;
  95009. private _buttonRB;
  95010. private _buttonLeftStick;
  95011. private _buttonRightStick;
  95012. private _dPadUp;
  95013. private _dPadDown;
  95014. private _dPadLeft;
  95015. private _dPadRight;
  95016. private _isXboxOnePad;
  95017. /**
  95018. * Creates a new XBox360 gamepad object
  95019. * @param id defines the id of this gamepad
  95020. * @param index defines its index
  95021. * @param gamepad defines the internal HTML gamepad object
  95022. * @param xboxOne defines if it is a XBox One gamepad
  95023. */
  95024. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  95025. /**
  95026. * Defines the callback to call when left trigger is pressed
  95027. * @param callback defines the callback to use
  95028. */
  95029. onlefttriggerchanged(callback: (value: number) => void): void;
  95030. /**
  95031. * Defines the callback to call when right trigger is pressed
  95032. * @param callback defines the callback to use
  95033. */
  95034. onrighttriggerchanged(callback: (value: number) => void): void;
  95035. /**
  95036. * Gets the left trigger value
  95037. */
  95038. /**
  95039. * Sets the left trigger value
  95040. */
  95041. leftTrigger: number;
  95042. /**
  95043. * Gets the right trigger value
  95044. */
  95045. /**
  95046. * Sets the right trigger value
  95047. */
  95048. rightTrigger: number;
  95049. /**
  95050. * Defines the callback to call when a button is pressed
  95051. * @param callback defines the callback to use
  95052. */
  95053. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  95054. /**
  95055. * Defines the callback to call when a button is released
  95056. * @param callback defines the callback to use
  95057. */
  95058. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  95059. /**
  95060. * Defines the callback to call when a pad is pressed
  95061. * @param callback defines the callback to use
  95062. */
  95063. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  95064. /**
  95065. * Defines the callback to call when a pad is released
  95066. * @param callback defines the callback to use
  95067. */
  95068. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  95069. private _setButtonValue;
  95070. private _setDPadValue;
  95071. /**
  95072. * Gets the value of the `A` button
  95073. */
  95074. /**
  95075. * Sets the value of the `A` button
  95076. */
  95077. buttonA: number;
  95078. /**
  95079. * Gets the value of the `B` button
  95080. */
  95081. /**
  95082. * Sets the value of the `B` button
  95083. */
  95084. buttonB: number;
  95085. /**
  95086. * Gets the value of the `X` button
  95087. */
  95088. /**
  95089. * Sets the value of the `X` button
  95090. */
  95091. buttonX: number;
  95092. /**
  95093. * Gets the value of the `Y` button
  95094. */
  95095. /**
  95096. * Sets the value of the `Y` button
  95097. */
  95098. buttonY: number;
  95099. /**
  95100. * Gets the value of the `Start` button
  95101. */
  95102. /**
  95103. * Sets the value of the `Start` button
  95104. */
  95105. buttonStart: number;
  95106. /**
  95107. * Gets the value of the `Back` button
  95108. */
  95109. /**
  95110. * Sets the value of the `Back` button
  95111. */
  95112. buttonBack: number;
  95113. /**
  95114. * Gets the value of the `Left` button
  95115. */
  95116. /**
  95117. * Sets the value of the `Left` button
  95118. */
  95119. buttonLB: number;
  95120. /**
  95121. * Gets the value of the `Right` button
  95122. */
  95123. /**
  95124. * Sets the value of the `Right` button
  95125. */
  95126. buttonRB: number;
  95127. /**
  95128. * Gets the value of the Left joystick
  95129. */
  95130. /**
  95131. * Sets the value of the Left joystick
  95132. */
  95133. buttonLeftStick: number;
  95134. /**
  95135. * Gets the value of the Right joystick
  95136. */
  95137. /**
  95138. * Sets the value of the Right joystick
  95139. */
  95140. buttonRightStick: number;
  95141. /**
  95142. * Gets the value of D-pad up
  95143. */
  95144. /**
  95145. * Sets the value of D-pad up
  95146. */
  95147. dPadUp: number;
  95148. /**
  95149. * Gets the value of D-pad down
  95150. */
  95151. /**
  95152. * Sets the value of D-pad down
  95153. */
  95154. dPadDown: number;
  95155. /**
  95156. * Gets the value of D-pad left
  95157. */
  95158. /**
  95159. * Sets the value of D-pad left
  95160. */
  95161. dPadLeft: number;
  95162. /**
  95163. * Gets the value of D-pad right
  95164. */
  95165. /**
  95166. * Sets the value of D-pad right
  95167. */
  95168. dPadRight: number;
  95169. /**
  95170. * Force the gamepad to synchronize with device values
  95171. */
  95172. update(): void;
  95173. /**
  95174. * Disposes the gamepad
  95175. */
  95176. dispose(): void;
  95177. }
  95178. }
  95179. declare module BABYLON {
  95180. /**
  95181. * Base class of materials working in push mode in babylon JS
  95182. * @hidden
  95183. */
  95184. export class PushMaterial extends Material {
  95185. protected _activeEffect: Effect;
  95186. protected _normalMatrix: Matrix;
  95187. /**
  95188. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  95189. * This means that the material can keep using a previous shader while a new one is being compiled.
  95190. * This is mostly used when shader parallel compilation is supported (true by default)
  95191. */
  95192. allowShaderHotSwapping: boolean;
  95193. constructor(name: string, scene: Scene);
  95194. getEffect(): Effect;
  95195. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95196. /**
  95197. * Binds the given world matrix to the active effect
  95198. *
  95199. * @param world the matrix to bind
  95200. */
  95201. bindOnlyWorldMatrix(world: Matrix): void;
  95202. /**
  95203. * Binds the given normal matrix to the active effect
  95204. *
  95205. * @param normalMatrix the matrix to bind
  95206. */
  95207. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  95208. bind(world: Matrix, mesh?: Mesh): void;
  95209. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  95210. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  95211. }
  95212. }
  95213. declare module BABYLON {
  95214. /**
  95215. * This groups all the flags used to control the materials channel.
  95216. */
  95217. export class MaterialFlags {
  95218. private static _DiffuseTextureEnabled;
  95219. /**
  95220. * Are diffuse textures enabled in the application.
  95221. */
  95222. static DiffuseTextureEnabled: boolean;
  95223. private static _AmbientTextureEnabled;
  95224. /**
  95225. * Are ambient textures enabled in the application.
  95226. */
  95227. static AmbientTextureEnabled: boolean;
  95228. private static _OpacityTextureEnabled;
  95229. /**
  95230. * Are opacity textures enabled in the application.
  95231. */
  95232. static OpacityTextureEnabled: boolean;
  95233. private static _ReflectionTextureEnabled;
  95234. /**
  95235. * Are reflection textures enabled in the application.
  95236. */
  95237. static ReflectionTextureEnabled: boolean;
  95238. private static _EmissiveTextureEnabled;
  95239. /**
  95240. * Are emissive textures enabled in the application.
  95241. */
  95242. static EmissiveTextureEnabled: boolean;
  95243. private static _SpecularTextureEnabled;
  95244. /**
  95245. * Are specular textures enabled in the application.
  95246. */
  95247. static SpecularTextureEnabled: boolean;
  95248. private static _BumpTextureEnabled;
  95249. /**
  95250. * Are bump textures enabled in the application.
  95251. */
  95252. static BumpTextureEnabled: boolean;
  95253. private static _LightmapTextureEnabled;
  95254. /**
  95255. * Are lightmap textures enabled in the application.
  95256. */
  95257. static LightmapTextureEnabled: boolean;
  95258. private static _RefractionTextureEnabled;
  95259. /**
  95260. * Are refraction textures enabled in the application.
  95261. */
  95262. static RefractionTextureEnabled: boolean;
  95263. private static _ColorGradingTextureEnabled;
  95264. /**
  95265. * Are color grading textures enabled in the application.
  95266. */
  95267. static ColorGradingTextureEnabled: boolean;
  95268. private static _FresnelEnabled;
  95269. /**
  95270. * Are fresnels enabled in the application.
  95271. */
  95272. static FresnelEnabled: boolean;
  95273. private static _ClearCoatTextureEnabled;
  95274. /**
  95275. * Are clear coat textures enabled in the application.
  95276. */
  95277. static ClearCoatTextureEnabled: boolean;
  95278. private static _ClearCoatBumpTextureEnabled;
  95279. /**
  95280. * Are clear coat bump textures enabled in the application.
  95281. */
  95282. static ClearCoatBumpTextureEnabled: boolean;
  95283. private static _ClearCoatTintTextureEnabled;
  95284. /**
  95285. * Are clear coat tint textures enabled in the application.
  95286. */
  95287. static ClearCoatTintTextureEnabled: boolean;
  95288. private static _SheenTextureEnabled;
  95289. /**
  95290. * Are sheen textures enabled in the application.
  95291. */
  95292. static SheenTextureEnabled: boolean;
  95293. private static _AnisotropicTextureEnabled;
  95294. /**
  95295. * Are anisotropic textures enabled in the application.
  95296. */
  95297. static AnisotropicTextureEnabled: boolean;
  95298. }
  95299. }
  95300. declare module BABYLON {
  95301. /** @hidden */
  95302. export var defaultFragmentDeclaration: {
  95303. name: string;
  95304. shader: string;
  95305. };
  95306. }
  95307. declare module BABYLON {
  95308. /** @hidden */
  95309. export var defaultUboDeclaration: {
  95310. name: string;
  95311. shader: string;
  95312. };
  95313. }
  95314. declare module BABYLON {
  95315. /** @hidden */
  95316. export var lightFragmentDeclaration: {
  95317. name: string;
  95318. shader: string;
  95319. };
  95320. }
  95321. declare module BABYLON {
  95322. /** @hidden */
  95323. export var lightUboDeclaration: {
  95324. name: string;
  95325. shader: string;
  95326. };
  95327. }
  95328. declare module BABYLON {
  95329. /** @hidden */
  95330. export var lightsFragmentFunctions: {
  95331. name: string;
  95332. shader: string;
  95333. };
  95334. }
  95335. declare module BABYLON {
  95336. /** @hidden */
  95337. export var shadowsFragmentFunctions: {
  95338. name: string;
  95339. shader: string;
  95340. };
  95341. }
  95342. declare module BABYLON {
  95343. /** @hidden */
  95344. export var fresnelFunction: {
  95345. name: string;
  95346. shader: string;
  95347. };
  95348. }
  95349. declare module BABYLON {
  95350. /** @hidden */
  95351. export var reflectionFunction: {
  95352. name: string;
  95353. shader: string;
  95354. };
  95355. }
  95356. declare module BABYLON {
  95357. /** @hidden */
  95358. export var bumpFragmentFunctions: {
  95359. name: string;
  95360. shader: string;
  95361. };
  95362. }
  95363. declare module BABYLON {
  95364. /** @hidden */
  95365. export var logDepthDeclaration: {
  95366. name: string;
  95367. shader: string;
  95368. };
  95369. }
  95370. declare module BABYLON {
  95371. /** @hidden */
  95372. export var bumpFragment: {
  95373. name: string;
  95374. shader: string;
  95375. };
  95376. }
  95377. declare module BABYLON {
  95378. /** @hidden */
  95379. export var depthPrePass: {
  95380. name: string;
  95381. shader: string;
  95382. };
  95383. }
  95384. declare module BABYLON {
  95385. /** @hidden */
  95386. export var lightFragment: {
  95387. name: string;
  95388. shader: string;
  95389. };
  95390. }
  95391. declare module BABYLON {
  95392. /** @hidden */
  95393. export var logDepthFragment: {
  95394. name: string;
  95395. shader: string;
  95396. };
  95397. }
  95398. declare module BABYLON {
  95399. /** @hidden */
  95400. export var defaultPixelShader: {
  95401. name: string;
  95402. shader: string;
  95403. };
  95404. }
  95405. declare module BABYLON {
  95406. /** @hidden */
  95407. export var defaultVertexDeclaration: {
  95408. name: string;
  95409. shader: string;
  95410. };
  95411. }
  95412. declare module BABYLON {
  95413. /** @hidden */
  95414. export var bumpVertexDeclaration: {
  95415. name: string;
  95416. shader: string;
  95417. };
  95418. }
  95419. declare module BABYLON {
  95420. /** @hidden */
  95421. export var bumpVertex: {
  95422. name: string;
  95423. shader: string;
  95424. };
  95425. }
  95426. declare module BABYLON {
  95427. /** @hidden */
  95428. export var fogVertex: {
  95429. name: string;
  95430. shader: string;
  95431. };
  95432. }
  95433. declare module BABYLON {
  95434. /** @hidden */
  95435. export var shadowsVertex: {
  95436. name: string;
  95437. shader: string;
  95438. };
  95439. }
  95440. declare module BABYLON {
  95441. /** @hidden */
  95442. export var pointCloudVertex: {
  95443. name: string;
  95444. shader: string;
  95445. };
  95446. }
  95447. declare module BABYLON {
  95448. /** @hidden */
  95449. export var logDepthVertex: {
  95450. name: string;
  95451. shader: string;
  95452. };
  95453. }
  95454. declare module BABYLON {
  95455. /** @hidden */
  95456. export var defaultVertexShader: {
  95457. name: string;
  95458. shader: string;
  95459. };
  95460. }
  95461. declare module BABYLON {
  95462. /** @hidden */
  95463. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95464. MAINUV1: boolean;
  95465. MAINUV2: boolean;
  95466. DIFFUSE: boolean;
  95467. DIFFUSEDIRECTUV: number;
  95468. AMBIENT: boolean;
  95469. AMBIENTDIRECTUV: number;
  95470. OPACITY: boolean;
  95471. OPACITYDIRECTUV: number;
  95472. OPACITYRGB: boolean;
  95473. REFLECTION: boolean;
  95474. EMISSIVE: boolean;
  95475. EMISSIVEDIRECTUV: number;
  95476. SPECULAR: boolean;
  95477. SPECULARDIRECTUV: number;
  95478. BUMP: boolean;
  95479. BUMPDIRECTUV: number;
  95480. PARALLAX: boolean;
  95481. PARALLAXOCCLUSION: boolean;
  95482. SPECULAROVERALPHA: boolean;
  95483. CLIPPLANE: boolean;
  95484. CLIPPLANE2: boolean;
  95485. CLIPPLANE3: boolean;
  95486. CLIPPLANE4: boolean;
  95487. ALPHATEST: boolean;
  95488. DEPTHPREPASS: boolean;
  95489. ALPHAFROMDIFFUSE: boolean;
  95490. POINTSIZE: boolean;
  95491. FOG: boolean;
  95492. SPECULARTERM: boolean;
  95493. DIFFUSEFRESNEL: boolean;
  95494. OPACITYFRESNEL: boolean;
  95495. REFLECTIONFRESNEL: boolean;
  95496. REFRACTIONFRESNEL: boolean;
  95497. EMISSIVEFRESNEL: boolean;
  95498. FRESNEL: boolean;
  95499. NORMAL: boolean;
  95500. UV1: boolean;
  95501. UV2: boolean;
  95502. VERTEXCOLOR: boolean;
  95503. VERTEXALPHA: boolean;
  95504. NUM_BONE_INFLUENCERS: number;
  95505. BonesPerMesh: number;
  95506. BONETEXTURE: boolean;
  95507. INSTANCES: boolean;
  95508. GLOSSINESS: boolean;
  95509. ROUGHNESS: boolean;
  95510. EMISSIVEASILLUMINATION: boolean;
  95511. LINKEMISSIVEWITHDIFFUSE: boolean;
  95512. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95513. LIGHTMAP: boolean;
  95514. LIGHTMAPDIRECTUV: number;
  95515. OBJECTSPACE_NORMALMAP: boolean;
  95516. USELIGHTMAPASSHADOWMAP: boolean;
  95517. REFLECTIONMAP_3D: boolean;
  95518. REFLECTIONMAP_SPHERICAL: boolean;
  95519. REFLECTIONMAP_PLANAR: boolean;
  95520. REFLECTIONMAP_CUBIC: boolean;
  95521. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95522. REFLECTIONMAP_PROJECTION: boolean;
  95523. REFLECTIONMAP_SKYBOX: boolean;
  95524. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95525. REFLECTIONMAP_EXPLICIT: boolean;
  95526. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95527. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95528. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95529. INVERTCUBICMAP: boolean;
  95530. LOGARITHMICDEPTH: boolean;
  95531. REFRACTION: boolean;
  95532. REFRACTIONMAP_3D: boolean;
  95533. REFLECTIONOVERALPHA: boolean;
  95534. TWOSIDEDLIGHTING: boolean;
  95535. SHADOWFLOAT: boolean;
  95536. MORPHTARGETS: boolean;
  95537. MORPHTARGETS_NORMAL: boolean;
  95538. MORPHTARGETS_TANGENT: boolean;
  95539. NUM_MORPH_INFLUENCERS: number;
  95540. NONUNIFORMSCALING: boolean;
  95541. PREMULTIPLYALPHA: boolean;
  95542. IMAGEPROCESSING: boolean;
  95543. VIGNETTE: boolean;
  95544. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95545. VIGNETTEBLENDMODEOPAQUE: boolean;
  95546. TONEMAPPING: boolean;
  95547. TONEMAPPING_ACES: boolean;
  95548. CONTRAST: boolean;
  95549. COLORCURVES: boolean;
  95550. COLORGRADING: boolean;
  95551. COLORGRADING3D: boolean;
  95552. SAMPLER3DGREENDEPTH: boolean;
  95553. SAMPLER3DBGRMAP: boolean;
  95554. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95555. /**
  95556. * If the reflection texture on this material is in linear color space
  95557. * @hidden
  95558. */
  95559. IS_REFLECTION_LINEAR: boolean;
  95560. /**
  95561. * If the refraction texture on this material is in linear color space
  95562. * @hidden
  95563. */
  95564. IS_REFRACTION_LINEAR: boolean;
  95565. EXPOSURE: boolean;
  95566. constructor();
  95567. setReflectionMode(modeToEnable: string): void;
  95568. }
  95569. /**
  95570. * This is the default material used in Babylon. It is the best trade off between quality
  95571. * and performances.
  95572. * @see http://doc.babylonjs.com/babylon101/materials
  95573. */
  95574. export class StandardMaterial extends PushMaterial {
  95575. private _diffuseTexture;
  95576. /**
  95577. * The basic texture of the material as viewed under a light.
  95578. */
  95579. diffuseTexture: Nullable<BaseTexture>;
  95580. private _ambientTexture;
  95581. /**
  95582. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95583. */
  95584. ambientTexture: Nullable<BaseTexture>;
  95585. private _opacityTexture;
  95586. /**
  95587. * Define the transparency of the material from a texture.
  95588. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95589. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95590. */
  95591. opacityTexture: Nullable<BaseTexture>;
  95592. private _reflectionTexture;
  95593. /**
  95594. * Define the texture used to display the reflection.
  95595. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95596. */
  95597. reflectionTexture: Nullable<BaseTexture>;
  95598. private _emissiveTexture;
  95599. /**
  95600. * Define texture of the material as if self lit.
  95601. * This will be mixed in the final result even in the absence of light.
  95602. */
  95603. emissiveTexture: Nullable<BaseTexture>;
  95604. private _specularTexture;
  95605. /**
  95606. * Define how the color and intensity of the highlight given by the light in the material.
  95607. */
  95608. specularTexture: Nullable<BaseTexture>;
  95609. private _bumpTexture;
  95610. /**
  95611. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95612. * 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.
  95613. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95614. */
  95615. bumpTexture: Nullable<BaseTexture>;
  95616. private _lightmapTexture;
  95617. /**
  95618. * Complex lighting can be computationally expensive to compute at runtime.
  95619. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95620. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95621. */
  95622. lightmapTexture: Nullable<BaseTexture>;
  95623. private _refractionTexture;
  95624. /**
  95625. * Define the texture used to display the refraction.
  95626. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95627. */
  95628. refractionTexture: Nullable<BaseTexture>;
  95629. /**
  95630. * The color of the material lit by the environmental background lighting.
  95631. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95632. */
  95633. ambientColor: Color3;
  95634. /**
  95635. * The basic color of the material as viewed under a light.
  95636. */
  95637. diffuseColor: Color3;
  95638. /**
  95639. * Define how the color and intensity of the highlight given by the light in the material.
  95640. */
  95641. specularColor: Color3;
  95642. /**
  95643. * Define the color of the material as if self lit.
  95644. * This will be mixed in the final result even in the absence of light.
  95645. */
  95646. emissiveColor: Color3;
  95647. /**
  95648. * Defines how sharp are the highlights in the material.
  95649. * The bigger the value the sharper giving a more glossy feeling to the result.
  95650. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95651. */
  95652. specularPower: number;
  95653. private _useAlphaFromDiffuseTexture;
  95654. /**
  95655. * Does the transparency come from the diffuse texture alpha channel.
  95656. */
  95657. useAlphaFromDiffuseTexture: boolean;
  95658. private _useEmissiveAsIllumination;
  95659. /**
  95660. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95661. */
  95662. useEmissiveAsIllumination: boolean;
  95663. private _linkEmissiveWithDiffuse;
  95664. /**
  95665. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95666. * the emissive level when the final color is close to one.
  95667. */
  95668. linkEmissiveWithDiffuse: boolean;
  95669. private _useSpecularOverAlpha;
  95670. /**
  95671. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95672. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95673. */
  95674. useSpecularOverAlpha: boolean;
  95675. private _useReflectionOverAlpha;
  95676. /**
  95677. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95678. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95679. */
  95680. useReflectionOverAlpha: boolean;
  95681. private _disableLighting;
  95682. /**
  95683. * Does lights from the scene impacts this material.
  95684. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95685. */
  95686. disableLighting: boolean;
  95687. private _useObjectSpaceNormalMap;
  95688. /**
  95689. * Allows using an object space normal map (instead of tangent space).
  95690. */
  95691. useObjectSpaceNormalMap: boolean;
  95692. private _useParallax;
  95693. /**
  95694. * Is parallax enabled or not.
  95695. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95696. */
  95697. useParallax: boolean;
  95698. private _useParallaxOcclusion;
  95699. /**
  95700. * Is parallax occlusion enabled or not.
  95701. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95702. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95703. */
  95704. useParallaxOcclusion: boolean;
  95705. /**
  95706. * 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.
  95707. */
  95708. parallaxScaleBias: number;
  95709. private _roughness;
  95710. /**
  95711. * Helps to define how blurry the reflections should appears in the material.
  95712. */
  95713. roughness: number;
  95714. /**
  95715. * In case of refraction, define the value of the indice of refraction.
  95716. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95717. */
  95718. indexOfRefraction: number;
  95719. /**
  95720. * Invert the refraction texture alongside the y axis.
  95721. * It can be useful with procedural textures or probe for instance.
  95722. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95723. */
  95724. invertRefractionY: boolean;
  95725. /**
  95726. * Defines the alpha limits in alpha test mode.
  95727. */
  95728. alphaCutOff: number;
  95729. private _useLightmapAsShadowmap;
  95730. /**
  95731. * In case of light mapping, define whether the map contains light or shadow informations.
  95732. */
  95733. useLightmapAsShadowmap: boolean;
  95734. private _diffuseFresnelParameters;
  95735. /**
  95736. * Define the diffuse fresnel parameters of the material.
  95737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95738. */
  95739. diffuseFresnelParameters: FresnelParameters;
  95740. private _opacityFresnelParameters;
  95741. /**
  95742. * Define the opacity fresnel parameters of the material.
  95743. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95744. */
  95745. opacityFresnelParameters: FresnelParameters;
  95746. private _reflectionFresnelParameters;
  95747. /**
  95748. * Define the reflection fresnel parameters of the material.
  95749. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95750. */
  95751. reflectionFresnelParameters: FresnelParameters;
  95752. private _refractionFresnelParameters;
  95753. /**
  95754. * Define the refraction fresnel parameters of the material.
  95755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95756. */
  95757. refractionFresnelParameters: FresnelParameters;
  95758. private _emissiveFresnelParameters;
  95759. /**
  95760. * Define the emissive fresnel parameters of the material.
  95761. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95762. */
  95763. emissiveFresnelParameters: FresnelParameters;
  95764. private _useReflectionFresnelFromSpecular;
  95765. /**
  95766. * If true automatically deducts the fresnels values from the material specularity.
  95767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95768. */
  95769. useReflectionFresnelFromSpecular: boolean;
  95770. private _useGlossinessFromSpecularMapAlpha;
  95771. /**
  95772. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95773. */
  95774. useGlossinessFromSpecularMapAlpha: boolean;
  95775. private _maxSimultaneousLights;
  95776. /**
  95777. * Defines the maximum number of lights that can be used in the material
  95778. */
  95779. maxSimultaneousLights: number;
  95780. private _invertNormalMapX;
  95781. /**
  95782. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95783. */
  95784. invertNormalMapX: boolean;
  95785. private _invertNormalMapY;
  95786. /**
  95787. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95788. */
  95789. invertNormalMapY: boolean;
  95790. private _twoSidedLighting;
  95791. /**
  95792. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95793. */
  95794. twoSidedLighting: boolean;
  95795. /**
  95796. * Default configuration related to image processing available in the standard Material.
  95797. */
  95798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95799. /**
  95800. * Gets the image processing configuration used either in this material.
  95801. */
  95802. /**
  95803. * Sets the Default image processing configuration used either in the this material.
  95804. *
  95805. * If sets to null, the scene one is in use.
  95806. */
  95807. imageProcessingConfiguration: ImageProcessingConfiguration;
  95808. /**
  95809. * Keep track of the image processing observer to allow dispose and replace.
  95810. */
  95811. private _imageProcessingObserver;
  95812. /**
  95813. * Attaches a new image processing configuration to the Standard Material.
  95814. * @param configuration
  95815. */
  95816. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95817. /**
  95818. * Gets wether the color curves effect is enabled.
  95819. */
  95820. /**
  95821. * Sets wether the color curves effect is enabled.
  95822. */
  95823. cameraColorCurvesEnabled: boolean;
  95824. /**
  95825. * Gets wether the color grading effect is enabled.
  95826. */
  95827. /**
  95828. * Gets wether the color grading effect is enabled.
  95829. */
  95830. cameraColorGradingEnabled: boolean;
  95831. /**
  95832. * Gets wether tonemapping is enabled or not.
  95833. */
  95834. /**
  95835. * Sets wether tonemapping is enabled or not
  95836. */
  95837. cameraToneMappingEnabled: boolean;
  95838. /**
  95839. * The camera exposure used on this material.
  95840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95841. * This corresponds to a photographic exposure.
  95842. */
  95843. /**
  95844. * The camera exposure used on this material.
  95845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95846. * This corresponds to a photographic exposure.
  95847. */
  95848. cameraExposure: number;
  95849. /**
  95850. * Gets The camera contrast used on this material.
  95851. */
  95852. /**
  95853. * Sets The camera contrast used on this material.
  95854. */
  95855. cameraContrast: number;
  95856. /**
  95857. * Gets the Color Grading 2D Lookup Texture.
  95858. */
  95859. /**
  95860. * Sets the Color Grading 2D Lookup Texture.
  95861. */
  95862. cameraColorGradingTexture: Nullable<BaseTexture>;
  95863. /**
  95864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95866. * 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;
  95867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95868. */
  95869. /**
  95870. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95871. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95872. * 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;
  95873. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95874. */
  95875. cameraColorCurves: Nullable<ColorCurves>;
  95876. /**
  95877. * Custom callback helping to override the default shader used in the material.
  95878. */
  95879. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95880. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95881. protected _worldViewProjectionMatrix: Matrix;
  95882. protected _globalAmbientColor: Color3;
  95883. protected _useLogarithmicDepth: boolean;
  95884. /**
  95885. * Instantiates a new standard material.
  95886. * This is the default material used in Babylon. It is the best trade off between quality
  95887. * and performances.
  95888. * @see http://doc.babylonjs.com/babylon101/materials
  95889. * @param name Define the name of the material in the scene
  95890. * @param scene Define the scene the material belong to
  95891. */
  95892. constructor(name: string, scene: Scene);
  95893. /**
  95894. * Gets a boolean indicating that current material needs to register RTT
  95895. */
  95896. readonly hasRenderTargetTextures: boolean;
  95897. /**
  95898. * Gets the current class name of the material e.g. "StandardMaterial"
  95899. * Mainly use in serialization.
  95900. * @returns the class name
  95901. */
  95902. getClassName(): string;
  95903. /**
  95904. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95905. * You can try switching to logarithmic depth.
  95906. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95907. */
  95908. useLogarithmicDepth: boolean;
  95909. /**
  95910. * Specifies if the material will require alpha blending
  95911. * @returns a boolean specifying if alpha blending is needed
  95912. */
  95913. needAlphaBlending(): boolean;
  95914. /**
  95915. * Specifies if this material should be rendered in alpha test mode
  95916. * @returns a boolean specifying if an alpha test is needed.
  95917. */
  95918. needAlphaTesting(): boolean;
  95919. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95920. /**
  95921. * Get the texture used for alpha test purpose.
  95922. * @returns the diffuse texture in case of the standard material.
  95923. */
  95924. getAlphaTestTexture(): Nullable<BaseTexture>;
  95925. /**
  95926. * Get if the submesh is ready to be used and all its information available.
  95927. * Child classes can use it to update shaders
  95928. * @param mesh defines the mesh to check
  95929. * @param subMesh defines which submesh to check
  95930. * @param useInstances specifies that instances should be used
  95931. * @returns a boolean indicating that the submesh is ready or not
  95932. */
  95933. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95934. /**
  95935. * Builds the material UBO layouts.
  95936. * Used internally during the effect preparation.
  95937. */
  95938. buildUniformLayout(): void;
  95939. /**
  95940. * Unbinds the material from the mesh
  95941. */
  95942. unbind(): void;
  95943. /**
  95944. * Binds the submesh to this material by preparing the effect and shader to draw
  95945. * @param world defines the world transformation matrix
  95946. * @param mesh defines the mesh containing the submesh
  95947. * @param subMesh defines the submesh to bind the material to
  95948. */
  95949. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95950. /**
  95951. * Get the list of animatables in the material.
  95952. * @returns the list of animatables object used in the material
  95953. */
  95954. getAnimatables(): IAnimatable[];
  95955. /**
  95956. * Gets the active textures from the material
  95957. * @returns an array of textures
  95958. */
  95959. getActiveTextures(): BaseTexture[];
  95960. /**
  95961. * Specifies if the material uses a texture
  95962. * @param texture defines the texture to check against the material
  95963. * @returns a boolean specifying if the material uses the texture
  95964. */
  95965. hasTexture(texture: BaseTexture): boolean;
  95966. /**
  95967. * Disposes the material
  95968. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95969. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95970. */
  95971. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95972. /**
  95973. * Makes a duplicate of the material, and gives it a new name
  95974. * @param name defines the new name for the duplicated material
  95975. * @returns the cloned material
  95976. */
  95977. clone(name: string): StandardMaterial;
  95978. /**
  95979. * Serializes this material in a JSON representation
  95980. * @returns the serialized material object
  95981. */
  95982. serialize(): any;
  95983. /**
  95984. * Creates a standard material from parsed material data
  95985. * @param source defines the JSON representation of the material
  95986. * @param scene defines the hosting scene
  95987. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95988. * @returns a new standard material
  95989. */
  95990. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95991. /**
  95992. * Are diffuse textures enabled in the application.
  95993. */
  95994. static DiffuseTextureEnabled: boolean;
  95995. /**
  95996. * Are ambient textures enabled in the application.
  95997. */
  95998. static AmbientTextureEnabled: boolean;
  95999. /**
  96000. * Are opacity textures enabled in the application.
  96001. */
  96002. static OpacityTextureEnabled: boolean;
  96003. /**
  96004. * Are reflection textures enabled in the application.
  96005. */
  96006. static ReflectionTextureEnabled: boolean;
  96007. /**
  96008. * Are emissive textures enabled in the application.
  96009. */
  96010. static EmissiveTextureEnabled: boolean;
  96011. /**
  96012. * Are specular textures enabled in the application.
  96013. */
  96014. static SpecularTextureEnabled: boolean;
  96015. /**
  96016. * Are bump textures enabled in the application.
  96017. */
  96018. static BumpTextureEnabled: boolean;
  96019. /**
  96020. * Are lightmap textures enabled in the application.
  96021. */
  96022. static LightmapTextureEnabled: boolean;
  96023. /**
  96024. * Are refraction textures enabled in the application.
  96025. */
  96026. static RefractionTextureEnabled: boolean;
  96027. /**
  96028. * Are color grading textures enabled in the application.
  96029. */
  96030. static ColorGradingTextureEnabled: boolean;
  96031. /**
  96032. * Are fresnels enabled in the application.
  96033. */
  96034. static FresnelEnabled: boolean;
  96035. }
  96036. }
  96037. declare module BABYLON {
  96038. /**
  96039. * A class extending Texture allowing drawing on a texture
  96040. * @see http://doc.babylonjs.com/how_to/dynamictexture
  96041. */
  96042. export class DynamicTexture extends Texture {
  96043. private _generateMipMaps;
  96044. private _canvas;
  96045. private _context;
  96046. private _engine;
  96047. /**
  96048. * Creates a DynamicTexture
  96049. * @param name defines the name of the texture
  96050. * @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
  96051. * @param scene defines the scene where you want the texture
  96052. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  96053. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96054. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  96055. */
  96056. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  96057. /**
  96058. * Get the current class name of the texture useful for serialization or dynamic coding.
  96059. * @returns "DynamicTexture"
  96060. */
  96061. getClassName(): string;
  96062. /**
  96063. * Gets the current state of canRescale
  96064. */
  96065. readonly canRescale: boolean;
  96066. private _recreate;
  96067. /**
  96068. * Scales the texture
  96069. * @param ratio the scale factor to apply to both width and height
  96070. */
  96071. scale(ratio: number): void;
  96072. /**
  96073. * Resizes the texture
  96074. * @param width the new width
  96075. * @param height the new height
  96076. */
  96077. scaleTo(width: number, height: number): void;
  96078. /**
  96079. * Gets the context of the canvas used by the texture
  96080. * @returns the canvas context of the dynamic texture
  96081. */
  96082. getContext(): CanvasRenderingContext2D;
  96083. /**
  96084. * Clears the texture
  96085. */
  96086. clear(): void;
  96087. /**
  96088. * Updates the texture
  96089. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96090. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  96091. */
  96092. update(invertY?: boolean, premulAlpha?: boolean): void;
  96093. /**
  96094. * Draws text onto the texture
  96095. * @param text defines the text to be drawn
  96096. * @param x defines the placement of the text from the left
  96097. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  96098. * @param font defines the font to be used with font-style, font-size, font-name
  96099. * @param color defines the color used for the text
  96100. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  96101. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96102. * @param update defines whether texture is immediately update (default is true)
  96103. */
  96104. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  96105. /**
  96106. * Clones the texture
  96107. * @returns the clone of the texture.
  96108. */
  96109. clone(): DynamicTexture;
  96110. /**
  96111. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  96112. * @returns a serialized dynamic texture object
  96113. */
  96114. serialize(): any;
  96115. /** @hidden */
  96116. _rebuild(): void;
  96117. }
  96118. }
  96119. declare module BABYLON {
  96120. /** @hidden */
  96121. export var imageProcessingPixelShader: {
  96122. name: string;
  96123. shader: string;
  96124. };
  96125. }
  96126. declare module BABYLON {
  96127. /**
  96128. * ImageProcessingPostProcess
  96129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  96130. */
  96131. export class ImageProcessingPostProcess extends PostProcess {
  96132. /**
  96133. * Default configuration related to image processing available in the PBR Material.
  96134. */
  96135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96136. /**
  96137. * Gets the image processing configuration used either in this material.
  96138. */
  96139. /**
  96140. * Sets the Default image processing configuration used either in the this material.
  96141. *
  96142. * If sets to null, the scene one is in use.
  96143. */
  96144. imageProcessingConfiguration: ImageProcessingConfiguration;
  96145. /**
  96146. * Keep track of the image processing observer to allow dispose and replace.
  96147. */
  96148. private _imageProcessingObserver;
  96149. /**
  96150. * Attaches a new image processing configuration to the PBR Material.
  96151. * @param configuration
  96152. */
  96153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  96154. /**
  96155. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  96156. */
  96157. /**
  96158. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  96159. */
  96160. colorCurves: Nullable<ColorCurves>;
  96161. /**
  96162. * Gets wether the color curves effect is enabled.
  96163. */
  96164. /**
  96165. * Sets wether the color curves effect is enabled.
  96166. */
  96167. colorCurvesEnabled: boolean;
  96168. /**
  96169. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96170. */
  96171. /**
  96172. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96173. */
  96174. colorGradingTexture: Nullable<BaseTexture>;
  96175. /**
  96176. * Gets wether the color grading effect is enabled.
  96177. */
  96178. /**
  96179. * Gets wether the color grading effect is enabled.
  96180. */
  96181. colorGradingEnabled: boolean;
  96182. /**
  96183. * Gets exposure used in the effect.
  96184. */
  96185. /**
  96186. * Sets exposure used in the effect.
  96187. */
  96188. exposure: number;
  96189. /**
  96190. * Gets wether tonemapping is enabled or not.
  96191. */
  96192. /**
  96193. * Sets wether tonemapping is enabled or not
  96194. */
  96195. toneMappingEnabled: boolean;
  96196. /**
  96197. * Gets the type of tone mapping effect.
  96198. */
  96199. /**
  96200. * Sets the type of tone mapping effect.
  96201. */
  96202. toneMappingType: number;
  96203. /**
  96204. * Gets contrast used in the effect.
  96205. */
  96206. /**
  96207. * Sets contrast used in the effect.
  96208. */
  96209. contrast: number;
  96210. /**
  96211. * Gets Vignette stretch size.
  96212. */
  96213. /**
  96214. * Sets Vignette stretch size.
  96215. */
  96216. vignetteStretch: number;
  96217. /**
  96218. * Gets Vignette centre X Offset.
  96219. */
  96220. /**
  96221. * Sets Vignette centre X Offset.
  96222. */
  96223. vignetteCentreX: number;
  96224. /**
  96225. * Gets Vignette centre Y Offset.
  96226. */
  96227. /**
  96228. * Sets Vignette centre Y Offset.
  96229. */
  96230. vignetteCentreY: number;
  96231. /**
  96232. * Gets Vignette weight or intensity of the vignette effect.
  96233. */
  96234. /**
  96235. * Sets Vignette weight or intensity of the vignette effect.
  96236. */
  96237. vignetteWeight: number;
  96238. /**
  96239. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96240. * if vignetteEnabled is set to true.
  96241. */
  96242. /**
  96243. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96244. * if vignetteEnabled is set to true.
  96245. */
  96246. vignetteColor: Color4;
  96247. /**
  96248. * Gets Camera field of view used by the Vignette effect.
  96249. */
  96250. /**
  96251. * Sets Camera field of view used by the Vignette effect.
  96252. */
  96253. vignetteCameraFov: number;
  96254. /**
  96255. * Gets the vignette blend mode allowing different kind of effect.
  96256. */
  96257. /**
  96258. * Sets the vignette blend mode allowing different kind of effect.
  96259. */
  96260. vignetteBlendMode: number;
  96261. /**
  96262. * Gets wether the vignette effect is enabled.
  96263. */
  96264. /**
  96265. * Sets wether the vignette effect is enabled.
  96266. */
  96267. vignetteEnabled: boolean;
  96268. private _fromLinearSpace;
  96269. /**
  96270. * Gets wether the input of the processing is in Gamma or Linear Space.
  96271. */
  96272. /**
  96273. * Sets wether the input of the processing is in Gamma or Linear Space.
  96274. */
  96275. fromLinearSpace: boolean;
  96276. /**
  96277. * Defines cache preventing GC.
  96278. */
  96279. private _defines;
  96280. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96281. /**
  96282. * "ImageProcessingPostProcess"
  96283. * @returns "ImageProcessingPostProcess"
  96284. */
  96285. getClassName(): string;
  96286. protected _updateParameters(): void;
  96287. dispose(camera?: Camera): void;
  96288. }
  96289. }
  96290. declare module BABYLON {
  96291. /**
  96292. * Class containing static functions to help procedurally build meshes
  96293. */
  96294. export class GroundBuilder {
  96295. /**
  96296. * Creates a ground mesh
  96297. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96298. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96300. * @param name defines the name of the mesh
  96301. * @param options defines the options used to create the mesh
  96302. * @param scene defines the hosting scene
  96303. * @returns the ground mesh
  96304. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96305. */
  96306. static CreateGround(name: string, options: {
  96307. width?: number;
  96308. height?: number;
  96309. subdivisions?: number;
  96310. subdivisionsX?: number;
  96311. subdivisionsY?: number;
  96312. updatable?: boolean;
  96313. }, scene: any): Mesh;
  96314. /**
  96315. * Creates a tiled ground mesh
  96316. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96317. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96318. * * 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
  96319. * * 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
  96320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96321. * @param name defines the name of the mesh
  96322. * @param options defines the options used to create the mesh
  96323. * @param scene defines the hosting scene
  96324. * @returns the tiled ground mesh
  96325. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96326. */
  96327. static CreateTiledGround(name: string, options: {
  96328. xmin: number;
  96329. zmin: number;
  96330. xmax: number;
  96331. zmax: number;
  96332. subdivisions?: {
  96333. w: number;
  96334. h: number;
  96335. };
  96336. precision?: {
  96337. w: number;
  96338. h: number;
  96339. };
  96340. updatable?: boolean;
  96341. }, scene: Scene): Mesh;
  96342. /**
  96343. * Creates a ground mesh from a height map
  96344. * * The parameter `url` sets the URL of the height map image resource.
  96345. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96346. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96347. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96348. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96349. * * 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.
  96350. * * 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).
  96351. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96353. * @param name defines the name of the mesh
  96354. * @param url defines the url to the height map
  96355. * @param options defines the options used to create the mesh
  96356. * @param scene defines the hosting scene
  96357. * @returns the ground mesh
  96358. * @see https://doc.babylonjs.com/babylon101/height_map
  96359. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96360. */
  96361. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96362. width?: number;
  96363. height?: number;
  96364. subdivisions?: number;
  96365. minHeight?: number;
  96366. maxHeight?: number;
  96367. colorFilter?: Color3;
  96368. alphaFilter?: number;
  96369. updatable?: boolean;
  96370. onReady?: (mesh: GroundMesh) => void;
  96371. }, scene: Scene): GroundMesh;
  96372. }
  96373. }
  96374. declare module BABYLON {
  96375. /**
  96376. * Class containing static functions to help procedurally build meshes
  96377. */
  96378. export class TorusBuilder {
  96379. /**
  96380. * Creates a torus mesh
  96381. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96382. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96383. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96387. * @param name defines the name of the mesh
  96388. * @param options defines the options used to create the mesh
  96389. * @param scene defines the hosting scene
  96390. * @returns the torus mesh
  96391. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96392. */
  96393. static CreateTorus(name: string, options: {
  96394. diameter?: number;
  96395. thickness?: number;
  96396. tessellation?: number;
  96397. updatable?: boolean;
  96398. sideOrientation?: number;
  96399. frontUVs?: Vector4;
  96400. backUVs?: Vector4;
  96401. }, scene: any): Mesh;
  96402. }
  96403. }
  96404. declare module BABYLON {
  96405. /**
  96406. * Class containing static functions to help procedurally build meshes
  96407. */
  96408. export class CylinderBuilder {
  96409. /**
  96410. * Creates a cylinder or a cone mesh
  96411. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96412. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96413. * * 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.
  96414. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96415. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96416. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96417. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96418. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96419. * * 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).
  96420. * * 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
  96421. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96422. * * 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
  96423. * * 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.
  96424. * * If `enclose` is false, a ring surface is one element.
  96425. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96426. * * 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
  96427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96430. * @param name defines the name of the mesh
  96431. * @param options defines the options used to create the mesh
  96432. * @param scene defines the hosting scene
  96433. * @returns the cylinder mesh
  96434. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96435. */
  96436. static CreateCylinder(name: string, options: {
  96437. height?: number;
  96438. diameterTop?: number;
  96439. diameterBottom?: number;
  96440. diameter?: number;
  96441. tessellation?: number;
  96442. subdivisions?: number;
  96443. arc?: number;
  96444. faceColors?: Color4[];
  96445. faceUV?: Vector4[];
  96446. updatable?: boolean;
  96447. hasRings?: boolean;
  96448. enclose?: boolean;
  96449. sideOrientation?: number;
  96450. frontUVs?: Vector4;
  96451. backUVs?: Vector4;
  96452. }, scene: any): Mesh;
  96453. }
  96454. }
  96455. declare module BABYLON {
  96456. /**
  96457. * Manager for handling gamepads
  96458. */
  96459. export class GamepadManager {
  96460. private _scene?;
  96461. private _babylonGamepads;
  96462. private _oneGamepadConnected;
  96463. /** @hidden */
  96464. _isMonitoring: boolean;
  96465. private _gamepadEventSupported;
  96466. private _gamepadSupport;
  96467. /**
  96468. * observable to be triggered when the gamepad controller has been connected
  96469. */
  96470. onGamepadConnectedObservable: Observable<Gamepad>;
  96471. /**
  96472. * observable to be triggered when the gamepad controller has been disconnected
  96473. */
  96474. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96475. private _onGamepadConnectedEvent;
  96476. private _onGamepadDisconnectedEvent;
  96477. /**
  96478. * Initializes the gamepad manager
  96479. * @param _scene BabylonJS scene
  96480. */
  96481. constructor(_scene?: Scene | undefined);
  96482. /**
  96483. * The gamepads in the game pad manager
  96484. */
  96485. readonly gamepads: Gamepad[];
  96486. /**
  96487. * Get the gamepad controllers based on type
  96488. * @param type The type of gamepad controller
  96489. * @returns Nullable gamepad
  96490. */
  96491. getGamepadByType(type?: number): Nullable<Gamepad>;
  96492. /**
  96493. * Disposes the gamepad manager
  96494. */
  96495. dispose(): void;
  96496. private _addNewGamepad;
  96497. private _startMonitoringGamepads;
  96498. private _stopMonitoringGamepads;
  96499. /** @hidden */
  96500. _checkGamepadsStatus(): void;
  96501. private _updateGamepadObjects;
  96502. }
  96503. }
  96504. declare module BABYLON {
  96505. interface Scene {
  96506. /** @hidden */
  96507. _gamepadManager: Nullable<GamepadManager>;
  96508. /**
  96509. * Gets the gamepad manager associated with the scene
  96510. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96511. */
  96512. gamepadManager: GamepadManager;
  96513. }
  96514. /**
  96515. * Interface representing a free camera inputs manager
  96516. */
  96517. interface FreeCameraInputsManager {
  96518. /**
  96519. * Adds gamepad input support to the FreeCameraInputsManager.
  96520. * @returns the FreeCameraInputsManager
  96521. */
  96522. addGamepad(): FreeCameraInputsManager;
  96523. }
  96524. /**
  96525. * Interface representing an arc rotate camera inputs manager
  96526. */
  96527. interface ArcRotateCameraInputsManager {
  96528. /**
  96529. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96530. * @returns the camera inputs manager
  96531. */
  96532. addGamepad(): ArcRotateCameraInputsManager;
  96533. }
  96534. /**
  96535. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96536. */
  96537. export class GamepadSystemSceneComponent implements ISceneComponent {
  96538. /**
  96539. * The component name helpfull to identify the component in the list of scene components.
  96540. */
  96541. readonly name: string;
  96542. /**
  96543. * The scene the component belongs to.
  96544. */
  96545. scene: Scene;
  96546. /**
  96547. * Creates a new instance of the component for the given scene
  96548. * @param scene Defines the scene to register the component in
  96549. */
  96550. constructor(scene: Scene);
  96551. /**
  96552. * Registers the component in a given scene
  96553. */
  96554. register(): void;
  96555. /**
  96556. * Rebuilds the elements related to this component in case of
  96557. * context lost for instance.
  96558. */
  96559. rebuild(): void;
  96560. /**
  96561. * Disposes the component and the associated ressources
  96562. */
  96563. dispose(): void;
  96564. private _beforeCameraUpdate;
  96565. }
  96566. }
  96567. declare module BABYLON {
  96568. /**
  96569. * Options to modify the vr teleportation behavior.
  96570. */
  96571. export interface VRTeleportationOptions {
  96572. /**
  96573. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96574. */
  96575. floorMeshName?: string;
  96576. /**
  96577. * A list of meshes to be used as the teleportation floor. (default: empty)
  96578. */
  96579. floorMeshes?: Mesh[];
  96580. }
  96581. /**
  96582. * Options to modify the vr experience helper's behavior.
  96583. */
  96584. export interface VRExperienceHelperOptions extends WebVROptions {
  96585. /**
  96586. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96587. */
  96588. createDeviceOrientationCamera?: boolean;
  96589. /**
  96590. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96591. */
  96592. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96593. /**
  96594. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96595. */
  96596. laserToggle?: boolean;
  96597. /**
  96598. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96599. */
  96600. floorMeshes?: Mesh[];
  96601. /**
  96602. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96603. */
  96604. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96605. }
  96606. /**
  96607. * Event containing information after VR has been entered
  96608. */
  96609. export class OnAfterEnteringVRObservableEvent {
  96610. /**
  96611. * If entering vr was successful
  96612. */
  96613. success: boolean;
  96614. }
  96615. /**
  96616. * Helps to quickly add VR support to an existing scene.
  96617. * See http://doc.babylonjs.com/how_to/webvr_helper
  96618. */
  96619. export class VRExperienceHelper {
  96620. /** Options to modify the vr experience helper's behavior. */
  96621. webVROptions: VRExperienceHelperOptions;
  96622. private _scene;
  96623. private _position;
  96624. private _btnVR;
  96625. private _btnVRDisplayed;
  96626. private _webVRsupported;
  96627. private _webVRready;
  96628. private _webVRrequesting;
  96629. private _webVRpresenting;
  96630. private _hasEnteredVR;
  96631. private _fullscreenVRpresenting;
  96632. private _canvas;
  96633. private _webVRCamera;
  96634. private _vrDeviceOrientationCamera;
  96635. private _deviceOrientationCamera;
  96636. private _existingCamera;
  96637. private _onKeyDown;
  96638. private _onVrDisplayPresentChange;
  96639. private _onVRDisplayChanged;
  96640. private _onVRRequestPresentStart;
  96641. private _onVRRequestPresentComplete;
  96642. /**
  96643. * Observable raised right before entering VR.
  96644. */
  96645. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96646. /**
  96647. * Observable raised when entering VR has completed.
  96648. */
  96649. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96650. /**
  96651. * Observable raised when exiting VR.
  96652. */
  96653. onExitingVRObservable: Observable<VRExperienceHelper>;
  96654. /**
  96655. * Observable raised when controller mesh is loaded.
  96656. */
  96657. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96658. /** Return this.onEnteringVRObservable
  96659. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96660. */
  96661. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96662. /** Return this.onExitingVRObservable
  96663. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96664. */
  96665. readonly onExitingVR: Observable<VRExperienceHelper>;
  96666. /** Return this.onControllerMeshLoadedObservable
  96667. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96668. */
  96669. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96670. private _rayLength;
  96671. private _useCustomVRButton;
  96672. private _teleportationRequested;
  96673. private _teleportActive;
  96674. private _floorMeshName;
  96675. private _floorMeshesCollection;
  96676. private _rotationAllowed;
  96677. private _teleportBackwardsVector;
  96678. private _teleportationTarget;
  96679. private _isDefaultTeleportationTarget;
  96680. private _postProcessMove;
  96681. private _teleportationFillColor;
  96682. private _teleportationBorderColor;
  96683. private _rotationAngle;
  96684. private _haloCenter;
  96685. private _cameraGazer;
  96686. private _padSensibilityUp;
  96687. private _padSensibilityDown;
  96688. private _leftController;
  96689. private _rightController;
  96690. /**
  96691. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96692. */
  96693. onNewMeshSelected: Observable<AbstractMesh>;
  96694. /**
  96695. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96696. */
  96697. onNewMeshPicked: Observable<PickingInfo>;
  96698. private _circleEase;
  96699. /**
  96700. * Observable raised before camera teleportation
  96701. */
  96702. onBeforeCameraTeleport: Observable<Vector3>;
  96703. /**
  96704. * Observable raised after camera teleportation
  96705. */
  96706. onAfterCameraTeleport: Observable<Vector3>;
  96707. /**
  96708. * Observable raised when current selected mesh gets unselected
  96709. */
  96710. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96711. private _raySelectionPredicate;
  96712. /**
  96713. * To be optionaly changed by user to define custom ray selection
  96714. */
  96715. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96716. /**
  96717. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96718. */
  96719. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96720. /**
  96721. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96722. */
  96723. teleportationEnabled: boolean;
  96724. private _defaultHeight;
  96725. private _teleportationInitialized;
  96726. private _interactionsEnabled;
  96727. private _interactionsRequested;
  96728. private _displayGaze;
  96729. private _displayLaserPointer;
  96730. /**
  96731. * The mesh used to display where the user is going to teleport.
  96732. */
  96733. /**
  96734. * Sets the mesh to be used to display where the user is going to teleport.
  96735. */
  96736. teleportationTarget: Mesh;
  96737. /**
  96738. * 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
  96739. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96740. * See http://doc.babylonjs.com/resources/baking_transformations
  96741. */
  96742. gazeTrackerMesh: Mesh;
  96743. /**
  96744. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96745. */
  96746. updateGazeTrackerScale: boolean;
  96747. /**
  96748. * If the gaze trackers color should be updated when selecting meshes
  96749. */
  96750. updateGazeTrackerColor: boolean;
  96751. /**
  96752. * The gaze tracking mesh corresponding to the left controller
  96753. */
  96754. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96755. /**
  96756. * The gaze tracking mesh corresponding to the right controller
  96757. */
  96758. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96759. /**
  96760. * If the ray of the gaze should be displayed.
  96761. */
  96762. /**
  96763. * Sets if the ray of the gaze should be displayed.
  96764. */
  96765. displayGaze: boolean;
  96766. /**
  96767. * If the ray of the LaserPointer should be displayed.
  96768. */
  96769. /**
  96770. * Sets if the ray of the LaserPointer should be displayed.
  96771. */
  96772. displayLaserPointer: boolean;
  96773. /**
  96774. * The deviceOrientationCamera used as the camera when not in VR.
  96775. */
  96776. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96777. /**
  96778. * Based on the current WebVR support, returns the current VR camera used.
  96779. */
  96780. readonly currentVRCamera: Nullable<Camera>;
  96781. /**
  96782. * The webVRCamera which is used when in VR.
  96783. */
  96784. readonly webVRCamera: WebVRFreeCamera;
  96785. /**
  96786. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96787. */
  96788. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96789. private readonly _teleportationRequestInitiated;
  96790. /**
  96791. * Defines wether or not Pointer lock should be requested when switching to
  96792. * full screen.
  96793. */
  96794. requestPointerLockOnFullScreen: boolean;
  96795. /**
  96796. * Instantiates a VRExperienceHelper.
  96797. * Helps to quickly add VR support to an existing scene.
  96798. * @param scene The scene the VRExperienceHelper belongs to.
  96799. * @param webVROptions Options to modify the vr experience helper's behavior.
  96800. */
  96801. constructor(scene: Scene,
  96802. /** Options to modify the vr experience helper's behavior. */
  96803. webVROptions?: VRExperienceHelperOptions);
  96804. private _onDefaultMeshLoaded;
  96805. private _onResize;
  96806. private _onFullscreenChange;
  96807. /**
  96808. * Gets a value indicating if we are currently in VR mode.
  96809. */
  96810. readonly isInVRMode: boolean;
  96811. private onVrDisplayPresentChange;
  96812. private onVRDisplayChanged;
  96813. private moveButtonToBottomRight;
  96814. private displayVRButton;
  96815. private updateButtonVisibility;
  96816. private _cachedAngularSensibility;
  96817. /**
  96818. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96819. * Otherwise, will use the fullscreen API.
  96820. */
  96821. enterVR(): void;
  96822. /**
  96823. * Attempt to exit VR, or fullscreen.
  96824. */
  96825. exitVR(): void;
  96826. /**
  96827. * The position of the vr experience helper.
  96828. */
  96829. /**
  96830. * Sets the position of the vr experience helper.
  96831. */
  96832. position: Vector3;
  96833. /**
  96834. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96835. */
  96836. enableInteractions(): void;
  96837. private readonly _noControllerIsActive;
  96838. private beforeRender;
  96839. private _isTeleportationFloor;
  96840. /**
  96841. * Adds a floor mesh to be used for teleportation.
  96842. * @param floorMesh the mesh to be used for teleportation.
  96843. */
  96844. addFloorMesh(floorMesh: Mesh): void;
  96845. /**
  96846. * Removes a floor mesh from being used for teleportation.
  96847. * @param floorMesh the mesh to be removed.
  96848. */
  96849. removeFloorMesh(floorMesh: Mesh): void;
  96850. /**
  96851. * Enables interactions and teleportation using the VR controllers and gaze.
  96852. * @param vrTeleportationOptions options to modify teleportation behavior.
  96853. */
  96854. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96855. private _onNewGamepadConnected;
  96856. private _tryEnableInteractionOnController;
  96857. private _onNewGamepadDisconnected;
  96858. private _enableInteractionOnController;
  96859. private _checkTeleportWithRay;
  96860. private _checkRotate;
  96861. private _checkTeleportBackwards;
  96862. private _enableTeleportationOnController;
  96863. private _createTeleportationCircles;
  96864. private _displayTeleportationTarget;
  96865. private _hideTeleportationTarget;
  96866. private _rotateCamera;
  96867. private _moveTeleportationSelectorTo;
  96868. private _workingVector;
  96869. private _workingQuaternion;
  96870. private _workingMatrix;
  96871. /**
  96872. * Teleports the users feet to the desired location
  96873. * @param location The location where the user's feet should be placed
  96874. */
  96875. teleportCamera(location: Vector3): void;
  96876. private _convertNormalToDirectionOfRay;
  96877. private _castRayAndSelectObject;
  96878. private _notifySelectedMeshUnselected;
  96879. /**
  96880. * Sets the color of the laser ray from the vr controllers.
  96881. * @param color new color for the ray.
  96882. */
  96883. changeLaserColor(color: Color3): void;
  96884. /**
  96885. * Sets the color of the ray from the vr headsets gaze.
  96886. * @param color new color for the ray.
  96887. */
  96888. changeGazeColor(color: Color3): void;
  96889. /**
  96890. * Exits VR and disposes of the vr experience helper
  96891. */
  96892. dispose(): void;
  96893. /**
  96894. * Gets the name of the VRExperienceHelper class
  96895. * @returns "VRExperienceHelper"
  96896. */
  96897. getClassName(): string;
  96898. }
  96899. }
  96900. declare module BABYLON {
  96901. /**
  96902. * Manages an XRSession
  96903. * @see https://doc.babylonjs.com/how_to/webxr
  96904. */
  96905. export class WebXRSessionManager implements IDisposable {
  96906. private scene;
  96907. /**
  96908. * Fires every time a new xrFrame arrives which can be used to update the camera
  96909. */
  96910. onXRFrameObservable: Observable<any>;
  96911. /**
  96912. * Fires when the xr session is ended either by the device or manually done
  96913. */
  96914. onXRSessionEnded: Observable<any>;
  96915. /** @hidden */
  96916. _xrSession: XRSession;
  96917. /** @hidden */
  96918. _frameOfReference: XRFrameOfReference;
  96919. /** @hidden */
  96920. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96921. /** @hidden */
  96922. _currentXRFrame: Nullable<XRFrame>;
  96923. private _xrNavigator;
  96924. private _xrDevice;
  96925. private _tmpMatrix;
  96926. /**
  96927. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96928. * @param scene The scene which the session should be created for
  96929. */
  96930. constructor(scene: Scene);
  96931. /**
  96932. * Initializes the manager
  96933. * After initialization enterXR can be called to start an XR session
  96934. * @returns Promise which resolves after it is initialized
  96935. */
  96936. initializeAsync(): Promise<void>;
  96937. /**
  96938. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96939. * @param sessionCreationOptions xr options to create the session with
  96940. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96941. * @returns Promise which resolves after it enters XR
  96942. */
  96943. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96944. /**
  96945. * Stops the xrSession and restores the renderloop
  96946. * @returns Promise which resolves after it exits XR
  96947. */
  96948. exitXRAsync(): Promise<void>;
  96949. /**
  96950. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96951. * @param ray ray to cast into the environment
  96952. * @returns Promise which resolves with a collision point in the environment if it exists
  96953. */
  96954. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96955. /**
  96956. * Checks if a session would be supported for the creation options specified
  96957. * @param options creation options to check if they are supported
  96958. * @returns true if supported
  96959. */
  96960. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96961. /**
  96962. * @hidden
  96963. * Converts the render layer of xrSession to a render target
  96964. * @param session session to create render target for
  96965. * @param scene scene the new render target should be created for
  96966. */
  96967. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96968. /**
  96969. * Disposes of the session manager
  96970. */
  96971. dispose(): void;
  96972. }
  96973. }
  96974. declare module BABYLON {
  96975. /**
  96976. * WebXR Camera which holds the views for the xrSession
  96977. * @see https://doc.babylonjs.com/how_to/webxr
  96978. */
  96979. export class WebXRCamera extends FreeCamera {
  96980. private static _TmpMatrix;
  96981. /**
  96982. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96983. * @param name the name of the camera
  96984. * @param scene the scene to add the camera to
  96985. */
  96986. constructor(name: string, scene: Scene);
  96987. private _updateNumberOfRigCameras;
  96988. /** @hidden */
  96989. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96990. /**
  96991. * Updates the cameras position from the current pose information of the XR session
  96992. * @param xrSessionManager the session containing pose information
  96993. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96994. */
  96995. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96996. }
  96997. }
  96998. declare module BABYLON {
  96999. /**
  97000. * States of the webXR experience
  97001. */
  97002. export enum WebXRState {
  97003. /**
  97004. * Transitioning to being in XR mode
  97005. */
  97006. ENTERING_XR = 0,
  97007. /**
  97008. * Transitioning to non XR mode
  97009. */
  97010. EXITING_XR = 1,
  97011. /**
  97012. * In XR mode and presenting
  97013. */
  97014. IN_XR = 2,
  97015. /**
  97016. * Not entered XR mode
  97017. */
  97018. NOT_IN_XR = 3
  97019. }
  97020. /**
  97021. * Helper class used to enable XR
  97022. * @see https://doc.babylonjs.com/how_to/webxr
  97023. */
  97024. export class WebXRExperienceHelper implements IDisposable {
  97025. private scene;
  97026. /**
  97027. * 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
  97028. */
  97029. container: AbstractMesh;
  97030. /**
  97031. * Camera used to render xr content
  97032. */
  97033. camera: WebXRCamera;
  97034. /**
  97035. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  97036. */
  97037. state: WebXRState;
  97038. private _setState;
  97039. private static _TmpVector;
  97040. /**
  97041. * Fires when the state of the experience helper has changed
  97042. */
  97043. onStateChangedObservable: Observable<WebXRState>;
  97044. /** @hidden */
  97045. _sessionManager: WebXRSessionManager;
  97046. private _nonVRCamera;
  97047. private _originalSceneAutoClear;
  97048. private _supported;
  97049. /**
  97050. * Creates the experience helper
  97051. * @param scene the scene to attach the experience helper to
  97052. * @returns a promise for the experience helper
  97053. */
  97054. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  97055. /**
  97056. * Creates a WebXRExperienceHelper
  97057. * @param scene The scene the helper should be created in
  97058. */
  97059. private constructor();
  97060. /**
  97061. * Exits XR mode and returns the scene to its original state
  97062. * @returns promise that resolves after xr mode has exited
  97063. */
  97064. exitXRAsync(): Promise<void>;
  97065. /**
  97066. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  97067. * @param sessionCreationOptions options for the XR session
  97068. * @param frameOfReference frame of reference of the XR session
  97069. * @returns promise that resolves after xr mode has entered
  97070. */
  97071. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  97072. /**
  97073. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97074. * @param ray ray to cast into the environment
  97075. * @returns Promise which resolves with a collision point in the environment if it exists
  97076. */
  97077. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97078. /**
  97079. * Updates the global position of the camera by moving the camera's container
  97080. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  97081. * @param position The desired global position of the camera
  97082. */
  97083. setPositionOfCameraUsingContainer(position: Vector3): void;
  97084. /**
  97085. * Rotates the xr camera by rotating the camera's container around the camera's position
  97086. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  97087. * @param rotation the desired quaternion rotation to apply to the camera
  97088. */
  97089. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  97090. /**
  97091. * Checks if the creation options are supported by the xr session
  97092. * @param options creation options
  97093. * @returns true if supported
  97094. */
  97095. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97096. /**
  97097. * Disposes of the experience helper
  97098. */
  97099. dispose(): void;
  97100. }
  97101. }
  97102. declare module BABYLON {
  97103. /**
  97104. * Button which can be used to enter a different mode of XR
  97105. */
  97106. export class WebXREnterExitUIButton {
  97107. /** button element */
  97108. element: HTMLElement;
  97109. /** XR initialization options for the button */
  97110. initializationOptions: XRSessionCreationOptions;
  97111. /**
  97112. * Creates a WebXREnterExitUIButton
  97113. * @param element button element
  97114. * @param initializationOptions XR initialization options for the button
  97115. */
  97116. constructor(
  97117. /** button element */
  97118. element: HTMLElement,
  97119. /** XR initialization options for the button */
  97120. initializationOptions: XRSessionCreationOptions);
  97121. /**
  97122. * Overwritable function which can be used to update the button's visuals when the state changes
  97123. * @param activeButton the current active button in the UI
  97124. */
  97125. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  97126. }
  97127. /**
  97128. * Options to create the webXR UI
  97129. */
  97130. export class WebXREnterExitUIOptions {
  97131. /**
  97132. * Context to enter xr with
  97133. */
  97134. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  97135. /**
  97136. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  97137. */
  97138. customButtons?: Array<WebXREnterExitUIButton>;
  97139. }
  97140. /**
  97141. * UI to allow the user to enter/exit XR mode
  97142. */
  97143. export class WebXREnterExitUI implements IDisposable {
  97144. private scene;
  97145. private _overlay;
  97146. private _buttons;
  97147. private _activeButton;
  97148. /**
  97149. * Fired every time the active button is changed.
  97150. *
  97151. * When xr is entered via a button that launches xr that button will be the callback parameter
  97152. *
  97153. * When exiting xr the callback parameter will be null)
  97154. */
  97155. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  97156. /**
  97157. * Creates UI to allow the user to enter/exit XR mode
  97158. * @param scene the scene to add the ui to
  97159. * @param helper the xr experience helper to enter/exit xr with
  97160. * @param options options to configure the UI
  97161. * @returns the created ui
  97162. */
  97163. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  97164. private constructor();
  97165. private _updateButtons;
  97166. /**
  97167. * Disposes of the object
  97168. */
  97169. dispose(): void;
  97170. }
  97171. }
  97172. declare module BABYLON {
  97173. /**
  97174. * Represents an XR input
  97175. */
  97176. export class WebXRController {
  97177. /**
  97178. * 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
  97179. */
  97180. grip?: AbstractMesh;
  97181. /**
  97182. * Pointer which can be used to select objects or attach a visible laser to
  97183. */
  97184. pointer: AbstractMesh;
  97185. /**
  97186. * Creates the controller
  97187. * @see https://doc.babylonjs.com/how_to/webxr
  97188. * @param scene the scene which the controller should be associated to
  97189. */
  97190. constructor(scene: Scene);
  97191. /**
  97192. * Disposes of the object
  97193. */
  97194. dispose(): void;
  97195. }
  97196. /**
  97197. * XR input used to track XR inputs such as controllers/rays
  97198. */
  97199. export class WebXRInput implements IDisposable {
  97200. private helper;
  97201. /**
  97202. * XR controllers being tracked
  97203. */
  97204. controllers: Array<WebXRController>;
  97205. private _tmpMatrix;
  97206. private _frameObserver;
  97207. /**
  97208. * Initializes the WebXRInput
  97209. * @param helper experience helper which the input should be created for
  97210. */
  97211. constructor(helper: WebXRExperienceHelper);
  97212. /**
  97213. * Disposes of the object
  97214. */
  97215. dispose(): void;
  97216. }
  97217. }
  97218. declare module BABYLON {
  97219. /**
  97220. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  97221. */
  97222. export class WebXRManagedOutputCanvas implements IDisposable {
  97223. private _canvas;
  97224. /**
  97225. * xrpresent context of the canvas which can be used to display/mirror xr content
  97226. */
  97227. canvasContext: Nullable<WebGLRenderingContext>;
  97228. /**
  97229. * Initializes the canvas to be added/removed upon entering/exiting xr
  97230. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97231. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97232. */
  97233. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97234. /**
  97235. * Disposes of the object
  97236. */
  97237. dispose(): void;
  97238. private _setManagedOutputCanvas;
  97239. private _addCanvas;
  97240. private _removeCanvas;
  97241. }
  97242. }
  97243. declare module BABYLON {
  97244. /**
  97245. * Contains an array of blocks representing the octree
  97246. */
  97247. export interface IOctreeContainer<T> {
  97248. /**
  97249. * Blocks within the octree
  97250. */
  97251. blocks: Array<OctreeBlock<T>>;
  97252. }
  97253. /**
  97254. * Class used to store a cell in an octree
  97255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97256. */
  97257. export class OctreeBlock<T> {
  97258. /**
  97259. * Gets the content of the current block
  97260. */
  97261. entries: T[];
  97262. /**
  97263. * Gets the list of block children
  97264. */
  97265. blocks: Array<OctreeBlock<T>>;
  97266. private _depth;
  97267. private _maxDepth;
  97268. private _capacity;
  97269. private _minPoint;
  97270. private _maxPoint;
  97271. private _boundingVectors;
  97272. private _creationFunc;
  97273. /**
  97274. * Creates a new block
  97275. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97276. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97277. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97278. * @param depth defines the current depth of this block in the octree
  97279. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97280. * @param creationFunc defines a callback to call when an element is added to the block
  97281. */
  97282. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97283. /**
  97284. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97285. */
  97286. readonly capacity: number;
  97287. /**
  97288. * Gets the minimum vector (in world space) of the block's bounding box
  97289. */
  97290. readonly minPoint: Vector3;
  97291. /**
  97292. * Gets the maximum vector (in world space) of the block's bounding box
  97293. */
  97294. readonly maxPoint: Vector3;
  97295. /**
  97296. * Add a new element to this block
  97297. * @param entry defines the element to add
  97298. */
  97299. addEntry(entry: T): void;
  97300. /**
  97301. * Remove an element from this block
  97302. * @param entry defines the element to remove
  97303. */
  97304. removeEntry(entry: T): void;
  97305. /**
  97306. * Add an array of elements to this block
  97307. * @param entries defines the array of elements to add
  97308. */
  97309. addEntries(entries: T[]): void;
  97310. /**
  97311. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97312. * @param frustumPlanes defines the frustum planes to test
  97313. * @param selection defines the array to store current content if selection is positive
  97314. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97315. */
  97316. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97317. /**
  97318. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97319. * @param sphereCenter defines the bounding sphere center
  97320. * @param sphereRadius defines the bounding sphere radius
  97321. * @param selection defines the array to store current content if selection is positive
  97322. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97323. */
  97324. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97325. /**
  97326. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97327. * @param ray defines the ray to test with
  97328. * @param selection defines the array to store current content if selection is positive
  97329. */
  97330. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97331. /**
  97332. * Subdivide the content into child blocks (this block will then be empty)
  97333. */
  97334. createInnerBlocks(): void;
  97335. /**
  97336. * @hidden
  97337. */
  97338. 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;
  97339. }
  97340. }
  97341. declare module BABYLON {
  97342. /**
  97343. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97344. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97345. */
  97346. export class Octree<T> {
  97347. /** 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.) */
  97348. maxDepth: number;
  97349. /**
  97350. * Blocks within the octree containing objects
  97351. */
  97352. blocks: Array<OctreeBlock<T>>;
  97353. /**
  97354. * Content stored in the octree
  97355. */
  97356. dynamicContent: T[];
  97357. private _maxBlockCapacity;
  97358. private _selectionContent;
  97359. private _creationFunc;
  97360. /**
  97361. * Creates a octree
  97362. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97363. * @param creationFunc function to be used to instatiate the octree
  97364. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97365. * @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.)
  97366. */
  97367. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97368. /** 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.) */
  97369. maxDepth?: number);
  97370. /**
  97371. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97372. * @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);
  97373. * @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);
  97374. * @param entries meshes to be added to the octree blocks
  97375. */
  97376. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97377. /**
  97378. * Adds a mesh to the octree
  97379. * @param entry Mesh to add to the octree
  97380. */
  97381. addMesh(entry: T): void;
  97382. /**
  97383. * Remove an element from the octree
  97384. * @param entry defines the element to remove
  97385. */
  97386. removeMesh(entry: T): void;
  97387. /**
  97388. * Selects an array of meshes within the frustum
  97389. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97390. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97391. * @returns array of meshes within the frustum
  97392. */
  97393. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97394. /**
  97395. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97396. * @param sphereCenter defines the bounding sphere center
  97397. * @param sphereRadius defines the bounding sphere radius
  97398. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97399. * @returns an array of objects that intersect the sphere
  97400. */
  97401. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97402. /**
  97403. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97404. * @param ray defines the ray to test with
  97405. * @returns array of intersected objects
  97406. */
  97407. intersectsRay(ray: Ray): SmartArray<T>;
  97408. /**
  97409. * Adds a mesh into the octree block if it intersects the block
  97410. */
  97411. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97412. /**
  97413. * Adds a submesh into the octree block if it intersects the block
  97414. */
  97415. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97416. }
  97417. }
  97418. declare module BABYLON {
  97419. interface Scene {
  97420. /**
  97421. * @hidden
  97422. * Backing Filed
  97423. */
  97424. _selectionOctree: Octree<AbstractMesh>;
  97425. /**
  97426. * Gets the octree used to boost mesh selection (picking)
  97427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97428. */
  97429. selectionOctree: Octree<AbstractMesh>;
  97430. /**
  97431. * Creates or updates the octree used to boost selection (picking)
  97432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97433. * @param maxCapacity defines the maximum capacity per leaf
  97434. * @param maxDepth defines the maximum depth of the octree
  97435. * @returns an octree of AbstractMesh
  97436. */
  97437. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97438. }
  97439. interface AbstractMesh {
  97440. /**
  97441. * @hidden
  97442. * Backing Field
  97443. */
  97444. _submeshesOctree: Octree<SubMesh>;
  97445. /**
  97446. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97447. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97448. * @param maxCapacity defines the maximum size of each block (64 by default)
  97449. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97450. * @returns the new octree
  97451. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97453. */
  97454. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97455. }
  97456. /**
  97457. * Defines the octree scene component responsible to manage any octrees
  97458. * in a given scene.
  97459. */
  97460. export class OctreeSceneComponent {
  97461. /**
  97462. * The component name helpfull to identify the component in the list of scene components.
  97463. */
  97464. readonly name: string;
  97465. /**
  97466. * The scene the component belongs to.
  97467. */
  97468. scene: Scene;
  97469. /**
  97470. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97471. */
  97472. readonly checksIsEnabled: boolean;
  97473. /**
  97474. * Creates a new instance of the component for the given scene
  97475. * @param scene Defines the scene to register the component in
  97476. */
  97477. constructor(scene: Scene);
  97478. /**
  97479. * Registers the component in a given scene
  97480. */
  97481. register(): void;
  97482. /**
  97483. * Return the list of active meshes
  97484. * @returns the list of active meshes
  97485. */
  97486. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97487. /**
  97488. * Return the list of active sub meshes
  97489. * @param mesh The mesh to get the candidates sub meshes from
  97490. * @returns the list of active sub meshes
  97491. */
  97492. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97493. private _tempRay;
  97494. /**
  97495. * Return the list of sub meshes intersecting with a given local ray
  97496. * @param mesh defines the mesh to find the submesh for
  97497. * @param localRay defines the ray in local space
  97498. * @returns the list of intersecting sub meshes
  97499. */
  97500. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97501. /**
  97502. * Return the list of sub meshes colliding with a collider
  97503. * @param mesh defines the mesh to find the submesh for
  97504. * @param collider defines the collider to evaluate the collision against
  97505. * @returns the list of colliding sub meshes
  97506. */
  97507. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97508. /**
  97509. * Rebuilds the elements related to this component in case of
  97510. * context lost for instance.
  97511. */
  97512. rebuild(): void;
  97513. /**
  97514. * Disposes the component and the associated ressources.
  97515. */
  97516. dispose(): void;
  97517. }
  97518. }
  97519. declare module BABYLON {
  97520. /**
  97521. * Class containing static functions to help procedurally build meshes
  97522. */
  97523. export class LinesBuilder {
  97524. /**
  97525. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97526. * * 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
  97527. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97528. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97529. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97530. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97531. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97532. * * 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
  97533. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97536. * @param name defines the name of the new line system
  97537. * @param options defines the options used to create the line system
  97538. * @param scene defines the hosting scene
  97539. * @returns a new line system mesh
  97540. */
  97541. static CreateLineSystem(name: string, options: {
  97542. lines: Vector3[][];
  97543. updatable?: boolean;
  97544. instance?: Nullable<LinesMesh>;
  97545. colors?: Nullable<Color4[][]>;
  97546. useVertexAlpha?: boolean;
  97547. }, scene: Nullable<Scene>): LinesMesh;
  97548. /**
  97549. * Creates a line mesh
  97550. * 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
  97551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97552. * * The parameter `points` is an array successive Vector3
  97553. * * 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
  97554. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97555. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97556. * * When updating an instance, remember that only point positions can change, not the number of points
  97557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97559. * @param name defines the name of the new line system
  97560. * @param options defines the options used to create the line system
  97561. * @param scene defines the hosting scene
  97562. * @returns a new line mesh
  97563. */
  97564. static CreateLines(name: string, options: {
  97565. points: Vector3[];
  97566. updatable?: boolean;
  97567. instance?: Nullable<LinesMesh>;
  97568. colors?: Color4[];
  97569. useVertexAlpha?: boolean;
  97570. }, scene?: Nullable<Scene>): LinesMesh;
  97571. /**
  97572. * Creates a dashed line mesh
  97573. * * 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
  97574. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97575. * * The parameter `points` is an array successive Vector3
  97576. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97577. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97578. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97579. * * 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
  97580. * * When updating an instance, remember that only point positions can change, not the number of points
  97581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97582. * @param name defines the name of the mesh
  97583. * @param options defines the options used to create the mesh
  97584. * @param scene defines the hosting scene
  97585. * @returns the dashed line mesh
  97586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97587. */
  97588. static CreateDashedLines(name: string, options: {
  97589. points: Vector3[];
  97590. dashSize?: number;
  97591. gapSize?: number;
  97592. dashNb?: number;
  97593. updatable?: boolean;
  97594. instance?: LinesMesh;
  97595. }, scene?: Nullable<Scene>): LinesMesh;
  97596. }
  97597. }
  97598. declare module BABYLON {
  97599. /**
  97600. * Renders a layer on top of an existing scene
  97601. */
  97602. export class UtilityLayerRenderer implements IDisposable {
  97603. /** the original scene that will be rendered on top of */
  97604. originalScene: Scene;
  97605. private _pointerCaptures;
  97606. private _lastPointerEvents;
  97607. private static _DefaultUtilityLayer;
  97608. private static _DefaultKeepDepthUtilityLayer;
  97609. /**
  97610. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97611. */
  97612. pickUtilitySceneFirst: boolean;
  97613. /**
  97614. * 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)
  97615. */
  97616. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97617. /**
  97618. * 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)
  97619. */
  97620. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97621. /**
  97622. * The scene that is rendered on top of the original scene
  97623. */
  97624. utilityLayerScene: Scene;
  97625. /**
  97626. * If the utility layer should automatically be rendered on top of existing scene
  97627. */
  97628. shouldRender: boolean;
  97629. /**
  97630. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97631. */
  97632. onlyCheckPointerDownEvents: boolean;
  97633. /**
  97634. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97635. */
  97636. processAllEvents: boolean;
  97637. /**
  97638. * Observable raised when the pointer move from the utility layer scene to the main scene
  97639. */
  97640. onPointerOutObservable: Observable<number>;
  97641. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97642. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97643. private _afterRenderObserver;
  97644. private _sceneDisposeObserver;
  97645. private _originalPointerObserver;
  97646. /**
  97647. * Instantiates a UtilityLayerRenderer
  97648. * @param originalScene the original scene that will be rendered on top of
  97649. * @param handleEvents boolean indicating if the utility layer should handle events
  97650. */
  97651. constructor(
  97652. /** the original scene that will be rendered on top of */
  97653. originalScene: Scene, handleEvents?: boolean);
  97654. private _notifyObservers;
  97655. /**
  97656. * Renders the utility layers scene on top of the original scene
  97657. */
  97658. render(): void;
  97659. /**
  97660. * Disposes of the renderer
  97661. */
  97662. dispose(): void;
  97663. private _updateCamera;
  97664. }
  97665. }
  97666. declare module BABYLON {
  97667. /**
  97668. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97669. */
  97670. export class Gizmo implements IDisposable {
  97671. /** The utility layer the gizmo will be added to */
  97672. gizmoLayer: UtilityLayerRenderer;
  97673. /**
  97674. * The root mesh of the gizmo
  97675. */
  97676. _rootMesh: Mesh;
  97677. private _attachedMesh;
  97678. /**
  97679. * Ratio for the scale of the gizmo (Default: 1)
  97680. */
  97681. scaleRatio: number;
  97682. private _tmpMatrix;
  97683. /**
  97684. * If a custom mesh has been set (Default: false)
  97685. */
  97686. protected _customMeshSet: boolean;
  97687. /**
  97688. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97689. * * When set, interactions will be enabled
  97690. */
  97691. attachedMesh: Nullable<AbstractMesh>;
  97692. /**
  97693. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97694. * @param mesh The mesh to replace the default mesh of the gizmo
  97695. */
  97696. setCustomMesh(mesh: Mesh): void;
  97697. /**
  97698. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97699. */
  97700. updateGizmoRotationToMatchAttachedMesh: boolean;
  97701. /**
  97702. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97703. */
  97704. updateGizmoPositionToMatchAttachedMesh: boolean;
  97705. /**
  97706. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97707. */
  97708. protected _updateScale: boolean;
  97709. protected _interactionsEnabled: boolean;
  97710. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97711. private _beforeRenderObserver;
  97712. /**
  97713. * Creates a gizmo
  97714. * @param gizmoLayer The utility layer the gizmo will be added to
  97715. */
  97716. constructor(
  97717. /** The utility layer the gizmo will be added to */
  97718. gizmoLayer?: UtilityLayerRenderer);
  97719. private _tempVector;
  97720. /**
  97721. * @hidden
  97722. * Updates the gizmo to match the attached mesh's position/rotation
  97723. */
  97724. protected _update(): void;
  97725. /**
  97726. * Disposes of the gizmo
  97727. */
  97728. dispose(): void;
  97729. }
  97730. }
  97731. declare module BABYLON {
  97732. /**
  97733. * Single axis drag gizmo
  97734. */
  97735. export class AxisDragGizmo extends Gizmo {
  97736. /**
  97737. * Drag behavior responsible for the gizmos dragging interactions
  97738. */
  97739. dragBehavior: PointerDragBehavior;
  97740. private _pointerObserver;
  97741. /**
  97742. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97743. */
  97744. snapDistance: number;
  97745. /**
  97746. * Event that fires each time the gizmo snaps to a new location.
  97747. * * snapDistance is the the change in distance
  97748. */
  97749. onSnapObservable: Observable<{
  97750. snapDistance: number;
  97751. }>;
  97752. /** @hidden */
  97753. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97754. /** @hidden */
  97755. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97756. /**
  97757. * Creates an AxisDragGizmo
  97758. * @param gizmoLayer The utility layer the gizmo will be added to
  97759. * @param dragAxis The axis which the gizmo will be able to drag on
  97760. * @param color The color of the gizmo
  97761. */
  97762. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97763. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97764. /**
  97765. * Disposes of the gizmo
  97766. */
  97767. dispose(): void;
  97768. }
  97769. }
  97770. declare module BABYLON.Debug {
  97771. /**
  97772. * The Axes viewer will show 3 axes in a specific point in space
  97773. */
  97774. export class AxesViewer {
  97775. private _xAxis;
  97776. private _yAxis;
  97777. private _zAxis;
  97778. private _scaleLinesFactor;
  97779. private _instanced;
  97780. /**
  97781. * Gets the hosting scene
  97782. */
  97783. scene: Scene;
  97784. /**
  97785. * Gets or sets a number used to scale line length
  97786. */
  97787. scaleLines: number;
  97788. /** Gets the node hierarchy used to render x-axis */
  97789. readonly xAxis: TransformNode;
  97790. /** Gets the node hierarchy used to render y-axis */
  97791. readonly yAxis: TransformNode;
  97792. /** Gets the node hierarchy used to render z-axis */
  97793. readonly zAxis: TransformNode;
  97794. /**
  97795. * Creates a new AxesViewer
  97796. * @param scene defines the hosting scene
  97797. * @param scaleLines defines a number used to scale line length (1 by default)
  97798. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97799. * @param xAxis defines the node hierarchy used to render the x-axis
  97800. * @param yAxis defines the node hierarchy used to render the y-axis
  97801. * @param zAxis defines the node hierarchy used to render the z-axis
  97802. */
  97803. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97804. /**
  97805. * Force the viewer to update
  97806. * @param position defines the position of the viewer
  97807. * @param xaxis defines the x axis of the viewer
  97808. * @param yaxis defines the y axis of the viewer
  97809. * @param zaxis defines the z axis of the viewer
  97810. */
  97811. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97812. /**
  97813. * Creates an instance of this axes viewer.
  97814. * @returns a new axes viewer with instanced meshes
  97815. */
  97816. createInstance(): AxesViewer;
  97817. /** Releases resources */
  97818. dispose(): void;
  97819. private static _SetRenderingGroupId;
  97820. }
  97821. }
  97822. declare module BABYLON.Debug {
  97823. /**
  97824. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97825. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97826. */
  97827. export class BoneAxesViewer extends AxesViewer {
  97828. /**
  97829. * Gets or sets the target mesh where to display the axes viewer
  97830. */
  97831. mesh: Nullable<Mesh>;
  97832. /**
  97833. * Gets or sets the target bone where to display the axes viewer
  97834. */
  97835. bone: Nullable<Bone>;
  97836. /** Gets current position */
  97837. pos: Vector3;
  97838. /** Gets direction of X axis */
  97839. xaxis: Vector3;
  97840. /** Gets direction of Y axis */
  97841. yaxis: Vector3;
  97842. /** Gets direction of Z axis */
  97843. zaxis: Vector3;
  97844. /**
  97845. * Creates a new BoneAxesViewer
  97846. * @param scene defines the hosting scene
  97847. * @param bone defines the target bone
  97848. * @param mesh defines the target mesh
  97849. * @param scaleLines defines a scaling factor for line length (1 by default)
  97850. */
  97851. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97852. /**
  97853. * Force the viewer to update
  97854. */
  97855. update(): void;
  97856. /** Releases resources */
  97857. dispose(): void;
  97858. }
  97859. }
  97860. declare module BABYLON {
  97861. /**
  97862. * Interface used to define scene explorer extensibility option
  97863. */
  97864. export interface IExplorerExtensibilityOption {
  97865. /**
  97866. * Define the option label
  97867. */
  97868. label: string;
  97869. /**
  97870. * Defines the action to execute on click
  97871. */
  97872. action: (entity: any) => void;
  97873. }
  97874. /**
  97875. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97876. */
  97877. export interface IExplorerExtensibilityGroup {
  97878. /**
  97879. * Defines a predicate to test if a given type mut be extended
  97880. */
  97881. predicate: (entity: any) => boolean;
  97882. /**
  97883. * Gets the list of options added to a type
  97884. */
  97885. entries: IExplorerExtensibilityOption[];
  97886. }
  97887. /**
  97888. * Interface used to define the options to use to create the Inspector
  97889. */
  97890. export interface IInspectorOptions {
  97891. /**
  97892. * Display in overlay mode (default: false)
  97893. */
  97894. overlay?: boolean;
  97895. /**
  97896. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97897. */
  97898. globalRoot?: HTMLElement;
  97899. /**
  97900. * Display the Scene explorer
  97901. */
  97902. showExplorer?: boolean;
  97903. /**
  97904. * Display the property inspector
  97905. */
  97906. showInspector?: boolean;
  97907. /**
  97908. * Display in embed mode (both panes on the right)
  97909. */
  97910. embedMode?: boolean;
  97911. /**
  97912. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97913. */
  97914. handleResize?: boolean;
  97915. /**
  97916. * Allow the panes to popup (default: true)
  97917. */
  97918. enablePopup?: boolean;
  97919. /**
  97920. * Allow the panes to be closed by users (default: true)
  97921. */
  97922. enableClose?: boolean;
  97923. /**
  97924. * Optional list of extensibility entries
  97925. */
  97926. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97927. /**
  97928. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97929. */
  97930. inspectorURL?: string;
  97931. }
  97932. interface Scene {
  97933. /**
  97934. * @hidden
  97935. * Backing field
  97936. */
  97937. _debugLayer: DebugLayer;
  97938. /**
  97939. * Gets the debug layer (aka Inspector) associated with the scene
  97940. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97941. */
  97942. debugLayer: DebugLayer;
  97943. }
  97944. /**
  97945. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97946. * what is happening in your scene
  97947. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97948. */
  97949. export class DebugLayer {
  97950. /**
  97951. * Define the url to get the inspector script from.
  97952. * By default it uses the babylonjs CDN.
  97953. * @ignoreNaming
  97954. */
  97955. static InspectorURL: string;
  97956. private _scene;
  97957. private BJSINSPECTOR;
  97958. /**
  97959. * Observable triggered when a property is changed through the inspector.
  97960. */
  97961. onPropertyChangedObservable: Observable<{
  97962. object: any;
  97963. property: string;
  97964. value: any;
  97965. initialValue: any;
  97966. }>;
  97967. /**
  97968. * Instantiates a new debug layer.
  97969. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97970. * what is happening in your scene
  97971. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97972. * @param scene Defines the scene to inspect
  97973. */
  97974. constructor(scene: Scene);
  97975. /** Creates the inspector window. */
  97976. private _createInspector;
  97977. /**
  97978. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97979. * @param entity defines the entity to select
  97980. * @param lineContainerTitle defines the specific block to highlight
  97981. */
  97982. select(entity: any, lineContainerTitle?: string): void;
  97983. /** Get the inspector from bundle or global */
  97984. private _getGlobalInspector;
  97985. /**
  97986. * Get if the inspector is visible or not.
  97987. * @returns true if visible otherwise, false
  97988. */
  97989. isVisible(): boolean;
  97990. /**
  97991. * Hide the inspector and close its window.
  97992. */
  97993. hide(): void;
  97994. /**
  97995. * Launch the debugLayer.
  97996. * @param config Define the configuration of the inspector
  97997. * @return a promise fulfilled when the debug layer is visible
  97998. */
  97999. show(config?: IInspectorOptions): Promise<DebugLayer>;
  98000. }
  98001. }
  98002. declare module BABYLON {
  98003. /**
  98004. * Class containing static functions to help procedurally build meshes
  98005. */
  98006. export class BoxBuilder {
  98007. /**
  98008. * Creates a box mesh
  98009. * * The parameter `size` sets the size (float) of each box side (default 1)
  98010. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  98011. * * 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)
  98012. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  98013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98016. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  98017. * @param name defines the name of the mesh
  98018. * @param options defines the options used to create the mesh
  98019. * @param scene defines the hosting scene
  98020. * @returns the box mesh
  98021. */
  98022. static CreateBox(name: string, options: {
  98023. size?: number;
  98024. width?: number;
  98025. height?: number;
  98026. depth?: number;
  98027. faceUV?: Vector4[];
  98028. faceColors?: Color4[];
  98029. sideOrientation?: number;
  98030. frontUVs?: Vector4;
  98031. backUVs?: Vector4;
  98032. updatable?: boolean;
  98033. }, scene?: Nullable<Scene>): Mesh;
  98034. }
  98035. }
  98036. declare module BABYLON {
  98037. /**
  98038. * Class containing static functions to help procedurally build meshes
  98039. */
  98040. export class SphereBuilder {
  98041. /**
  98042. * Creates a sphere mesh
  98043. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  98044. * * 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`)
  98045. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  98046. * * 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
  98047. * * 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)
  98048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98051. * @param name defines the name of the mesh
  98052. * @param options defines the options used to create the mesh
  98053. * @param scene defines the hosting scene
  98054. * @returns the sphere mesh
  98055. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  98056. */
  98057. static CreateSphere(name: string, options: {
  98058. segments?: number;
  98059. diameter?: number;
  98060. diameterX?: number;
  98061. diameterY?: number;
  98062. diameterZ?: number;
  98063. arc?: number;
  98064. slice?: number;
  98065. sideOrientation?: number;
  98066. frontUVs?: Vector4;
  98067. backUVs?: Vector4;
  98068. updatable?: boolean;
  98069. }, scene: any): Mesh;
  98070. }
  98071. }
  98072. declare module BABYLON.Debug {
  98073. /**
  98074. * Used to show the physics impostor around the specific mesh
  98075. */
  98076. export class PhysicsViewer {
  98077. /** @hidden */
  98078. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  98079. /** @hidden */
  98080. protected _meshes: Array<Nullable<AbstractMesh>>;
  98081. /** @hidden */
  98082. protected _scene: Nullable<Scene>;
  98083. /** @hidden */
  98084. protected _numMeshes: number;
  98085. /** @hidden */
  98086. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  98087. private _renderFunction;
  98088. private _utilityLayer;
  98089. private _debugBoxMesh;
  98090. private _debugSphereMesh;
  98091. private _debugMaterial;
  98092. /**
  98093. * Creates a new PhysicsViewer
  98094. * @param scene defines the hosting scene
  98095. */
  98096. constructor(scene: Scene);
  98097. /** @hidden */
  98098. protected _updateDebugMeshes(): void;
  98099. /**
  98100. * Renders a specified physic impostor
  98101. * @param impostor defines the impostor to render
  98102. * @returns the new debug mesh used to render the impostor
  98103. */
  98104. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  98105. /**
  98106. * Hides a specified physic impostor
  98107. * @param impostor defines the impostor to hide
  98108. */
  98109. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  98110. private _getDebugMaterial;
  98111. private _getDebugBoxMesh;
  98112. private _getDebugSphereMesh;
  98113. private _getDebugMesh;
  98114. /** Releases all resources */
  98115. dispose(): void;
  98116. }
  98117. }
  98118. declare module BABYLON {
  98119. /**
  98120. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  98121. * in order to better appreciate the issue one might have.
  98122. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  98123. */
  98124. export class RayHelper {
  98125. /**
  98126. * Defines the ray we are currently tryin to visualize.
  98127. */
  98128. ray: Nullable<Ray>;
  98129. private _renderPoints;
  98130. private _renderLine;
  98131. private _renderFunction;
  98132. private _scene;
  98133. private _updateToMeshFunction;
  98134. private _attachedToMesh;
  98135. private _meshSpaceDirection;
  98136. private _meshSpaceOrigin;
  98137. /**
  98138. * Helper function to create a colored helper in a scene in one line.
  98139. * @param ray Defines the ray we are currently tryin to visualize
  98140. * @param scene Defines the scene the ray is used in
  98141. * @param color Defines the color we want to see the ray in
  98142. * @returns The newly created ray helper.
  98143. */
  98144. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  98145. /**
  98146. * Instantiate a new ray helper.
  98147. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  98148. * in order to better appreciate the issue one might have.
  98149. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  98150. * @param ray Defines the ray we are currently tryin to visualize
  98151. */
  98152. constructor(ray: Ray);
  98153. /**
  98154. * Shows the ray we are willing to debug.
  98155. * @param scene Defines the scene the ray needs to be rendered in
  98156. * @param color Defines the color the ray needs to be rendered in
  98157. */
  98158. show(scene: Scene, color?: Color3): void;
  98159. /**
  98160. * Hides the ray we are debugging.
  98161. */
  98162. hide(): void;
  98163. private _render;
  98164. /**
  98165. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  98166. * @param mesh Defines the mesh we want the helper attached to
  98167. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  98168. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  98169. * @param length Defines the length of the ray
  98170. */
  98171. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  98172. /**
  98173. * Detach the ray helper from the mesh it has previously been attached to.
  98174. */
  98175. detachFromMesh(): void;
  98176. private _updateToMesh;
  98177. /**
  98178. * Dispose the helper and release its associated resources.
  98179. */
  98180. dispose(): void;
  98181. }
  98182. }
  98183. declare module BABYLON.Debug {
  98184. /**
  98185. * Class used to render a debug view of a given skeleton
  98186. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  98187. */
  98188. export class SkeletonViewer {
  98189. /** defines the skeleton to render */
  98190. skeleton: Skeleton;
  98191. /** defines the mesh attached to the skeleton */
  98192. mesh: AbstractMesh;
  98193. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98194. autoUpdateBonesMatrices: boolean;
  98195. /** defines the rendering group id to use with the viewer */
  98196. renderingGroupId: number;
  98197. /** Gets or sets the color used to render the skeleton */
  98198. color: Color3;
  98199. private _scene;
  98200. private _debugLines;
  98201. private _debugMesh;
  98202. private _isEnabled;
  98203. private _renderFunction;
  98204. private _utilityLayer;
  98205. /**
  98206. * Returns the mesh used to render the bones
  98207. */
  98208. readonly debugMesh: Nullable<LinesMesh>;
  98209. /**
  98210. * Creates a new SkeletonViewer
  98211. * @param skeleton defines the skeleton to render
  98212. * @param mesh defines the mesh attached to the skeleton
  98213. * @param scene defines the hosting scene
  98214. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  98215. * @param renderingGroupId defines the rendering group id to use with the viewer
  98216. */
  98217. constructor(
  98218. /** defines the skeleton to render */
  98219. skeleton: Skeleton,
  98220. /** defines the mesh attached to the skeleton */
  98221. mesh: AbstractMesh, scene: Scene,
  98222. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98223. autoUpdateBonesMatrices?: boolean,
  98224. /** defines the rendering group id to use with the viewer */
  98225. renderingGroupId?: number);
  98226. /** Gets or sets a boolean indicating if the viewer is enabled */
  98227. isEnabled: boolean;
  98228. private _getBonePosition;
  98229. private _getLinesForBonesWithLength;
  98230. private _getLinesForBonesNoLength;
  98231. /** Update the viewer to sync with current skeleton state */
  98232. update(): void;
  98233. /** Release associated resources */
  98234. dispose(): void;
  98235. }
  98236. }
  98237. declare module BABYLON {
  98238. /**
  98239. * Options to create the null engine
  98240. */
  98241. export class NullEngineOptions {
  98242. /**
  98243. * Render width (Default: 512)
  98244. */
  98245. renderWidth: number;
  98246. /**
  98247. * Render height (Default: 256)
  98248. */
  98249. renderHeight: number;
  98250. /**
  98251. * Texture size (Default: 512)
  98252. */
  98253. textureSize: number;
  98254. /**
  98255. * If delta time between frames should be constant
  98256. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98257. */
  98258. deterministicLockstep: boolean;
  98259. /**
  98260. * Maximum about of steps between frames (Default: 4)
  98261. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98262. */
  98263. lockstepMaxSteps: number;
  98264. }
  98265. /**
  98266. * The null engine class provides support for headless version of babylon.js.
  98267. * This can be used in server side scenario or for testing purposes
  98268. */
  98269. export class NullEngine extends Engine {
  98270. private _options;
  98271. /**
  98272. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98273. */
  98274. isDeterministicLockStep(): boolean;
  98275. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98276. getLockstepMaxSteps(): number;
  98277. /**
  98278. * Sets hardware scaling, used to save performance if needed
  98279. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98280. */
  98281. getHardwareScalingLevel(): number;
  98282. constructor(options?: NullEngineOptions);
  98283. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98284. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98285. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98286. getRenderWidth(useScreen?: boolean): number;
  98287. getRenderHeight(useScreen?: boolean): number;
  98288. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98289. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98290. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98291. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98292. bindSamplers(effect: Effect): void;
  98293. enableEffect(effect: Effect): void;
  98294. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98295. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98296. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98297. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98298. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98299. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98300. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98301. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98302. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98303. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98304. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98305. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98306. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98307. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98308. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98309. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98310. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98311. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98312. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98313. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98314. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98315. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98316. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98317. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98318. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98319. bindBuffers(vertexBuffers: {
  98320. [key: string]: VertexBuffer;
  98321. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98322. wipeCaches(bruteForce?: boolean): void;
  98323. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98324. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98325. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98326. /** @hidden */
  98327. _createTexture(): WebGLTexture;
  98328. /** @hidden */
  98329. _releaseTexture(texture: InternalTexture): void;
  98330. 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;
  98331. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98332. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98333. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98334. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98335. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98336. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98337. areAllEffectsReady(): boolean;
  98338. /**
  98339. * @hidden
  98340. * Get the current error code of the webGL context
  98341. * @returns the error code
  98342. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98343. */
  98344. getError(): number;
  98345. /** @hidden */
  98346. _getUnpackAlignement(): number;
  98347. /** @hidden */
  98348. _unpackFlipY(value: boolean): void;
  98349. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98350. /**
  98351. * Updates a dynamic vertex buffer.
  98352. * @param vertexBuffer the vertex buffer to update
  98353. * @param data the data used to update the vertex buffer
  98354. * @param byteOffset the byte offset of the data (optional)
  98355. * @param byteLength the byte length of the data (optional)
  98356. */
  98357. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98358. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98359. /** @hidden */
  98360. _bindTexture(channel: number, texture: InternalTexture): void;
  98361. /** @hidden */
  98362. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98363. releaseEffects(): void;
  98364. displayLoadingUI(): void;
  98365. hideLoadingUI(): void;
  98366. /** @hidden */
  98367. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98368. /** @hidden */
  98369. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98370. /** @hidden */
  98371. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98372. /** @hidden */
  98373. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98374. }
  98375. }
  98376. declare module BABYLON {
  98377. /** @hidden */
  98378. export class _OcclusionDataStorage {
  98379. /** @hidden */
  98380. occlusionInternalRetryCounter: number;
  98381. /** @hidden */
  98382. isOcclusionQueryInProgress: boolean;
  98383. /** @hidden */
  98384. isOccluded: boolean;
  98385. /** @hidden */
  98386. occlusionRetryCount: number;
  98387. /** @hidden */
  98388. occlusionType: number;
  98389. /** @hidden */
  98390. occlusionQueryAlgorithmType: number;
  98391. }
  98392. interface Engine {
  98393. /**
  98394. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98395. * @return the new query
  98396. */
  98397. createQuery(): WebGLQuery;
  98398. /**
  98399. * Delete and release a webGL query
  98400. * @param query defines the query to delete
  98401. * @return the current engine
  98402. */
  98403. deleteQuery(query: WebGLQuery): Engine;
  98404. /**
  98405. * Check if a given query has resolved and got its value
  98406. * @param query defines the query to check
  98407. * @returns true if the query got its value
  98408. */
  98409. isQueryResultAvailable(query: WebGLQuery): boolean;
  98410. /**
  98411. * Gets the value of a given query
  98412. * @param query defines the query to check
  98413. * @returns the value of the query
  98414. */
  98415. getQueryResult(query: WebGLQuery): number;
  98416. /**
  98417. * Initiates an occlusion query
  98418. * @param algorithmType defines the algorithm to use
  98419. * @param query defines the query to use
  98420. * @returns the current engine
  98421. * @see http://doc.babylonjs.com/features/occlusionquery
  98422. */
  98423. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98424. /**
  98425. * Ends an occlusion query
  98426. * @see http://doc.babylonjs.com/features/occlusionquery
  98427. * @param algorithmType defines the algorithm to use
  98428. * @returns the current engine
  98429. */
  98430. endOcclusionQuery(algorithmType: number): Engine;
  98431. /**
  98432. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98433. * Please note that only one query can be issued at a time
  98434. * @returns a time token used to track the time span
  98435. */
  98436. startTimeQuery(): Nullable<_TimeToken>;
  98437. /**
  98438. * Ends a time query
  98439. * @param token defines the token used to measure the time span
  98440. * @returns the time spent (in ns)
  98441. */
  98442. endTimeQuery(token: _TimeToken): int;
  98443. /** @hidden */
  98444. _currentNonTimestampToken: Nullable<_TimeToken>;
  98445. /** @hidden */
  98446. _createTimeQuery(): WebGLQuery;
  98447. /** @hidden */
  98448. _deleteTimeQuery(query: WebGLQuery): void;
  98449. /** @hidden */
  98450. _getGlAlgorithmType(algorithmType: number): number;
  98451. /** @hidden */
  98452. _getTimeQueryResult(query: WebGLQuery): any;
  98453. /** @hidden */
  98454. _getTimeQueryAvailability(query: WebGLQuery): any;
  98455. }
  98456. interface AbstractMesh {
  98457. /**
  98458. * Backing filed
  98459. * @hidden
  98460. */
  98461. __occlusionDataStorage: _OcclusionDataStorage;
  98462. /**
  98463. * Access property
  98464. * @hidden
  98465. */
  98466. _occlusionDataStorage: _OcclusionDataStorage;
  98467. /**
  98468. * 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.
  98469. * The default value is -1 which means don't break the query and wait till the result
  98470. * @see http://doc.babylonjs.com/features/occlusionquery
  98471. */
  98472. occlusionRetryCount: number;
  98473. /**
  98474. * 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:
  98475. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98476. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98477. * * 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.
  98478. * @see http://doc.babylonjs.com/features/occlusionquery
  98479. */
  98480. occlusionType: number;
  98481. /**
  98482. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98483. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98484. * * 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.
  98485. * @see http://doc.babylonjs.com/features/occlusionquery
  98486. */
  98487. occlusionQueryAlgorithmType: number;
  98488. /**
  98489. * 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
  98490. * @see http://doc.babylonjs.com/features/occlusionquery
  98491. */
  98492. isOccluded: boolean;
  98493. /**
  98494. * Flag to check the progress status of the query
  98495. * @see http://doc.babylonjs.com/features/occlusionquery
  98496. */
  98497. isOcclusionQueryInProgress: boolean;
  98498. }
  98499. }
  98500. declare module BABYLON {
  98501. /** @hidden */
  98502. export var _forceTransformFeedbackToBundle: boolean;
  98503. interface Engine {
  98504. /**
  98505. * Creates a webGL transform feedback object
  98506. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98507. * @returns the webGL transform feedback object
  98508. */
  98509. createTransformFeedback(): WebGLTransformFeedback;
  98510. /**
  98511. * Delete a webGL transform feedback object
  98512. * @param value defines the webGL transform feedback object to delete
  98513. */
  98514. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98515. /**
  98516. * Bind a webGL transform feedback object to the webgl context
  98517. * @param value defines the webGL transform feedback object to bind
  98518. */
  98519. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98520. /**
  98521. * Begins a transform feedback operation
  98522. * @param usePoints defines if points or triangles must be used
  98523. */
  98524. beginTransformFeedback(usePoints: boolean): void;
  98525. /**
  98526. * Ends a transform feedback operation
  98527. */
  98528. endTransformFeedback(): void;
  98529. /**
  98530. * Specify the varyings to use with transform feedback
  98531. * @param program defines the associated webGL program
  98532. * @param value defines the list of strings representing the varying names
  98533. */
  98534. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98535. /**
  98536. * Bind a webGL buffer for a transform feedback operation
  98537. * @param value defines the webGL buffer to bind
  98538. */
  98539. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98540. }
  98541. }
  98542. declare module BABYLON {
  98543. /**
  98544. * Gather the list of clipboard event types as constants.
  98545. */
  98546. export class ClipboardEventTypes {
  98547. /**
  98548. * The clipboard event is fired when a copy command is active (pressed).
  98549. */
  98550. static readonly COPY: number;
  98551. /**
  98552. * The clipboard event is fired when a cut command is active (pressed).
  98553. */
  98554. static readonly CUT: number;
  98555. /**
  98556. * The clipboard event is fired when a paste command is active (pressed).
  98557. */
  98558. static readonly PASTE: number;
  98559. }
  98560. /**
  98561. * This class is used to store clipboard related info for the onClipboardObservable event.
  98562. */
  98563. export class ClipboardInfo {
  98564. /**
  98565. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98566. */
  98567. type: number;
  98568. /**
  98569. * Defines the related dom event
  98570. */
  98571. event: ClipboardEvent;
  98572. /**
  98573. *Creates an instance of ClipboardInfo.
  98574. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98575. * @param event Defines the related dom event
  98576. */
  98577. constructor(
  98578. /**
  98579. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98580. */
  98581. type: number,
  98582. /**
  98583. * Defines the related dom event
  98584. */
  98585. event: ClipboardEvent);
  98586. /**
  98587. * Get the clipboard event's type from the keycode.
  98588. * @param keyCode Defines the keyCode for the current keyboard event.
  98589. * @return {number}
  98590. */
  98591. static GetTypeFromCharacter(keyCode: number): number;
  98592. }
  98593. }
  98594. declare module BABYLON {
  98595. /**
  98596. * Class used to represent data loading progression
  98597. */
  98598. export class SceneLoaderProgressEvent {
  98599. /** defines if data length to load can be evaluated */
  98600. readonly lengthComputable: boolean;
  98601. /** defines the loaded data length */
  98602. readonly loaded: number;
  98603. /** defines the data length to load */
  98604. readonly total: number;
  98605. /**
  98606. * Create a new progress event
  98607. * @param lengthComputable defines if data length to load can be evaluated
  98608. * @param loaded defines the loaded data length
  98609. * @param total defines the data length to load
  98610. */
  98611. constructor(
  98612. /** defines if data length to load can be evaluated */
  98613. lengthComputable: boolean,
  98614. /** defines the loaded data length */
  98615. loaded: number,
  98616. /** defines the data length to load */
  98617. total: number);
  98618. /**
  98619. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98620. * @param event defines the source event
  98621. * @returns a new SceneLoaderProgressEvent
  98622. */
  98623. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98624. }
  98625. /**
  98626. * Interface used by SceneLoader plugins to define supported file extensions
  98627. */
  98628. export interface ISceneLoaderPluginExtensions {
  98629. /**
  98630. * Defines the list of supported extensions
  98631. */
  98632. [extension: string]: {
  98633. isBinary: boolean;
  98634. };
  98635. }
  98636. /**
  98637. * Interface used by SceneLoader plugin factory
  98638. */
  98639. export interface ISceneLoaderPluginFactory {
  98640. /**
  98641. * Defines the name of the factory
  98642. */
  98643. name: string;
  98644. /**
  98645. * Function called to create a new plugin
  98646. * @return the new plugin
  98647. */
  98648. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98649. /**
  98650. * Boolean indicating if the plugin can direct load specific data
  98651. */
  98652. canDirectLoad?: (data: string) => boolean;
  98653. }
  98654. /**
  98655. * Interface used to define a SceneLoader plugin
  98656. */
  98657. export interface ISceneLoaderPlugin {
  98658. /**
  98659. * The friendly name of this plugin.
  98660. */
  98661. name: string;
  98662. /**
  98663. * The file extensions supported by this plugin.
  98664. */
  98665. extensions: string | ISceneLoaderPluginExtensions;
  98666. /**
  98667. * Import meshes into a scene.
  98668. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98669. * @param scene The scene to import into
  98670. * @param data The data to import
  98671. * @param rootUrl The root url for scene and resources
  98672. * @param meshes The meshes array to import into
  98673. * @param particleSystems The particle systems array to import into
  98674. * @param skeletons The skeletons array to import into
  98675. * @param onError The callback when import fails
  98676. * @returns True if successful or false otherwise
  98677. */
  98678. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98679. /**
  98680. * Load into a scene.
  98681. * @param scene The scene to load into
  98682. * @param data The data to import
  98683. * @param rootUrl The root url for scene and resources
  98684. * @param onError The callback when import fails
  98685. * @returns true if successful or false otherwise
  98686. */
  98687. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98688. /**
  98689. * The callback that returns true if the data can be directly loaded.
  98690. */
  98691. canDirectLoad?: (data: string) => boolean;
  98692. /**
  98693. * The callback that allows custom handling of the root url based on the response url.
  98694. */
  98695. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98696. /**
  98697. * Load into an asset container.
  98698. * @param scene The scene to load into
  98699. * @param data The data to import
  98700. * @param rootUrl The root url for scene and resources
  98701. * @param onError The callback when import fails
  98702. * @returns The loaded asset container
  98703. */
  98704. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98705. }
  98706. /**
  98707. * Interface used to define an async SceneLoader plugin
  98708. */
  98709. export interface ISceneLoaderPluginAsync {
  98710. /**
  98711. * The friendly name of this plugin.
  98712. */
  98713. name: string;
  98714. /**
  98715. * The file extensions supported by this plugin.
  98716. */
  98717. extensions: string | ISceneLoaderPluginExtensions;
  98718. /**
  98719. * Import meshes into a scene.
  98720. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98721. * @param scene The scene to import into
  98722. * @param data The data to import
  98723. * @param rootUrl The root url for scene and resources
  98724. * @param onProgress The callback when the load progresses
  98725. * @param fileName Defines the name of the file to load
  98726. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98727. */
  98728. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98729. meshes: AbstractMesh[];
  98730. particleSystems: IParticleSystem[];
  98731. skeletons: Skeleton[];
  98732. animationGroups: AnimationGroup[];
  98733. }>;
  98734. /**
  98735. * Load into a scene.
  98736. * @param scene The scene to load into
  98737. * @param data The data to import
  98738. * @param rootUrl The root url for scene and resources
  98739. * @param onProgress The callback when the load progresses
  98740. * @param fileName Defines the name of the file to load
  98741. * @returns Nothing
  98742. */
  98743. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98744. /**
  98745. * The callback that returns true if the data can be directly loaded.
  98746. */
  98747. canDirectLoad?: (data: string) => boolean;
  98748. /**
  98749. * The callback that allows custom handling of the root url based on the response url.
  98750. */
  98751. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98752. /**
  98753. * Load into an asset container.
  98754. * @param scene The scene to load into
  98755. * @param data The data to import
  98756. * @param rootUrl The root url for scene and resources
  98757. * @param onProgress The callback when the load progresses
  98758. * @param fileName Defines the name of the file to load
  98759. * @returns The loaded asset container
  98760. */
  98761. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98762. }
  98763. /**
  98764. * Class used to load scene from various file formats using registered plugins
  98765. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98766. */
  98767. export class SceneLoader {
  98768. /**
  98769. * No logging while loading
  98770. */
  98771. static readonly NO_LOGGING: number;
  98772. /**
  98773. * Minimal logging while loading
  98774. */
  98775. static readonly MINIMAL_LOGGING: number;
  98776. /**
  98777. * Summary logging while loading
  98778. */
  98779. static readonly SUMMARY_LOGGING: number;
  98780. /**
  98781. * Detailled logging while loading
  98782. */
  98783. static readonly DETAILED_LOGGING: number;
  98784. /**
  98785. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98786. */
  98787. static ForceFullSceneLoadingForIncremental: boolean;
  98788. /**
  98789. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98790. */
  98791. static ShowLoadingScreen: boolean;
  98792. /**
  98793. * Defines the current logging level (while loading the scene)
  98794. * @ignorenaming
  98795. */
  98796. static loggingLevel: number;
  98797. /**
  98798. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98799. */
  98800. static CleanBoneMatrixWeights: boolean;
  98801. /**
  98802. * Event raised when a plugin is used to load a scene
  98803. */
  98804. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98805. private static _registeredPlugins;
  98806. private static _getDefaultPlugin;
  98807. private static _getPluginForExtension;
  98808. private static _getPluginForDirectLoad;
  98809. private static _getPluginForFilename;
  98810. private static _getDirectLoad;
  98811. private static _loadData;
  98812. private static _getFileInfo;
  98813. /**
  98814. * Gets a plugin that can load the given extension
  98815. * @param extension defines the extension to load
  98816. * @returns a plugin or null if none works
  98817. */
  98818. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98819. /**
  98820. * Gets a boolean indicating that the given extension can be loaded
  98821. * @param extension defines the extension to load
  98822. * @returns true if the extension is supported
  98823. */
  98824. static IsPluginForExtensionAvailable(extension: string): boolean;
  98825. /**
  98826. * Adds a new plugin to the list of registered plugins
  98827. * @param plugin defines the plugin to add
  98828. */
  98829. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98830. /**
  98831. * Import meshes into a scene
  98832. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98833. * @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)
  98834. * @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)
  98835. * @param scene the instance of BABYLON.Scene to append to
  98836. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98837. * @param onProgress a callback with a progress event for each file being loaded
  98838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98839. * @param pluginExtension the extension used to determine the plugin
  98840. * @returns The loaded plugin
  98841. */
  98842. 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>;
  98843. /**
  98844. * Import meshes into a scene
  98845. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98846. * @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)
  98847. * @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)
  98848. * @param scene the instance of BABYLON.Scene to append to
  98849. * @param onProgress a callback with a progress event for each file being loaded
  98850. * @param pluginExtension the extension used to determine the plugin
  98851. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98852. */
  98853. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98854. meshes: AbstractMesh[];
  98855. particleSystems: IParticleSystem[];
  98856. skeletons: Skeleton[];
  98857. animationGroups: AnimationGroup[];
  98858. }>;
  98859. /**
  98860. * Load a scene
  98861. * @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)
  98862. * @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)
  98863. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98864. * @param onSuccess a callback with the scene when import succeeds
  98865. * @param onProgress a callback with a progress event for each file being loaded
  98866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98867. * @param pluginExtension the extension used to determine the plugin
  98868. * @returns The loaded plugin
  98869. */
  98870. 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>;
  98871. /**
  98872. * Load a scene
  98873. * @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)
  98874. * @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)
  98875. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98876. * @param onProgress a callback with a progress event for each file being loaded
  98877. * @param pluginExtension the extension used to determine the plugin
  98878. * @returns The loaded scene
  98879. */
  98880. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98881. /**
  98882. * Append a scene
  98883. * @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)
  98884. * @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)
  98885. * @param scene is the instance of BABYLON.Scene to append to
  98886. * @param onSuccess a callback with the scene when import succeeds
  98887. * @param onProgress a callback with a progress event for each file being loaded
  98888. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98889. * @param pluginExtension the extension used to determine the plugin
  98890. * @returns The loaded plugin
  98891. */
  98892. 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>;
  98893. /**
  98894. * Append a scene
  98895. * @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)
  98896. * @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)
  98897. * @param scene is the instance of BABYLON.Scene to append to
  98898. * @param onProgress a callback with a progress event for each file being loaded
  98899. * @param pluginExtension the extension used to determine the plugin
  98900. * @returns The given scene
  98901. */
  98902. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98903. /**
  98904. * Load a scene into an asset container
  98905. * @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)
  98906. * @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)
  98907. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98908. * @param onSuccess a callback with the scene when import succeeds
  98909. * @param onProgress a callback with a progress event for each file being loaded
  98910. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98911. * @param pluginExtension the extension used to determine the plugin
  98912. * @returns The loaded plugin
  98913. */
  98914. 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>;
  98915. /**
  98916. * Load a scene into an asset container
  98917. * @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)
  98918. * @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)
  98919. * @param scene is the instance of Scene to append to
  98920. * @param onProgress a callback with a progress event for each file being loaded
  98921. * @param pluginExtension the extension used to determine the plugin
  98922. * @returns The loaded asset container
  98923. */
  98924. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98925. }
  98926. }
  98927. declare module BABYLON {
  98928. /**
  98929. * Google Daydream controller
  98930. */
  98931. export class DaydreamController extends WebVRController {
  98932. /**
  98933. * Base Url for the controller model.
  98934. */
  98935. static MODEL_BASE_URL: string;
  98936. /**
  98937. * File name for the controller model.
  98938. */
  98939. static MODEL_FILENAME: string;
  98940. /**
  98941. * Gamepad Id prefix used to identify Daydream Controller.
  98942. */
  98943. static readonly GAMEPAD_ID_PREFIX: string;
  98944. /**
  98945. * Creates a new DaydreamController from a gamepad
  98946. * @param vrGamepad the gamepad that the controller should be created from
  98947. */
  98948. constructor(vrGamepad: any);
  98949. /**
  98950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98951. * @param scene scene in which to add meshes
  98952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98953. */
  98954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98955. /**
  98956. * Called once for each button that changed state since the last frame
  98957. * @param buttonIdx Which button index changed
  98958. * @param state New state of the button
  98959. * @param changes Which properties on the state changed since last frame
  98960. */
  98961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98962. }
  98963. }
  98964. declare module BABYLON {
  98965. /**
  98966. * Gear VR Controller
  98967. */
  98968. export class GearVRController extends WebVRController {
  98969. /**
  98970. * Base Url for the controller model.
  98971. */
  98972. static MODEL_BASE_URL: string;
  98973. /**
  98974. * File name for the controller model.
  98975. */
  98976. static MODEL_FILENAME: string;
  98977. /**
  98978. * Gamepad Id prefix used to identify this controller.
  98979. */
  98980. static readonly GAMEPAD_ID_PREFIX: string;
  98981. private readonly _buttonIndexToObservableNameMap;
  98982. /**
  98983. * Creates a new GearVRController from a gamepad
  98984. * @param vrGamepad the gamepad that the controller should be created from
  98985. */
  98986. constructor(vrGamepad: any);
  98987. /**
  98988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98989. * @param scene scene in which to add meshes
  98990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98991. */
  98992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98993. /**
  98994. * Called once for each button that changed state since the last frame
  98995. * @param buttonIdx Which button index changed
  98996. * @param state New state of the button
  98997. * @param changes Which properties on the state changed since last frame
  98998. */
  98999. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99000. }
  99001. }
  99002. declare module BABYLON {
  99003. /**
  99004. * Generic Controller
  99005. */
  99006. export class GenericController extends WebVRController {
  99007. /**
  99008. * Base Url for the controller model.
  99009. */
  99010. static readonly MODEL_BASE_URL: string;
  99011. /**
  99012. * File name for the controller model.
  99013. */
  99014. static readonly MODEL_FILENAME: string;
  99015. /**
  99016. * Creates a new GenericController from a gamepad
  99017. * @param vrGamepad the gamepad that the controller should be created from
  99018. */
  99019. constructor(vrGamepad: any);
  99020. /**
  99021. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99022. * @param scene scene in which to add meshes
  99023. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99024. */
  99025. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99026. /**
  99027. * Called once for each button that changed state since the last frame
  99028. * @param buttonIdx Which button index changed
  99029. * @param state New state of the button
  99030. * @param changes Which properties on the state changed since last frame
  99031. */
  99032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99033. }
  99034. }
  99035. declare module BABYLON {
  99036. /**
  99037. * Oculus Touch Controller
  99038. */
  99039. export class OculusTouchController extends WebVRController {
  99040. /**
  99041. * Base Url for the controller model.
  99042. */
  99043. static MODEL_BASE_URL: string;
  99044. /**
  99045. * File name for the left controller model.
  99046. */
  99047. static MODEL_LEFT_FILENAME: string;
  99048. /**
  99049. * File name for the right controller model.
  99050. */
  99051. static MODEL_RIGHT_FILENAME: string;
  99052. /**
  99053. * Fired when the secondary trigger on this controller is modified
  99054. */
  99055. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99056. /**
  99057. * Fired when the thumb rest on this controller is modified
  99058. */
  99059. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  99060. /**
  99061. * Creates a new OculusTouchController from a gamepad
  99062. * @param vrGamepad the gamepad that the controller should be created from
  99063. */
  99064. constructor(vrGamepad: any);
  99065. /**
  99066. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99067. * @param scene scene in which to add meshes
  99068. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99069. */
  99070. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99071. /**
  99072. * Fired when the A button on this controller is modified
  99073. */
  99074. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99075. /**
  99076. * Fired when the B button on this controller is modified
  99077. */
  99078. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99079. /**
  99080. * Fired when the X button on this controller is modified
  99081. */
  99082. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99083. /**
  99084. * Fired when the Y button on this controller is modified
  99085. */
  99086. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99087. /**
  99088. * Called once for each button that changed state since the last frame
  99089. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  99090. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  99091. * 2) secondary trigger (same)
  99092. * 3) A (right) X (left), touch, pressed = value
  99093. * 4) B / Y
  99094. * 5) thumb rest
  99095. * @param buttonIdx Which button index changed
  99096. * @param state New state of the button
  99097. * @param changes Which properties on the state changed since last frame
  99098. */
  99099. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99100. }
  99101. }
  99102. declare module BABYLON {
  99103. /**
  99104. * Vive Controller
  99105. */
  99106. export class ViveController extends WebVRController {
  99107. /**
  99108. * Base Url for the controller model.
  99109. */
  99110. static MODEL_BASE_URL: string;
  99111. /**
  99112. * File name for the controller model.
  99113. */
  99114. static MODEL_FILENAME: string;
  99115. /**
  99116. * Creates a new ViveController from a gamepad
  99117. * @param vrGamepad the gamepad that the controller should be created from
  99118. */
  99119. constructor(vrGamepad: any);
  99120. /**
  99121. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99122. * @param scene scene in which to add meshes
  99123. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99124. */
  99125. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99126. /**
  99127. * Fired when the left button on this controller is modified
  99128. */
  99129. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99130. /**
  99131. * Fired when the right button on this controller is modified
  99132. */
  99133. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99134. /**
  99135. * Fired when the menu button on this controller is modified
  99136. */
  99137. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99138. /**
  99139. * Called once for each button that changed state since the last frame
  99140. * Vive mapping:
  99141. * 0: touchpad
  99142. * 1: trigger
  99143. * 2: left AND right buttons
  99144. * 3: menu button
  99145. * @param buttonIdx Which button index changed
  99146. * @param state New state of the button
  99147. * @param changes Which properties on the state changed since last frame
  99148. */
  99149. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99150. }
  99151. }
  99152. declare module BABYLON {
  99153. /**
  99154. * Defines the WindowsMotionController object that the state of the windows motion controller
  99155. */
  99156. export class WindowsMotionController extends WebVRController {
  99157. /**
  99158. * The base url used to load the left and right controller models
  99159. */
  99160. static MODEL_BASE_URL: string;
  99161. /**
  99162. * The name of the left controller model file
  99163. */
  99164. static MODEL_LEFT_FILENAME: string;
  99165. /**
  99166. * The name of the right controller model file
  99167. */
  99168. static MODEL_RIGHT_FILENAME: string;
  99169. /**
  99170. * The controller name prefix for this controller type
  99171. */
  99172. static readonly GAMEPAD_ID_PREFIX: string;
  99173. /**
  99174. * The controller id pattern for this controller type
  99175. */
  99176. private static readonly GAMEPAD_ID_PATTERN;
  99177. private _loadedMeshInfo;
  99178. private readonly _mapping;
  99179. /**
  99180. * Fired when the trackpad on this controller is clicked
  99181. */
  99182. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  99183. /**
  99184. * Fired when the trackpad on this controller is modified
  99185. */
  99186. onTrackpadValuesChangedObservable: Observable<StickValues>;
  99187. /**
  99188. * The current x and y values of this controller's trackpad
  99189. */
  99190. trackpad: StickValues;
  99191. /**
  99192. * Creates a new WindowsMotionController from a gamepad
  99193. * @param vrGamepad the gamepad that the controller should be created from
  99194. */
  99195. constructor(vrGamepad: any);
  99196. /**
  99197. * Fired when the trigger on this controller is modified
  99198. */
  99199. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99200. /**
  99201. * Fired when the menu button on this controller is modified
  99202. */
  99203. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99204. /**
  99205. * Fired when the grip button on this controller is modified
  99206. */
  99207. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99208. /**
  99209. * Fired when the thumbstick button on this controller is modified
  99210. */
  99211. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99212. /**
  99213. * Fired when the touchpad button on this controller is modified
  99214. */
  99215. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99216. /**
  99217. * Fired when the touchpad values on this controller are modified
  99218. */
  99219. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  99220. private _updateTrackpad;
  99221. /**
  99222. * Called once per frame by the engine.
  99223. */
  99224. update(): void;
  99225. /**
  99226. * Called once for each button that changed state since the last frame
  99227. * @param buttonIdx Which button index changed
  99228. * @param state New state of the button
  99229. * @param changes Which properties on the state changed since last frame
  99230. */
  99231. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99232. /**
  99233. * Moves the buttons on the controller mesh based on their current state
  99234. * @param buttonName the name of the button to move
  99235. * @param buttonValue the value of the button which determines the buttons new position
  99236. */
  99237. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99238. /**
  99239. * Moves the axis on the controller mesh based on its current state
  99240. * @param axis the index of the axis
  99241. * @param axisValue the value of the axis which determines the meshes new position
  99242. * @hidden
  99243. */
  99244. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99245. /**
  99246. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99247. * @param scene scene in which to add meshes
  99248. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99249. */
  99250. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99251. /**
  99252. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99253. * can be transformed by button presses and axes values, based on this._mapping.
  99254. *
  99255. * @param scene scene in which the meshes exist
  99256. * @param meshes list of meshes that make up the controller model to process
  99257. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99258. */
  99259. private processModel;
  99260. private createMeshInfo;
  99261. /**
  99262. * Gets the ray of the controller in the direction the controller is pointing
  99263. * @param length the length the resulting ray should be
  99264. * @returns a ray in the direction the controller is pointing
  99265. */
  99266. getForwardRay(length?: number): Ray;
  99267. /**
  99268. * Disposes of the controller
  99269. */
  99270. dispose(): void;
  99271. }
  99272. }
  99273. declare module BABYLON {
  99274. /**
  99275. * Single axis scale gizmo
  99276. */
  99277. export class AxisScaleGizmo extends Gizmo {
  99278. private _coloredMaterial;
  99279. /**
  99280. * Drag behavior responsible for the gizmos dragging interactions
  99281. */
  99282. dragBehavior: PointerDragBehavior;
  99283. private _pointerObserver;
  99284. /**
  99285. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99286. */
  99287. snapDistance: number;
  99288. /**
  99289. * Event that fires each time the gizmo snaps to a new location.
  99290. * * snapDistance is the the change in distance
  99291. */
  99292. onSnapObservable: Observable<{
  99293. snapDistance: number;
  99294. }>;
  99295. /**
  99296. * If the scaling operation should be done on all axis (default: false)
  99297. */
  99298. uniformScaling: boolean;
  99299. /**
  99300. * Creates an AxisScaleGizmo
  99301. * @param gizmoLayer The utility layer the gizmo will be added to
  99302. * @param dragAxis The axis which the gizmo will be able to scale on
  99303. * @param color The color of the gizmo
  99304. */
  99305. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99307. /**
  99308. * Disposes of the gizmo
  99309. */
  99310. dispose(): void;
  99311. /**
  99312. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99313. * @param mesh The mesh to replace the default mesh of the gizmo
  99314. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99315. */
  99316. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99317. }
  99318. }
  99319. declare module BABYLON {
  99320. /**
  99321. * Bounding box gizmo
  99322. */
  99323. export class BoundingBoxGizmo extends Gizmo {
  99324. private _lineBoundingBox;
  99325. private _rotateSpheresParent;
  99326. private _scaleBoxesParent;
  99327. private _boundingDimensions;
  99328. private _renderObserver;
  99329. private _pointerObserver;
  99330. private _scaleDragSpeed;
  99331. private _tmpQuaternion;
  99332. private _tmpVector;
  99333. private _tmpRotationMatrix;
  99334. /**
  99335. * 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)
  99336. */
  99337. ignoreChildren: boolean;
  99338. /**
  99339. * 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)
  99340. */
  99341. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99342. /**
  99343. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99344. */
  99345. rotationSphereSize: number;
  99346. /**
  99347. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99348. */
  99349. scaleBoxSize: number;
  99350. /**
  99351. * 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)
  99352. */
  99353. fixedDragMeshScreenSize: boolean;
  99354. /**
  99355. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99356. */
  99357. fixedDragMeshScreenSizeDistanceFactor: number;
  99358. /**
  99359. * Fired when a rotation sphere or scale box is dragged
  99360. */
  99361. onDragStartObservable: Observable<{}>;
  99362. /**
  99363. * Fired when a scale box is dragged
  99364. */
  99365. onScaleBoxDragObservable: Observable<{}>;
  99366. /**
  99367. * Fired when a scale box drag is ended
  99368. */
  99369. onScaleBoxDragEndObservable: Observable<{}>;
  99370. /**
  99371. * Fired when a rotation sphere is dragged
  99372. */
  99373. onRotationSphereDragObservable: Observable<{}>;
  99374. /**
  99375. * Fired when a rotation sphere drag is ended
  99376. */
  99377. onRotationSphereDragEndObservable: Observable<{}>;
  99378. /**
  99379. * 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)
  99380. */
  99381. scalePivot: Nullable<Vector3>;
  99382. private _anchorMesh;
  99383. private _existingMeshScale;
  99384. private _dragMesh;
  99385. private pointerDragBehavior;
  99386. private coloredMaterial;
  99387. private hoverColoredMaterial;
  99388. /**
  99389. * Sets the color of the bounding box gizmo
  99390. * @param color the color to set
  99391. */
  99392. setColor(color: Color3): void;
  99393. /**
  99394. * Creates an BoundingBoxGizmo
  99395. * @param gizmoLayer The utility layer the gizmo will be added to
  99396. * @param color The color of the gizmo
  99397. */
  99398. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99399. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99400. private _selectNode;
  99401. /**
  99402. * Updates the bounding box information for the Gizmo
  99403. */
  99404. updateBoundingBox(): void;
  99405. private _updateRotationSpheres;
  99406. private _updateScaleBoxes;
  99407. /**
  99408. * Enables rotation on the specified axis and disables rotation on the others
  99409. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99410. */
  99411. setEnabledRotationAxis(axis: string): void;
  99412. /**
  99413. * Enables/disables scaling
  99414. * @param enable if scaling should be enabled
  99415. */
  99416. setEnabledScaling(enable: boolean): void;
  99417. private _updateDummy;
  99418. /**
  99419. * Enables a pointer drag behavior on the bounding box of the gizmo
  99420. */
  99421. enableDragBehavior(): void;
  99422. /**
  99423. * Disposes of the gizmo
  99424. */
  99425. dispose(): void;
  99426. /**
  99427. * 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)
  99428. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99429. * @returns the bounding box mesh with the passed in mesh as a child
  99430. */
  99431. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99432. /**
  99433. * CustomMeshes are not supported by this gizmo
  99434. * @param mesh The mesh to replace the default mesh of the gizmo
  99435. */
  99436. setCustomMesh(mesh: Mesh): void;
  99437. }
  99438. }
  99439. declare module BABYLON {
  99440. /**
  99441. * Single plane rotation gizmo
  99442. */
  99443. export class PlaneRotationGizmo extends Gizmo {
  99444. /**
  99445. * Drag behavior responsible for the gizmos dragging interactions
  99446. */
  99447. dragBehavior: PointerDragBehavior;
  99448. private _pointerObserver;
  99449. /**
  99450. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99451. */
  99452. snapDistance: number;
  99453. /**
  99454. * Event that fires each time the gizmo snaps to a new location.
  99455. * * snapDistance is the the change in distance
  99456. */
  99457. onSnapObservable: Observable<{
  99458. snapDistance: number;
  99459. }>;
  99460. /**
  99461. * Creates a PlaneRotationGizmo
  99462. * @param gizmoLayer The utility layer the gizmo will be added to
  99463. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99464. * @param color The color of the gizmo
  99465. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99466. */
  99467. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99468. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99469. /**
  99470. * Disposes of the gizmo
  99471. */
  99472. dispose(): void;
  99473. }
  99474. }
  99475. declare module BABYLON {
  99476. /**
  99477. * Gizmo that enables rotating a mesh along 3 axis
  99478. */
  99479. export class RotationGizmo extends Gizmo {
  99480. /**
  99481. * Internal gizmo used for interactions on the x axis
  99482. */
  99483. xGizmo: PlaneRotationGizmo;
  99484. /**
  99485. * Internal gizmo used for interactions on the y axis
  99486. */
  99487. yGizmo: PlaneRotationGizmo;
  99488. /**
  99489. * Internal gizmo used for interactions on the z axis
  99490. */
  99491. zGizmo: PlaneRotationGizmo;
  99492. /** Fires an event when any of it's sub gizmos are dragged */
  99493. onDragStartObservable: Observable<{}>;
  99494. /** Fires an event when any of it's sub gizmos are released from dragging */
  99495. onDragEndObservable: Observable<{}>;
  99496. attachedMesh: Nullable<AbstractMesh>;
  99497. /**
  99498. * Creates a RotationGizmo
  99499. * @param gizmoLayer The utility layer the gizmo will be added to
  99500. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99501. */
  99502. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99503. updateGizmoRotationToMatchAttachedMesh: boolean;
  99504. /**
  99505. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99506. */
  99507. snapDistance: number;
  99508. /**
  99509. * Ratio for the scale of the gizmo (Default: 1)
  99510. */
  99511. scaleRatio: number;
  99512. /**
  99513. * Disposes of the gizmo
  99514. */
  99515. dispose(): void;
  99516. /**
  99517. * CustomMeshes are not supported by this gizmo
  99518. * @param mesh The mesh to replace the default mesh of the gizmo
  99519. */
  99520. setCustomMesh(mesh: Mesh): void;
  99521. }
  99522. }
  99523. declare module BABYLON {
  99524. /**
  99525. * Gizmo that enables dragging a mesh along 3 axis
  99526. */
  99527. export class PositionGizmo extends Gizmo {
  99528. /**
  99529. * Internal gizmo used for interactions on the x axis
  99530. */
  99531. xGizmo: AxisDragGizmo;
  99532. /**
  99533. * Internal gizmo used for interactions on the y axis
  99534. */
  99535. yGizmo: AxisDragGizmo;
  99536. /**
  99537. * Internal gizmo used for interactions on the z axis
  99538. */
  99539. zGizmo: AxisDragGizmo;
  99540. /** Fires an event when any of it's sub gizmos are dragged */
  99541. onDragStartObservable: Observable<{}>;
  99542. /** Fires an event when any of it's sub gizmos are released from dragging */
  99543. onDragEndObservable: Observable<{}>;
  99544. attachedMesh: Nullable<AbstractMesh>;
  99545. /**
  99546. * Creates a PositionGizmo
  99547. * @param gizmoLayer The utility layer the gizmo will be added to
  99548. */
  99549. constructor(gizmoLayer?: UtilityLayerRenderer);
  99550. updateGizmoRotationToMatchAttachedMesh: boolean;
  99551. /**
  99552. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99553. */
  99554. snapDistance: number;
  99555. /**
  99556. * Ratio for the scale of the gizmo (Default: 1)
  99557. */
  99558. scaleRatio: number;
  99559. /**
  99560. * Disposes of the gizmo
  99561. */
  99562. dispose(): void;
  99563. /**
  99564. * CustomMeshes are not supported by this gizmo
  99565. * @param mesh The mesh to replace the default mesh of the gizmo
  99566. */
  99567. setCustomMesh(mesh: Mesh): void;
  99568. }
  99569. }
  99570. declare module BABYLON {
  99571. /**
  99572. * Class containing static functions to help procedurally build meshes
  99573. */
  99574. export class PolyhedronBuilder {
  99575. /**
  99576. * Creates a polyhedron mesh
  99577. * * 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
  99578. * * The parameter `size` (positive float, default 1) sets the polygon size
  99579. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99580. * * 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`
  99581. * * 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
  99582. * * 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)`)
  99583. * * 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
  99584. * * 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
  99585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99588. * @param name defines the name of the mesh
  99589. * @param options defines the options used to create the mesh
  99590. * @param scene defines the hosting scene
  99591. * @returns the polyhedron mesh
  99592. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99593. */
  99594. static CreatePolyhedron(name: string, options: {
  99595. type?: number;
  99596. size?: number;
  99597. sizeX?: number;
  99598. sizeY?: number;
  99599. sizeZ?: number;
  99600. custom?: any;
  99601. faceUV?: Vector4[];
  99602. faceColors?: Color4[];
  99603. flat?: boolean;
  99604. updatable?: boolean;
  99605. sideOrientation?: number;
  99606. frontUVs?: Vector4;
  99607. backUVs?: Vector4;
  99608. }, scene: Scene): Mesh;
  99609. }
  99610. }
  99611. declare module BABYLON {
  99612. /**
  99613. * Gizmo that enables scaling a mesh along 3 axis
  99614. */
  99615. export class ScaleGizmo extends Gizmo {
  99616. /**
  99617. * Internal gizmo used for interactions on the x axis
  99618. */
  99619. xGizmo: AxisScaleGizmo;
  99620. /**
  99621. * Internal gizmo used for interactions on the y axis
  99622. */
  99623. yGizmo: AxisScaleGizmo;
  99624. /**
  99625. * Internal gizmo used for interactions on the z axis
  99626. */
  99627. zGizmo: AxisScaleGizmo;
  99628. /**
  99629. * Internal gizmo used to scale all axis equally
  99630. */
  99631. uniformScaleGizmo: AxisScaleGizmo;
  99632. /** Fires an event when any of it's sub gizmos are dragged */
  99633. onDragStartObservable: Observable<{}>;
  99634. /** Fires an event when any of it's sub gizmos are released from dragging */
  99635. onDragEndObservable: Observable<{}>;
  99636. attachedMesh: Nullable<AbstractMesh>;
  99637. /**
  99638. * Creates a ScaleGizmo
  99639. * @param gizmoLayer The utility layer the gizmo will be added to
  99640. */
  99641. constructor(gizmoLayer?: UtilityLayerRenderer);
  99642. updateGizmoRotationToMatchAttachedMesh: boolean;
  99643. /**
  99644. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99645. */
  99646. snapDistance: number;
  99647. /**
  99648. * Ratio for the scale of the gizmo (Default: 1)
  99649. */
  99650. scaleRatio: number;
  99651. /**
  99652. * Disposes of the gizmo
  99653. */
  99654. dispose(): void;
  99655. }
  99656. }
  99657. declare module BABYLON {
  99658. /**
  99659. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99660. */
  99661. export class GizmoManager implements IDisposable {
  99662. private scene;
  99663. /**
  99664. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99665. */
  99666. gizmos: {
  99667. positionGizmo: Nullable<PositionGizmo>;
  99668. rotationGizmo: Nullable<RotationGizmo>;
  99669. scaleGizmo: Nullable<ScaleGizmo>;
  99670. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99671. };
  99672. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99673. clearGizmoOnEmptyPointerEvent: boolean;
  99674. /** Fires an event when the manager is attached to a mesh */
  99675. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99676. private _gizmosEnabled;
  99677. private _pointerObserver;
  99678. private _attachedMesh;
  99679. private _boundingBoxColor;
  99680. private _defaultUtilityLayer;
  99681. private _defaultKeepDepthUtilityLayer;
  99682. /**
  99683. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99684. */
  99685. boundingBoxDragBehavior: SixDofDragBehavior;
  99686. /**
  99687. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99688. */
  99689. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99690. /**
  99691. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99692. */
  99693. usePointerToAttachGizmos: boolean;
  99694. /**
  99695. * Instatiates a gizmo manager
  99696. * @param scene the scene to overlay the gizmos on top of
  99697. */
  99698. constructor(scene: Scene);
  99699. /**
  99700. * Attaches a set of gizmos to the specified mesh
  99701. * @param mesh The mesh the gizmo's should be attached to
  99702. */
  99703. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99704. /**
  99705. * If the position gizmo is enabled
  99706. */
  99707. positionGizmoEnabled: boolean;
  99708. /**
  99709. * If the rotation gizmo is enabled
  99710. */
  99711. rotationGizmoEnabled: boolean;
  99712. /**
  99713. * If the scale gizmo is enabled
  99714. */
  99715. scaleGizmoEnabled: boolean;
  99716. /**
  99717. * If the boundingBox gizmo is enabled
  99718. */
  99719. boundingBoxGizmoEnabled: boolean;
  99720. /**
  99721. * Disposes of the gizmo manager
  99722. */
  99723. dispose(): void;
  99724. }
  99725. }
  99726. declare module BABYLON {
  99727. /**
  99728. * Gizmo that enables viewing a light
  99729. */
  99730. export class LightGizmo extends Gizmo {
  99731. private _box;
  99732. /**
  99733. * Creates a LightGizmo
  99734. * @param gizmoLayer The utility layer the gizmo will be added to
  99735. */
  99736. constructor(gizmoLayer?: UtilityLayerRenderer);
  99737. private _light;
  99738. /**
  99739. * The light that the gizmo is attached to
  99740. */
  99741. light: Nullable<Light>;
  99742. /**
  99743. * @hidden
  99744. * Updates the gizmo to match the attached mesh's position/rotation
  99745. */
  99746. protected _update(): void;
  99747. }
  99748. }
  99749. declare module BABYLON {
  99750. /** @hidden */
  99751. export var backgroundFragmentDeclaration: {
  99752. name: string;
  99753. shader: string;
  99754. };
  99755. }
  99756. declare module BABYLON {
  99757. /** @hidden */
  99758. export var backgroundUboDeclaration: {
  99759. name: string;
  99760. shader: string;
  99761. };
  99762. }
  99763. declare module BABYLON {
  99764. /** @hidden */
  99765. export var backgroundPixelShader: {
  99766. name: string;
  99767. shader: string;
  99768. };
  99769. }
  99770. declare module BABYLON {
  99771. /** @hidden */
  99772. export var backgroundVertexDeclaration: {
  99773. name: string;
  99774. shader: string;
  99775. };
  99776. }
  99777. declare module BABYLON {
  99778. /** @hidden */
  99779. export var backgroundVertexShader: {
  99780. name: string;
  99781. shader: string;
  99782. };
  99783. }
  99784. declare module BABYLON {
  99785. /**
  99786. * Background material used to create an efficient environement around your scene.
  99787. */
  99788. export class BackgroundMaterial extends PushMaterial {
  99789. /**
  99790. * Standard reflectance value at parallel view angle.
  99791. */
  99792. static StandardReflectance0: number;
  99793. /**
  99794. * Standard reflectance value at grazing angle.
  99795. */
  99796. static StandardReflectance90: number;
  99797. protected _primaryColor: Color3;
  99798. /**
  99799. * Key light Color (multiply against the environement texture)
  99800. */
  99801. primaryColor: Color3;
  99802. protected __perceptualColor: Nullable<Color3>;
  99803. /**
  99804. * Experimental Internal Use Only.
  99805. *
  99806. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99807. * This acts as a helper to set the primary color to a more "human friendly" value.
  99808. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99809. * output color as close as possible from the chosen value.
  99810. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99811. * part of lighting setup.)
  99812. */
  99813. _perceptualColor: Nullable<Color3>;
  99814. protected _primaryColorShadowLevel: float;
  99815. /**
  99816. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99817. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99818. */
  99819. primaryColorShadowLevel: float;
  99820. protected _primaryColorHighlightLevel: float;
  99821. /**
  99822. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99823. * The primary color is used at the level chosen to define what the white area would look.
  99824. */
  99825. primaryColorHighlightLevel: float;
  99826. protected _reflectionTexture: Nullable<BaseTexture>;
  99827. /**
  99828. * Reflection Texture used in the material.
  99829. * Should be author in a specific way for the best result (refer to the documentation).
  99830. */
  99831. reflectionTexture: Nullable<BaseTexture>;
  99832. protected _reflectionBlur: float;
  99833. /**
  99834. * Reflection Texture level of blur.
  99835. *
  99836. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99837. * texture twice.
  99838. */
  99839. reflectionBlur: float;
  99840. protected _diffuseTexture: Nullable<BaseTexture>;
  99841. /**
  99842. * Diffuse Texture used in the material.
  99843. * Should be author in a specific way for the best result (refer to the documentation).
  99844. */
  99845. diffuseTexture: Nullable<BaseTexture>;
  99846. protected _shadowLights: Nullable<IShadowLight[]>;
  99847. /**
  99848. * Specify the list of lights casting shadow on the material.
  99849. * All scene shadow lights will be included if null.
  99850. */
  99851. shadowLights: Nullable<IShadowLight[]>;
  99852. protected _shadowLevel: float;
  99853. /**
  99854. * Helps adjusting the shadow to a softer level if required.
  99855. * 0 means black shadows and 1 means no shadows.
  99856. */
  99857. shadowLevel: float;
  99858. protected _sceneCenter: Vector3;
  99859. /**
  99860. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99861. * It is usually zero but might be interesting to modify according to your setup.
  99862. */
  99863. sceneCenter: Vector3;
  99864. protected _opacityFresnel: boolean;
  99865. /**
  99866. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99867. * This helps ensuring a nice transition when the camera goes under the ground.
  99868. */
  99869. opacityFresnel: boolean;
  99870. protected _reflectionFresnel: boolean;
  99871. /**
  99872. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99873. * This helps adding a mirror texture on the ground.
  99874. */
  99875. reflectionFresnel: boolean;
  99876. protected _reflectionFalloffDistance: number;
  99877. /**
  99878. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99879. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99880. */
  99881. reflectionFalloffDistance: number;
  99882. protected _reflectionAmount: number;
  99883. /**
  99884. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99885. */
  99886. reflectionAmount: number;
  99887. protected _reflectionReflectance0: number;
  99888. /**
  99889. * This specifies the weight of the reflection at grazing angle.
  99890. */
  99891. reflectionReflectance0: number;
  99892. protected _reflectionReflectance90: number;
  99893. /**
  99894. * This specifies the weight of the reflection at a perpendicular point of view.
  99895. */
  99896. reflectionReflectance90: number;
  99897. /**
  99898. * Sets the reflection reflectance fresnel values according to the default standard
  99899. * empirically know to work well :-)
  99900. */
  99901. reflectionStandardFresnelWeight: number;
  99902. protected _useRGBColor: boolean;
  99903. /**
  99904. * Helps to directly use the maps channels instead of their level.
  99905. */
  99906. useRGBColor: boolean;
  99907. protected _enableNoise: boolean;
  99908. /**
  99909. * This helps reducing the banding effect that could occur on the background.
  99910. */
  99911. enableNoise: boolean;
  99912. /**
  99913. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99914. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99915. * Recommended to be keep at 1.0 except for special cases.
  99916. */
  99917. fovMultiplier: number;
  99918. private _fovMultiplier;
  99919. /**
  99920. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99921. */
  99922. useEquirectangularFOV: boolean;
  99923. private _maxSimultaneousLights;
  99924. /**
  99925. * Number of Simultaneous lights allowed on the material.
  99926. */
  99927. maxSimultaneousLights: int;
  99928. /**
  99929. * Default configuration related to image processing available in the Background Material.
  99930. */
  99931. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99932. /**
  99933. * Keep track of the image processing observer to allow dispose and replace.
  99934. */
  99935. private _imageProcessingObserver;
  99936. /**
  99937. * Attaches a new image processing configuration to the PBR Material.
  99938. * @param configuration (if null the scene configuration will be use)
  99939. */
  99940. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99941. /**
  99942. * Gets the image processing configuration used either in this material.
  99943. */
  99944. /**
  99945. * Sets the Default image processing configuration used either in the this material.
  99946. *
  99947. * If sets to null, the scene one is in use.
  99948. */
  99949. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99950. /**
  99951. * Gets wether the color curves effect is enabled.
  99952. */
  99953. /**
  99954. * Sets wether the color curves effect is enabled.
  99955. */
  99956. cameraColorCurvesEnabled: boolean;
  99957. /**
  99958. * Gets wether the color grading effect is enabled.
  99959. */
  99960. /**
  99961. * Gets wether the color grading effect is enabled.
  99962. */
  99963. cameraColorGradingEnabled: boolean;
  99964. /**
  99965. * Gets wether tonemapping is enabled or not.
  99966. */
  99967. /**
  99968. * Sets wether tonemapping is enabled or not
  99969. */
  99970. cameraToneMappingEnabled: boolean;
  99971. /**
  99972. * The camera exposure used on this material.
  99973. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99974. * This corresponds to a photographic exposure.
  99975. */
  99976. /**
  99977. * The camera exposure used on this material.
  99978. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99979. * This corresponds to a photographic exposure.
  99980. */
  99981. cameraExposure: float;
  99982. /**
  99983. * Gets The camera contrast used on this material.
  99984. */
  99985. /**
  99986. * Sets The camera contrast used on this material.
  99987. */
  99988. cameraContrast: float;
  99989. /**
  99990. * Gets the Color Grading 2D Lookup Texture.
  99991. */
  99992. /**
  99993. * Sets the Color Grading 2D Lookup Texture.
  99994. */
  99995. cameraColorGradingTexture: Nullable<BaseTexture>;
  99996. /**
  99997. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99998. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99999. * 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;
  100000. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100001. */
  100002. /**
  100003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100005. * 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;
  100006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100007. */
  100008. cameraColorCurves: Nullable<ColorCurves>;
  100009. /**
  100010. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  100011. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  100012. */
  100013. switchToBGR: boolean;
  100014. private _renderTargets;
  100015. private _reflectionControls;
  100016. private _white;
  100017. private _primaryShadowColor;
  100018. private _primaryHighlightColor;
  100019. /**
  100020. * Instantiates a Background Material in the given scene
  100021. * @param name The friendly name of the material
  100022. * @param scene The scene to add the material to
  100023. */
  100024. constructor(name: string, scene: Scene);
  100025. /**
  100026. * Gets a boolean indicating that current material needs to register RTT
  100027. */
  100028. readonly hasRenderTargetTextures: boolean;
  100029. /**
  100030. * The entire material has been created in order to prevent overdraw.
  100031. * @returns false
  100032. */
  100033. needAlphaTesting(): boolean;
  100034. /**
  100035. * The entire material has been created in order to prevent overdraw.
  100036. * @returns true if blending is enable
  100037. */
  100038. needAlphaBlending(): boolean;
  100039. /**
  100040. * Checks wether the material is ready to be rendered for a given mesh.
  100041. * @param mesh The mesh to render
  100042. * @param subMesh The submesh to check against
  100043. * @param useInstances Specify wether or not the material is used with instances
  100044. * @returns true if all the dependencies are ready (Textures, Effects...)
  100045. */
  100046. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100047. /**
  100048. * Compute the primary color according to the chosen perceptual color.
  100049. */
  100050. private _computePrimaryColorFromPerceptualColor;
  100051. /**
  100052. * Compute the highlights and shadow colors according to their chosen levels.
  100053. */
  100054. private _computePrimaryColors;
  100055. /**
  100056. * Build the uniform buffer used in the material.
  100057. */
  100058. buildUniformLayout(): void;
  100059. /**
  100060. * Unbind the material.
  100061. */
  100062. unbind(): void;
  100063. /**
  100064. * Bind only the world matrix to the material.
  100065. * @param world The world matrix to bind.
  100066. */
  100067. bindOnlyWorldMatrix(world: Matrix): void;
  100068. /**
  100069. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  100070. * @param world The world matrix to bind.
  100071. * @param subMesh The submesh to bind for.
  100072. */
  100073. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100074. /**
  100075. * Dispose the material.
  100076. * @param forceDisposeEffect Force disposal of the associated effect.
  100077. * @param forceDisposeTextures Force disposal of the associated textures.
  100078. */
  100079. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100080. /**
  100081. * Clones the material.
  100082. * @param name The cloned name.
  100083. * @returns The cloned material.
  100084. */
  100085. clone(name: string): BackgroundMaterial;
  100086. /**
  100087. * Serializes the current material to its JSON representation.
  100088. * @returns The JSON representation.
  100089. */
  100090. serialize(): any;
  100091. /**
  100092. * Gets the class name of the material
  100093. * @returns "BackgroundMaterial"
  100094. */
  100095. getClassName(): string;
  100096. /**
  100097. * Parse a JSON input to create back a background material.
  100098. * @param source The JSON data to parse
  100099. * @param scene The scene to create the parsed material in
  100100. * @param rootUrl The root url of the assets the material depends upon
  100101. * @returns the instantiated BackgroundMaterial.
  100102. */
  100103. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  100104. }
  100105. }
  100106. declare module BABYLON {
  100107. /**
  100108. * Represents the different options available during the creation of
  100109. * a Environment helper.
  100110. *
  100111. * This can control the default ground, skybox and image processing setup of your scene.
  100112. */
  100113. export interface IEnvironmentHelperOptions {
  100114. /**
  100115. * Specifies wether or not to create a ground.
  100116. * True by default.
  100117. */
  100118. createGround: boolean;
  100119. /**
  100120. * Specifies the ground size.
  100121. * 15 by default.
  100122. */
  100123. groundSize: number;
  100124. /**
  100125. * The texture used on the ground for the main color.
  100126. * Comes from the BabylonJS CDN by default.
  100127. *
  100128. * Remarks: Can be either a texture or a url.
  100129. */
  100130. groundTexture: string | BaseTexture;
  100131. /**
  100132. * The color mixed in the ground texture by default.
  100133. * BabylonJS clearColor by default.
  100134. */
  100135. groundColor: Color3;
  100136. /**
  100137. * Specifies the ground opacity.
  100138. * 1 by default.
  100139. */
  100140. groundOpacity: number;
  100141. /**
  100142. * Enables the ground to receive shadows.
  100143. * True by default.
  100144. */
  100145. enableGroundShadow: boolean;
  100146. /**
  100147. * Helps preventing the shadow to be fully black on the ground.
  100148. * 0.5 by default.
  100149. */
  100150. groundShadowLevel: number;
  100151. /**
  100152. * Creates a mirror texture attach to the ground.
  100153. * false by default.
  100154. */
  100155. enableGroundMirror: boolean;
  100156. /**
  100157. * Specifies the ground mirror size ratio.
  100158. * 0.3 by default as the default kernel is 64.
  100159. */
  100160. groundMirrorSizeRatio: number;
  100161. /**
  100162. * Specifies the ground mirror blur kernel size.
  100163. * 64 by default.
  100164. */
  100165. groundMirrorBlurKernel: number;
  100166. /**
  100167. * Specifies the ground mirror visibility amount.
  100168. * 1 by default
  100169. */
  100170. groundMirrorAmount: number;
  100171. /**
  100172. * Specifies the ground mirror reflectance weight.
  100173. * This uses the standard weight of the background material to setup the fresnel effect
  100174. * of the mirror.
  100175. * 1 by default.
  100176. */
  100177. groundMirrorFresnelWeight: number;
  100178. /**
  100179. * Specifies the ground mirror Falloff distance.
  100180. * This can helps reducing the size of the reflection.
  100181. * 0 by Default.
  100182. */
  100183. groundMirrorFallOffDistance: number;
  100184. /**
  100185. * Specifies the ground mirror texture type.
  100186. * Unsigned Int by Default.
  100187. */
  100188. groundMirrorTextureType: number;
  100189. /**
  100190. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  100191. * the shown objects.
  100192. */
  100193. groundYBias: number;
  100194. /**
  100195. * Specifies wether or not to create a skybox.
  100196. * True by default.
  100197. */
  100198. createSkybox: boolean;
  100199. /**
  100200. * Specifies the skybox size.
  100201. * 20 by default.
  100202. */
  100203. skyboxSize: number;
  100204. /**
  100205. * The texture used on the skybox for the main color.
  100206. * Comes from the BabylonJS CDN by default.
  100207. *
  100208. * Remarks: Can be either a texture or a url.
  100209. */
  100210. skyboxTexture: string | BaseTexture;
  100211. /**
  100212. * The color mixed in the skybox texture by default.
  100213. * BabylonJS clearColor by default.
  100214. */
  100215. skyboxColor: Color3;
  100216. /**
  100217. * The background rotation around the Y axis of the scene.
  100218. * This helps aligning the key lights of your scene with the background.
  100219. * 0 by default.
  100220. */
  100221. backgroundYRotation: number;
  100222. /**
  100223. * Compute automatically the size of the elements to best fit with the scene.
  100224. */
  100225. sizeAuto: boolean;
  100226. /**
  100227. * Default position of the rootMesh if autoSize is not true.
  100228. */
  100229. rootPosition: Vector3;
  100230. /**
  100231. * Sets up the image processing in the scene.
  100232. * true by default.
  100233. */
  100234. setupImageProcessing: boolean;
  100235. /**
  100236. * The texture used as your environment texture in the scene.
  100237. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100238. *
  100239. * Remarks: Can be either a texture or a url.
  100240. */
  100241. environmentTexture: string | BaseTexture;
  100242. /**
  100243. * The value of the exposure to apply to the scene.
  100244. * 0.6 by default if setupImageProcessing is true.
  100245. */
  100246. cameraExposure: number;
  100247. /**
  100248. * The value of the contrast to apply to the scene.
  100249. * 1.6 by default if setupImageProcessing is true.
  100250. */
  100251. cameraContrast: number;
  100252. /**
  100253. * Specifies wether or not tonemapping should be enabled in the scene.
  100254. * true by default if setupImageProcessing is true.
  100255. */
  100256. toneMappingEnabled: boolean;
  100257. }
  100258. /**
  100259. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100260. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100261. * It also helps with the default setup of your imageProcessing configuration.
  100262. */
  100263. export class EnvironmentHelper {
  100264. /**
  100265. * Default ground texture URL.
  100266. */
  100267. private static _groundTextureCDNUrl;
  100268. /**
  100269. * Default skybox texture URL.
  100270. */
  100271. private static _skyboxTextureCDNUrl;
  100272. /**
  100273. * Default environment texture URL.
  100274. */
  100275. private static _environmentTextureCDNUrl;
  100276. /**
  100277. * Creates the default options for the helper.
  100278. */
  100279. private static _getDefaultOptions;
  100280. private _rootMesh;
  100281. /**
  100282. * Gets the root mesh created by the helper.
  100283. */
  100284. readonly rootMesh: Mesh;
  100285. private _skybox;
  100286. /**
  100287. * Gets the skybox created by the helper.
  100288. */
  100289. readonly skybox: Nullable<Mesh>;
  100290. private _skyboxTexture;
  100291. /**
  100292. * Gets the skybox texture created by the helper.
  100293. */
  100294. readonly skyboxTexture: Nullable<BaseTexture>;
  100295. private _skyboxMaterial;
  100296. /**
  100297. * Gets the skybox material created by the helper.
  100298. */
  100299. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100300. private _ground;
  100301. /**
  100302. * Gets the ground mesh created by the helper.
  100303. */
  100304. readonly ground: Nullable<Mesh>;
  100305. private _groundTexture;
  100306. /**
  100307. * Gets the ground texture created by the helper.
  100308. */
  100309. readonly groundTexture: Nullable<BaseTexture>;
  100310. private _groundMirror;
  100311. /**
  100312. * Gets the ground mirror created by the helper.
  100313. */
  100314. readonly groundMirror: Nullable<MirrorTexture>;
  100315. /**
  100316. * Gets the ground mirror render list to helps pushing the meshes
  100317. * you wish in the ground reflection.
  100318. */
  100319. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100320. private _groundMaterial;
  100321. /**
  100322. * Gets the ground material created by the helper.
  100323. */
  100324. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100325. /**
  100326. * Stores the creation options.
  100327. */
  100328. private readonly _scene;
  100329. private _options;
  100330. /**
  100331. * This observable will be notified with any error during the creation of the environment,
  100332. * mainly texture creation errors.
  100333. */
  100334. onErrorObservable: Observable<{
  100335. message?: string;
  100336. exception?: any;
  100337. }>;
  100338. /**
  100339. * constructor
  100340. * @param options Defines the options we want to customize the helper
  100341. * @param scene The scene to add the material to
  100342. */
  100343. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100344. /**
  100345. * Updates the background according to the new options
  100346. * @param options
  100347. */
  100348. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100349. /**
  100350. * Sets the primary color of all the available elements.
  100351. * @param color the main color to affect to the ground and the background
  100352. */
  100353. setMainColor(color: Color3): void;
  100354. /**
  100355. * Setup the image processing according to the specified options.
  100356. */
  100357. private _setupImageProcessing;
  100358. /**
  100359. * Setup the environment texture according to the specified options.
  100360. */
  100361. private _setupEnvironmentTexture;
  100362. /**
  100363. * Setup the background according to the specified options.
  100364. */
  100365. private _setupBackground;
  100366. /**
  100367. * Get the scene sizes according to the setup.
  100368. */
  100369. private _getSceneSize;
  100370. /**
  100371. * Setup the ground according to the specified options.
  100372. */
  100373. private _setupGround;
  100374. /**
  100375. * Setup the ground material according to the specified options.
  100376. */
  100377. private _setupGroundMaterial;
  100378. /**
  100379. * Setup the ground diffuse texture according to the specified options.
  100380. */
  100381. private _setupGroundDiffuseTexture;
  100382. /**
  100383. * Setup the ground mirror texture according to the specified options.
  100384. */
  100385. private _setupGroundMirrorTexture;
  100386. /**
  100387. * Setup the ground to receive the mirror texture.
  100388. */
  100389. private _setupMirrorInGroundMaterial;
  100390. /**
  100391. * Setup the skybox according to the specified options.
  100392. */
  100393. private _setupSkybox;
  100394. /**
  100395. * Setup the skybox material according to the specified options.
  100396. */
  100397. private _setupSkyboxMaterial;
  100398. /**
  100399. * Setup the skybox reflection texture according to the specified options.
  100400. */
  100401. private _setupSkyboxReflectionTexture;
  100402. private _errorHandler;
  100403. /**
  100404. * Dispose all the elements created by the Helper.
  100405. */
  100406. dispose(): void;
  100407. }
  100408. }
  100409. declare module BABYLON {
  100410. /**
  100411. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100412. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100413. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100414. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100415. */
  100416. export class PhotoDome extends TransformNode {
  100417. private _useDirectMapping;
  100418. /**
  100419. * The texture being displayed on the sphere
  100420. */
  100421. protected _photoTexture: Texture;
  100422. /**
  100423. * Gets or sets the texture being displayed on the sphere
  100424. */
  100425. photoTexture: Texture;
  100426. /**
  100427. * Observable raised when an error occured while loading the 360 image
  100428. */
  100429. onLoadErrorObservable: Observable<string>;
  100430. /**
  100431. * The skybox material
  100432. */
  100433. protected _material: BackgroundMaterial;
  100434. /**
  100435. * The surface used for the skybox
  100436. */
  100437. protected _mesh: Mesh;
  100438. /**
  100439. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100440. * Also see the options.resolution property.
  100441. */
  100442. fovMultiplier: number;
  100443. /**
  100444. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100445. * @param name Element's name, child elements will append suffixes for their own names.
  100446. * @param urlsOfPhoto defines the url of the photo to display
  100447. * @param options defines an object containing optional or exposed sub element properties
  100448. * @param onError defines a callback called when an error occured while loading the texture
  100449. */
  100450. constructor(name: string, urlOfPhoto: string, options: {
  100451. resolution?: number;
  100452. size?: number;
  100453. useDirectMapping?: boolean;
  100454. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100455. /**
  100456. * Releases resources associated with this node.
  100457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100459. */
  100460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100461. }
  100462. }
  100463. declare module BABYLON {
  100464. /**
  100465. * Class used to host texture specific utilities
  100466. */
  100467. export class TextureTools {
  100468. /**
  100469. * Uses the GPU to create a copy texture rescaled at a given size
  100470. * @param texture Texture to copy from
  100471. * @param width defines the desired width
  100472. * @param height defines the desired height
  100473. * @param useBilinearMode defines if bilinear mode has to be used
  100474. * @return the generated texture
  100475. */
  100476. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100477. /**
  100478. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100479. * @param scene defines the hosting scene
  100480. * @returns the environment BRDF texture
  100481. */
  100482. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100483. private static _environmentBRDFBase64Texture;
  100484. }
  100485. }
  100486. declare module BABYLON {
  100487. /**
  100488. * @hidden
  100489. */
  100490. export interface IMaterialClearCoatDefines {
  100491. CLEARCOAT: boolean;
  100492. CLEARCOAT_DEFAULTIOR: boolean;
  100493. CLEARCOAT_TEXTURE: boolean;
  100494. CLEARCOAT_TEXTUREDIRECTUV: number;
  100495. CLEARCOAT_BUMP: boolean;
  100496. CLEARCOAT_BUMPDIRECTUV: number;
  100497. CLEARCOAT_TINT: boolean;
  100498. CLEARCOAT_TINT_TEXTURE: boolean;
  100499. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100500. /** @hidden */
  100501. _areTexturesDirty: boolean;
  100502. }
  100503. /**
  100504. * Define the code related to the clear coat parameters of the pbr material.
  100505. */
  100506. export class PBRClearCoatConfiguration {
  100507. /**
  100508. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100509. * The default fits with a polyurethane material.
  100510. */
  100511. private static readonly _DefaultIndiceOfRefraction;
  100512. private _isEnabled;
  100513. /**
  100514. * Defines if the clear coat is enabled in the material.
  100515. */
  100516. isEnabled: boolean;
  100517. /**
  100518. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100519. */
  100520. intensity: number;
  100521. /**
  100522. * Defines the clear coat layer roughness.
  100523. */
  100524. roughness: number;
  100525. private _indiceOfRefraction;
  100526. /**
  100527. * Defines the indice of refraction of the clear coat.
  100528. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100529. * The default fits with a polyurethane material.
  100530. * Changing the default value is more performance intensive.
  100531. */
  100532. indiceOfRefraction: number;
  100533. private _texture;
  100534. /**
  100535. * Stores the clear coat values in a texture.
  100536. */
  100537. texture: Nullable<BaseTexture>;
  100538. private _bumpTexture;
  100539. /**
  100540. * Define the clear coat specific bump texture.
  100541. */
  100542. bumpTexture: Nullable<BaseTexture>;
  100543. private _isTintEnabled;
  100544. /**
  100545. * Defines if the clear coat tint is enabled in the material.
  100546. */
  100547. isTintEnabled: boolean;
  100548. /**
  100549. * Defines if the clear coat tint is enabled in the material.
  100550. * This is only use if tint is enabled
  100551. */
  100552. tintColor: Color3;
  100553. /**
  100554. * Defines if the distance at which the tint color should be found in the
  100555. * clear coat media.
  100556. * This is only use if tint is enabled
  100557. */
  100558. tintColorAtDistance: number;
  100559. /**
  100560. * Defines the clear coat layer thickness.
  100561. * This is only use if tint is enabled
  100562. */
  100563. tintThickness: number;
  100564. private _tintTexture;
  100565. /**
  100566. * Stores the clear tint values in a texture.
  100567. * rgb is tint
  100568. * a is a thickness factor
  100569. */
  100570. tintTexture: Nullable<BaseTexture>;
  100571. /** @hidden */
  100572. private _internalMarkAllSubMeshesAsTexturesDirty;
  100573. /** @hidden */
  100574. _markAllSubMeshesAsTexturesDirty(): void;
  100575. /**
  100576. * Instantiate a new istance of clear coat configuration.
  100577. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100578. */
  100579. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100580. /**
  100581. * Specifies that the submesh is ready to be used.
  100582. * @param defines the list of "defines" to update.
  100583. * @param scene defines the scene the material belongs to.
  100584. * @param engine defines the engine the material belongs to.
  100585. * @param disableBumpMap defines wether the material disables bump or not.
  100586. * @returns - boolean indicating that the submesh is ready or not.
  100587. */
  100588. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100589. /**
  100590. * Checks to see if a texture is used in the material.
  100591. * @param defines the list of "defines" to update.
  100592. * @param scene defines the scene to the material belongs to.
  100593. */
  100594. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100595. /**
  100596. * Binds the material data.
  100597. * @param uniformBuffer defines the Uniform buffer to fill in.
  100598. * @param scene defines the scene the material belongs to.
  100599. * @param engine defines the engine the material belongs to.
  100600. * @param disableBumpMap defines wether the material disables bump or not.
  100601. * @param isFrozen defines wether the material is frozen or not.
  100602. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100603. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100604. */
  100605. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100606. /**
  100607. * Checks to see if a texture is used in the material.
  100608. * @param texture - Base texture to use.
  100609. * @returns - Boolean specifying if a texture is used in the material.
  100610. */
  100611. hasTexture(texture: BaseTexture): boolean;
  100612. /**
  100613. * Returns an array of the actively used textures.
  100614. * @param activeTextures Array of BaseTextures
  100615. */
  100616. getActiveTextures(activeTextures: BaseTexture[]): void;
  100617. /**
  100618. * Returns the animatable textures.
  100619. * @param animatables Array of animatable textures.
  100620. */
  100621. getAnimatables(animatables: IAnimatable[]): void;
  100622. /**
  100623. * Disposes the resources of the material.
  100624. * @param forceDisposeTextures - Forces the disposal of all textures.
  100625. */
  100626. dispose(forceDisposeTextures?: boolean): void;
  100627. /**
  100628. * Get the current class name of the texture useful for serialization or dynamic coding.
  100629. * @returns "PBRClearCoatConfiguration"
  100630. */
  100631. getClassName(): string;
  100632. /**
  100633. * Add fallbacks to the effect fallbacks list.
  100634. * @param defines defines the Base texture to use.
  100635. * @param fallbacks defines the current fallback list.
  100636. * @param currentRank defines the current fallback rank.
  100637. * @returns the new fallback rank.
  100638. */
  100639. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100640. /**
  100641. * Add the required uniforms to the current list.
  100642. * @param uniforms defines the current uniform list.
  100643. */
  100644. static AddUniforms(uniforms: string[]): void;
  100645. /**
  100646. * Add the required samplers to the current list.
  100647. * @param samplers defines the current sampler list.
  100648. */
  100649. static AddSamplers(samplers: string[]): void;
  100650. /**
  100651. * Add the required uniforms to the current buffer.
  100652. * @param uniformBuffer defines the current uniform buffer.
  100653. */
  100654. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100655. /**
  100656. * Makes a duplicate of the current configuration into another one.
  100657. * @param clearCoatConfiguration define the config where to copy the info
  100658. */
  100659. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100660. /**
  100661. * Serializes this clear coat configuration.
  100662. * @returns - An object with the serialized config.
  100663. */
  100664. serialize(): any;
  100665. /**
  100666. * Parses a Clear Coat Configuration from a serialized object.
  100667. * @param source - Serialized object.
  100668. */
  100669. parse(source: any): void;
  100670. }
  100671. }
  100672. declare module BABYLON {
  100673. /**
  100674. * @hidden
  100675. */
  100676. export interface IMaterialAnisotropicDefines {
  100677. ANISOTROPIC: boolean;
  100678. ANISOTROPIC_TEXTURE: boolean;
  100679. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100680. MAINUV1: boolean;
  100681. _areTexturesDirty: boolean;
  100682. _needUVs: boolean;
  100683. }
  100684. /**
  100685. * Define the code related to the anisotropic parameters of the pbr material.
  100686. */
  100687. export class PBRAnisotropicConfiguration {
  100688. private _isEnabled;
  100689. /**
  100690. * Defines if the anisotropy is enabled in the material.
  100691. */
  100692. isEnabled: boolean;
  100693. /**
  100694. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100695. */
  100696. intensity: number;
  100697. /**
  100698. * Defines if the effect is along the tangents, bitangents or in between.
  100699. * By default, the effect is "strectching" the highlights along the tangents.
  100700. */
  100701. direction: Vector2;
  100702. private _texture;
  100703. /**
  100704. * Stores the anisotropy values in a texture.
  100705. * rg is direction (like normal from -1 to 1)
  100706. * b is a intensity
  100707. */
  100708. texture: Nullable<BaseTexture>;
  100709. /** @hidden */
  100710. private _internalMarkAllSubMeshesAsTexturesDirty;
  100711. /** @hidden */
  100712. _markAllSubMeshesAsTexturesDirty(): void;
  100713. /**
  100714. * Instantiate a new istance of anisotropy configuration.
  100715. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100716. */
  100717. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100718. /**
  100719. * Specifies that the submesh is ready to be used.
  100720. * @param defines the list of "defines" to update.
  100721. * @param scene defines the scene the material belongs to.
  100722. * @returns - boolean indicating that the submesh is ready or not.
  100723. */
  100724. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100725. /**
  100726. * Checks to see if a texture is used in the material.
  100727. * @param defines the list of "defines" to update.
  100728. * @param mesh the mesh we are preparing the defines for.
  100729. * @param scene defines the scene the material belongs to.
  100730. */
  100731. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100732. /**
  100733. * Binds the material data.
  100734. * @param uniformBuffer defines the Uniform buffer to fill in.
  100735. * @param scene defines the scene the material belongs to.
  100736. * @param isFrozen defines wether the material is frozen or not.
  100737. */
  100738. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100739. /**
  100740. * Checks to see if a texture is used in the material.
  100741. * @param texture - Base texture to use.
  100742. * @returns - Boolean specifying if a texture is used in the material.
  100743. */
  100744. hasTexture(texture: BaseTexture): boolean;
  100745. /**
  100746. * Returns an array of the actively used textures.
  100747. * @param activeTextures Array of BaseTextures
  100748. */
  100749. getActiveTextures(activeTextures: BaseTexture[]): void;
  100750. /**
  100751. * Returns the animatable textures.
  100752. * @param animatables Array of animatable textures.
  100753. */
  100754. getAnimatables(animatables: IAnimatable[]): void;
  100755. /**
  100756. * Disposes the resources of the material.
  100757. * @param forceDisposeTextures - Forces the disposal of all textures.
  100758. */
  100759. dispose(forceDisposeTextures?: boolean): void;
  100760. /**
  100761. * Get the current class name of the texture useful for serialization or dynamic coding.
  100762. * @returns "PBRAnisotropicConfiguration"
  100763. */
  100764. getClassName(): string;
  100765. /**
  100766. * Add fallbacks to the effect fallbacks list.
  100767. * @param defines defines the Base texture to use.
  100768. * @param fallbacks defines the current fallback list.
  100769. * @param currentRank defines the current fallback rank.
  100770. * @returns the new fallback rank.
  100771. */
  100772. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100773. /**
  100774. * Add the required uniforms to the current list.
  100775. * @param uniforms defines the current uniform list.
  100776. */
  100777. static AddUniforms(uniforms: string[]): void;
  100778. /**
  100779. * Add the required uniforms to the current buffer.
  100780. * @param uniformBuffer defines the current uniform buffer.
  100781. */
  100782. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100783. /**
  100784. * Add the required samplers to the current list.
  100785. * @param samplers defines the current sampler list.
  100786. */
  100787. static AddSamplers(samplers: string[]): void;
  100788. /**
  100789. * Makes a duplicate of the current configuration into another one.
  100790. * @param anisotropicConfiguration define the config where to copy the info
  100791. */
  100792. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100793. /**
  100794. * Serializes this anisotropy configuration.
  100795. * @returns - An object with the serialized config.
  100796. */
  100797. serialize(): any;
  100798. /**
  100799. * Parses a anisotropy Configuration from a serialized object.
  100800. * @param source - Serialized object.
  100801. */
  100802. parse(source: any): void;
  100803. }
  100804. }
  100805. declare module BABYLON {
  100806. /**
  100807. * @hidden
  100808. */
  100809. export interface IMaterialBRDFDefines {
  100810. BRDF_V_HEIGHT_CORRELATED: boolean;
  100811. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100812. /** @hidden */
  100813. _areMiscDirty: boolean;
  100814. }
  100815. /**
  100816. * Define the code related to the BRDF parameters of the pbr material.
  100817. */
  100818. export class PBRBRDFConfiguration {
  100819. private _useEnergyConservation;
  100820. /**
  100821. * Defines if the material uses energy conservation.
  100822. */
  100823. useEnergyConservation: boolean;
  100824. private _useSmithVisibilityHeightCorrelated;
  100825. /**
  100826. * LEGACY Mode set to false
  100827. * Defines if the material uses height smith correlated visibility term.
  100828. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100829. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100830. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100831. * Not relying on height correlated will also disable energy conservation.
  100832. */
  100833. useSmithVisibilityHeightCorrelated: boolean;
  100834. /** @hidden */
  100835. private _internalMarkAllSubMeshesAsMiscDirty;
  100836. /** @hidden */
  100837. _markAllSubMeshesAsMiscDirty(): void;
  100838. /**
  100839. * Instantiate a new istance of clear coat configuration.
  100840. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100841. */
  100842. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100843. /**
  100844. * Checks to see if a texture is used in the material.
  100845. * @param defines the list of "defines" to update.
  100846. */
  100847. prepareDefines(defines: IMaterialBRDFDefines): void;
  100848. /**
  100849. * Get the current class name of the texture useful for serialization or dynamic coding.
  100850. * @returns "PBRClearCoatConfiguration"
  100851. */
  100852. getClassName(): string;
  100853. /**
  100854. * Makes a duplicate of the current configuration into another one.
  100855. * @param brdfConfiguration define the config where to copy the info
  100856. */
  100857. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100858. /**
  100859. * Serializes this BRDF configuration.
  100860. * @returns - An object with the serialized config.
  100861. */
  100862. serialize(): any;
  100863. /**
  100864. * Parses a BRDF Configuration from a serialized object.
  100865. * @param source - Serialized object.
  100866. */
  100867. parse(source: any): void;
  100868. }
  100869. }
  100870. declare module BABYLON {
  100871. /**
  100872. * @hidden
  100873. */
  100874. export interface IMaterialSheenDefines {
  100875. SHEEN: boolean;
  100876. SHEEN_TEXTURE: boolean;
  100877. SHEEN_TEXTUREDIRECTUV: number;
  100878. SHEEN_LINKWITHALBEDO: boolean;
  100879. /** @hidden */
  100880. _areTexturesDirty: boolean;
  100881. }
  100882. /**
  100883. * Define the code related to the Sheen parameters of the pbr material.
  100884. */
  100885. export class PBRSheenConfiguration {
  100886. private _isEnabled;
  100887. /**
  100888. * Defines if the material uses sheen.
  100889. */
  100890. isEnabled: boolean;
  100891. private _linkSheenWithAlbedo;
  100892. /**
  100893. * Defines if the sheen is linked to the sheen color.
  100894. */
  100895. linkSheenWithAlbedo: boolean;
  100896. /**
  100897. * Defines the sheen intensity.
  100898. */
  100899. intensity: number;
  100900. /**
  100901. * Defines the sheen color.
  100902. */
  100903. color: Color3;
  100904. private _texture;
  100905. /**
  100906. * Stores the sheen tint values in a texture.
  100907. * rgb is tint
  100908. * a is a intensity
  100909. */
  100910. texture: Nullable<BaseTexture>;
  100911. /** @hidden */
  100912. private _internalMarkAllSubMeshesAsTexturesDirty;
  100913. /** @hidden */
  100914. _markAllSubMeshesAsTexturesDirty(): void;
  100915. /**
  100916. * Instantiate a new istance of clear coat configuration.
  100917. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100918. */
  100919. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100920. /**
  100921. * Specifies that the submesh is ready to be used.
  100922. * @param defines the list of "defines" to update.
  100923. * @param scene defines the scene the material belongs to.
  100924. * @returns - boolean indicating that the submesh is ready or not.
  100925. */
  100926. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  100927. /**
  100928. * Checks to see if a texture is used in the material.
  100929. * @param defines the list of "defines" to update.
  100930. * @param scene defines the scene the material belongs to.
  100931. */
  100932. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  100933. /**
  100934. * Binds the material data.
  100935. * @param uniformBuffer defines the Uniform buffer to fill in.
  100936. * @param scene defines the scene the material belongs to.
  100937. * @param isFrozen defines wether the material is frozen or not.
  100938. */
  100939. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100940. /**
  100941. * Checks to see if a texture is used in the material.
  100942. * @param texture - Base texture to use.
  100943. * @returns - Boolean specifying if a texture is used in the material.
  100944. */
  100945. hasTexture(texture: BaseTexture): boolean;
  100946. /**
  100947. * Returns an array of the actively used textures.
  100948. * @param activeTextures Array of BaseTextures
  100949. */
  100950. getActiveTextures(activeTextures: BaseTexture[]): void;
  100951. /**
  100952. * Returns the animatable textures.
  100953. * @param animatables Array of animatable textures.
  100954. */
  100955. getAnimatables(animatables: IAnimatable[]): void;
  100956. /**
  100957. * Disposes the resources of the material.
  100958. * @param forceDisposeTextures - Forces the disposal of all textures.
  100959. */
  100960. dispose(forceDisposeTextures?: boolean): void;
  100961. /**
  100962. * Get the current class name of the texture useful for serialization or dynamic coding.
  100963. * @returns "PBRSheenConfiguration"
  100964. */
  100965. getClassName(): string;
  100966. /**
  100967. * Add fallbacks to the effect fallbacks list.
  100968. * @param defines defines the Base texture to use.
  100969. * @param fallbacks defines the current fallback list.
  100970. * @param currentRank defines the current fallback rank.
  100971. * @returns the new fallback rank.
  100972. */
  100973. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100974. /**
  100975. * Add the required uniforms to the current list.
  100976. * @param uniforms defines the current uniform list.
  100977. */
  100978. static AddUniforms(uniforms: string[]): void;
  100979. /**
  100980. * Add the required uniforms to the current buffer.
  100981. * @param uniformBuffer defines the current uniform buffer.
  100982. */
  100983. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100984. /**
  100985. * Add the required samplers to the current list.
  100986. * @param samplers defines the current sampler list.
  100987. */
  100988. static AddSamplers(samplers: string[]): void;
  100989. /**
  100990. * Makes a duplicate of the current configuration into another one.
  100991. * @param sheenConfiguration define the config where to copy the info
  100992. */
  100993. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  100994. /**
  100995. * Serializes this BRDF configuration.
  100996. * @returns - An object with the serialized config.
  100997. */
  100998. serialize(): any;
  100999. /**
  101000. * Parses a Sheen Configuration from a serialized object.
  101001. * @param source - Serialized object.
  101002. */
  101003. parse(source: any): void;
  101004. }
  101005. }
  101006. declare module BABYLON {
  101007. /** @hidden */
  101008. export var pbrFragmentDeclaration: {
  101009. name: string;
  101010. shader: string;
  101011. };
  101012. }
  101013. declare module BABYLON {
  101014. /** @hidden */
  101015. export var pbrUboDeclaration: {
  101016. name: string;
  101017. shader: string;
  101018. };
  101019. }
  101020. declare module BABYLON {
  101021. /** @hidden */
  101022. export var pbrFunctions: {
  101023. name: string;
  101024. shader: string;
  101025. };
  101026. }
  101027. declare module BABYLON {
  101028. /** @hidden */
  101029. export var harmonicsFunctions: {
  101030. name: string;
  101031. shader: string;
  101032. };
  101033. }
  101034. declare module BABYLON {
  101035. /** @hidden */
  101036. export var pbrPreLightingFunctions: {
  101037. name: string;
  101038. shader: string;
  101039. };
  101040. }
  101041. declare module BABYLON {
  101042. /** @hidden */
  101043. export var pbrFalloffLightingFunctions: {
  101044. name: string;
  101045. shader: string;
  101046. };
  101047. }
  101048. declare module BABYLON {
  101049. /** @hidden */
  101050. export var pbrLightingFunctions: {
  101051. name: string;
  101052. shader: string;
  101053. };
  101054. }
  101055. declare module BABYLON {
  101056. /** @hidden */
  101057. export var pbrDebug: {
  101058. name: string;
  101059. shader: string;
  101060. };
  101061. }
  101062. declare module BABYLON {
  101063. /** @hidden */
  101064. export var pbrPixelShader: {
  101065. name: string;
  101066. shader: string;
  101067. };
  101068. }
  101069. declare module BABYLON {
  101070. /** @hidden */
  101071. export var pbrVertexDeclaration: {
  101072. name: string;
  101073. shader: string;
  101074. };
  101075. }
  101076. declare module BABYLON {
  101077. /** @hidden */
  101078. export var pbrVertexShader: {
  101079. name: string;
  101080. shader: string;
  101081. };
  101082. }
  101083. declare module BABYLON {
  101084. /**
  101085. * The Physically based material base class of BJS.
  101086. *
  101087. * This offers the main features of a standard PBR material.
  101088. * For more information, please refer to the documentation :
  101089. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101090. */
  101091. export abstract class PBRBaseMaterial extends PushMaterial {
  101092. /**
  101093. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101094. */
  101095. static readonly PBRMATERIAL_OPAQUE: number;
  101096. /**
  101097. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101098. */
  101099. static readonly PBRMATERIAL_ALPHATEST: number;
  101100. /**
  101101. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101102. */
  101103. static readonly PBRMATERIAL_ALPHABLEND: number;
  101104. /**
  101105. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101106. * They are also discarded below the alpha cutoff threshold to improve performances.
  101107. */
  101108. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101109. /**
  101110. * Defines the default value of how much AO map is occluding the analytical lights
  101111. * (point spot...).
  101112. */
  101113. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101114. /**
  101115. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  101116. */
  101117. static readonly LIGHTFALLOFF_PHYSICAL: number;
  101118. /**
  101119. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  101120. * to enhance interoperability with other engines.
  101121. */
  101122. static readonly LIGHTFALLOFF_GLTF: number;
  101123. /**
  101124. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  101125. * to enhance interoperability with other materials.
  101126. */
  101127. static readonly LIGHTFALLOFF_STANDARD: number;
  101128. /**
  101129. * Intensity of the direct lights e.g. the four lights available in your scene.
  101130. * This impacts both the direct diffuse and specular highlights.
  101131. */
  101132. protected _directIntensity: number;
  101133. /**
  101134. * Intensity of the emissive part of the material.
  101135. * This helps controlling the emissive effect without modifying the emissive color.
  101136. */
  101137. protected _emissiveIntensity: number;
  101138. /**
  101139. * Intensity of the environment e.g. how much the environment will light the object
  101140. * either through harmonics for rough material or through the refelction for shiny ones.
  101141. */
  101142. protected _environmentIntensity: number;
  101143. /**
  101144. * This is a special control allowing the reduction of the specular highlights coming from the
  101145. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101146. */
  101147. protected _specularIntensity: number;
  101148. /**
  101149. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  101150. */
  101151. private _lightingInfos;
  101152. /**
  101153. * Debug Control allowing disabling the bump map on this material.
  101154. */
  101155. protected _disableBumpMap: boolean;
  101156. /**
  101157. * AKA Diffuse Texture in standard nomenclature.
  101158. */
  101159. protected _albedoTexture: BaseTexture;
  101160. /**
  101161. * AKA Occlusion Texture in other nomenclature.
  101162. */
  101163. protected _ambientTexture: BaseTexture;
  101164. /**
  101165. * AKA Occlusion Texture Intensity in other nomenclature.
  101166. */
  101167. protected _ambientTextureStrength: number;
  101168. /**
  101169. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101170. * 1 means it completely occludes it
  101171. * 0 mean it has no impact
  101172. */
  101173. protected _ambientTextureImpactOnAnalyticalLights: number;
  101174. /**
  101175. * Stores the alpha values in a texture.
  101176. */
  101177. protected _opacityTexture: BaseTexture;
  101178. /**
  101179. * Stores the reflection values in a texture.
  101180. */
  101181. protected _reflectionTexture: BaseTexture;
  101182. /**
  101183. * Stores the refraction values in a texture.
  101184. */
  101185. protected _refractionTexture: BaseTexture;
  101186. /**
  101187. * Stores the emissive values in a texture.
  101188. */
  101189. protected _emissiveTexture: BaseTexture;
  101190. /**
  101191. * AKA Specular texture in other nomenclature.
  101192. */
  101193. protected _reflectivityTexture: BaseTexture;
  101194. /**
  101195. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101196. */
  101197. protected _metallicTexture: BaseTexture;
  101198. /**
  101199. * Specifies the metallic scalar of the metallic/roughness workflow.
  101200. * Can also be used to scale the metalness values of the metallic texture.
  101201. */
  101202. protected _metallic: Nullable<number>;
  101203. /**
  101204. * Specifies the roughness scalar of the metallic/roughness workflow.
  101205. * Can also be used to scale the roughness values of the metallic texture.
  101206. */
  101207. protected _roughness: Nullable<number>;
  101208. /**
  101209. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101210. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101211. */
  101212. protected _microSurfaceTexture: BaseTexture;
  101213. /**
  101214. * Stores surface normal data used to displace a mesh in a texture.
  101215. */
  101216. protected _bumpTexture: BaseTexture;
  101217. /**
  101218. * Stores the pre-calculated light information of a mesh in a texture.
  101219. */
  101220. protected _lightmapTexture: BaseTexture;
  101221. /**
  101222. * The color of a material in ambient lighting.
  101223. */
  101224. protected _ambientColor: Color3;
  101225. /**
  101226. * AKA Diffuse Color in other nomenclature.
  101227. */
  101228. protected _albedoColor: Color3;
  101229. /**
  101230. * AKA Specular Color in other nomenclature.
  101231. */
  101232. protected _reflectivityColor: Color3;
  101233. /**
  101234. * The color applied when light is reflected from a material.
  101235. */
  101236. protected _reflectionColor: Color3;
  101237. /**
  101238. * The color applied when light is emitted from a material.
  101239. */
  101240. protected _emissiveColor: Color3;
  101241. /**
  101242. * AKA Glossiness in other nomenclature.
  101243. */
  101244. protected _microSurface: number;
  101245. /**
  101246. * source material index of refraction (IOR)' / 'destination material IOR.
  101247. */
  101248. protected _indexOfRefraction: number;
  101249. /**
  101250. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101251. */
  101252. protected _invertRefractionY: boolean;
  101253. /**
  101254. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101255. * Materials half opaque for instance using refraction could benefit from this control.
  101256. */
  101257. protected _linkRefractionWithTransparency: boolean;
  101258. /**
  101259. * Specifies that the material will use the light map as a show map.
  101260. */
  101261. protected _useLightmapAsShadowmap: boolean;
  101262. /**
  101263. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101264. * makes the reflect vector face the model (under horizon).
  101265. */
  101266. protected _useHorizonOcclusion: boolean;
  101267. /**
  101268. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101269. * too much the area relying on ambient texture to define their ambient occlusion.
  101270. */
  101271. protected _useRadianceOcclusion: boolean;
  101272. /**
  101273. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101274. */
  101275. protected _useAlphaFromAlbedoTexture: boolean;
  101276. /**
  101277. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101278. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101279. */
  101280. protected _useSpecularOverAlpha: boolean;
  101281. /**
  101282. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101283. */
  101284. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101285. /**
  101286. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101287. */
  101288. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101289. /**
  101290. * Specifies if the metallic texture contains the roughness information in its green channel.
  101291. */
  101292. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101293. /**
  101294. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101295. */
  101296. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101297. /**
  101298. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101299. */
  101300. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101301. /**
  101302. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101303. */
  101304. protected _useAmbientInGrayScale: boolean;
  101305. /**
  101306. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101307. * The material will try to infer what glossiness each pixel should be.
  101308. */
  101309. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101310. /**
  101311. * Defines the falloff type used in this material.
  101312. * It by default is Physical.
  101313. */
  101314. protected _lightFalloff: number;
  101315. /**
  101316. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101317. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101318. */
  101319. protected _useRadianceOverAlpha: boolean;
  101320. /**
  101321. * Allows using an object space normal map (instead of tangent space).
  101322. */
  101323. protected _useObjectSpaceNormalMap: boolean;
  101324. /**
  101325. * Allows using the bump map in parallax mode.
  101326. */
  101327. protected _useParallax: boolean;
  101328. /**
  101329. * Allows using the bump map in parallax occlusion mode.
  101330. */
  101331. protected _useParallaxOcclusion: boolean;
  101332. /**
  101333. * Controls the scale bias of the parallax mode.
  101334. */
  101335. protected _parallaxScaleBias: number;
  101336. /**
  101337. * If sets to true, disables all the lights affecting the material.
  101338. */
  101339. protected _disableLighting: boolean;
  101340. /**
  101341. * Number of Simultaneous lights allowed on the material.
  101342. */
  101343. protected _maxSimultaneousLights: number;
  101344. /**
  101345. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101346. */
  101347. protected _invertNormalMapX: boolean;
  101348. /**
  101349. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101350. */
  101351. protected _invertNormalMapY: boolean;
  101352. /**
  101353. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101354. */
  101355. protected _twoSidedLighting: boolean;
  101356. /**
  101357. * Defines the alpha limits in alpha test mode.
  101358. */
  101359. protected _alphaCutOff: number;
  101360. /**
  101361. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101362. */
  101363. protected _forceAlphaTest: boolean;
  101364. /**
  101365. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101366. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101367. */
  101368. protected _useAlphaFresnel: boolean;
  101369. /**
  101370. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101371. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101372. */
  101373. protected _useLinearAlphaFresnel: boolean;
  101374. /**
  101375. * The transparency mode of the material.
  101376. */
  101377. protected _transparencyMode: Nullable<number>;
  101378. /**
  101379. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101380. * from cos thetav and roughness:
  101381. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101382. */
  101383. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101384. /**
  101385. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101386. */
  101387. protected _forceIrradianceInFragment: boolean;
  101388. /**
  101389. * Force normal to face away from face.
  101390. */
  101391. protected _forceNormalForward: boolean;
  101392. /**
  101393. * Enables specular anti aliasing in the PBR shader.
  101394. * It will both interacts on the Geometry for analytical and IBL lighting.
  101395. * It also prefilter the roughness map based on the bump values.
  101396. */
  101397. protected _enableSpecularAntiAliasing: boolean;
  101398. /**
  101399. * Default configuration related to image processing available in the PBR Material.
  101400. */
  101401. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101402. /**
  101403. * Keep track of the image processing observer to allow dispose and replace.
  101404. */
  101405. private _imageProcessingObserver;
  101406. /**
  101407. * Attaches a new image processing configuration to the PBR Material.
  101408. * @param configuration
  101409. */
  101410. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101411. /**
  101412. * Stores the available render targets.
  101413. */
  101414. private _renderTargets;
  101415. /**
  101416. * Sets the global ambient color for the material used in lighting calculations.
  101417. */
  101418. private _globalAmbientColor;
  101419. /**
  101420. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101421. */
  101422. private _useLogarithmicDepth;
  101423. /**
  101424. * If set to true, no lighting calculations will be applied.
  101425. */
  101426. private _unlit;
  101427. private _debugMode;
  101428. /**
  101429. * @hidden
  101430. * This is reserved for the inspector.
  101431. * Defines the material debug mode.
  101432. * It helps seeing only some components of the material while troubleshooting.
  101433. */
  101434. debugMode: number;
  101435. /**
  101436. * @hidden
  101437. * This is reserved for the inspector.
  101438. * Specify from where on screen the debug mode should start.
  101439. * The value goes from -1 (full screen) to 1 (not visible)
  101440. * It helps with side by side comparison against the final render
  101441. * This defaults to -1
  101442. */
  101443. private debugLimit;
  101444. /**
  101445. * @hidden
  101446. * This is reserved for the inspector.
  101447. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101448. * You can use the factor to better multiply the final value.
  101449. */
  101450. private debugFactor;
  101451. /**
  101452. * Defines the clear coat layer parameters for the material.
  101453. */
  101454. readonly clearCoat: PBRClearCoatConfiguration;
  101455. /**
  101456. * Defines the anisotropic parameters for the material.
  101457. */
  101458. readonly anisotropy: PBRAnisotropicConfiguration;
  101459. /**
  101460. * Defines the BRDF parameters for the material.
  101461. */
  101462. readonly brdf: PBRBRDFConfiguration;
  101463. /**
  101464. * Defines the Sheen parameters for the material.
  101465. */
  101466. readonly sheen: PBRSheenConfiguration;
  101467. /**
  101468. * Instantiates a new PBRMaterial instance.
  101469. *
  101470. * @param name The material name
  101471. * @param scene The scene the material will be use in.
  101472. */
  101473. constructor(name: string, scene: Scene);
  101474. /**
  101475. * Gets a boolean indicating that current material needs to register RTT
  101476. */
  101477. readonly hasRenderTargetTextures: boolean;
  101478. /**
  101479. * Gets the name of the material class.
  101480. */
  101481. getClassName(): string;
  101482. /**
  101483. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101484. */
  101485. /**
  101486. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101487. */
  101488. useLogarithmicDepth: boolean;
  101489. /**
  101490. * Gets the current transparency mode.
  101491. */
  101492. /**
  101493. * Sets the transparency mode of the material.
  101494. *
  101495. * | Value | Type | Description |
  101496. * | ----- | ----------------------------------- | ----------- |
  101497. * | 0 | OPAQUE | |
  101498. * | 1 | ALPHATEST | |
  101499. * | 2 | ALPHABLEND | |
  101500. * | 3 | ALPHATESTANDBLEND | |
  101501. *
  101502. */
  101503. transparencyMode: Nullable<number>;
  101504. /**
  101505. * Returns true if alpha blending should be disabled.
  101506. */
  101507. private readonly _disableAlphaBlending;
  101508. /**
  101509. * Specifies whether or not this material should be rendered in alpha blend mode.
  101510. */
  101511. needAlphaBlending(): boolean;
  101512. /**
  101513. * Specifies if the mesh will require alpha blending.
  101514. * @param mesh - BJS mesh.
  101515. */
  101516. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101517. /**
  101518. * Specifies whether or not this material should be rendered in alpha test mode.
  101519. */
  101520. needAlphaTesting(): boolean;
  101521. /**
  101522. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101523. */
  101524. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101525. /**
  101526. * Gets the texture used for the alpha test.
  101527. */
  101528. getAlphaTestTexture(): BaseTexture;
  101529. /**
  101530. * Specifies that the submesh is ready to be used.
  101531. * @param mesh - BJS mesh.
  101532. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101533. * @param useInstances - Specifies that instances should be used.
  101534. * @returns - boolean indicating that the submesh is ready or not.
  101535. */
  101536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101537. /**
  101538. * Specifies if the material uses metallic roughness workflow.
  101539. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101540. */
  101541. isMetallicWorkflow(): boolean;
  101542. private _prepareEffect;
  101543. private _prepareDefines;
  101544. /**
  101545. * Force shader compilation
  101546. */
  101547. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101548. clipPlane: boolean;
  101549. }>): void;
  101550. /**
  101551. * Initializes the uniform buffer layout for the shader.
  101552. */
  101553. buildUniformLayout(): void;
  101554. /**
  101555. * Unbinds the textures.
  101556. */
  101557. unbind(): void;
  101558. /**
  101559. * Binds the submesh data.
  101560. * @param world - The world matrix.
  101561. * @param mesh - The BJS mesh.
  101562. * @param subMesh - A submesh of the BJS mesh.
  101563. */
  101564. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101565. /**
  101566. * Returns the animatable textures.
  101567. * @returns - Array of animatable textures.
  101568. */
  101569. getAnimatables(): IAnimatable[];
  101570. /**
  101571. * Returns the texture used for reflections.
  101572. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101573. */
  101574. private _getReflectionTexture;
  101575. /**
  101576. * Returns the texture used for refraction or null if none is used.
  101577. * @returns - Refection texture if present. If no refraction texture and refraction
  101578. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101579. */
  101580. private _getRefractionTexture;
  101581. /**
  101582. * Returns an array of the actively used textures.
  101583. * @returns - Array of BaseTextures
  101584. */
  101585. getActiveTextures(): BaseTexture[];
  101586. /**
  101587. * Checks to see if a texture is used in the material.
  101588. * @param texture - Base texture to use.
  101589. * @returns - Boolean specifying if a texture is used in the material.
  101590. */
  101591. hasTexture(texture: BaseTexture): boolean;
  101592. /**
  101593. * Disposes the resources of the material.
  101594. * @param forceDisposeEffect - Forces the disposal of effects.
  101595. * @param forceDisposeTextures - Forces the disposal of all textures.
  101596. */
  101597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101598. }
  101599. }
  101600. declare module BABYLON {
  101601. /**
  101602. * The Physically based material of BJS.
  101603. *
  101604. * This offers the main features of a standard PBR material.
  101605. * For more information, please refer to the documentation :
  101606. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101607. */
  101608. export class PBRMaterial extends PBRBaseMaterial {
  101609. /**
  101610. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101611. */
  101612. static readonly PBRMATERIAL_OPAQUE: number;
  101613. /**
  101614. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101615. */
  101616. static readonly PBRMATERIAL_ALPHATEST: number;
  101617. /**
  101618. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101619. */
  101620. static readonly PBRMATERIAL_ALPHABLEND: number;
  101621. /**
  101622. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101623. * They are also discarded below the alpha cutoff threshold to improve performances.
  101624. */
  101625. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101626. /**
  101627. * Defines the default value of how much AO map is occluding the analytical lights
  101628. * (point spot...).
  101629. */
  101630. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101631. /**
  101632. * Intensity of the direct lights e.g. the four lights available in your scene.
  101633. * This impacts both the direct diffuse and specular highlights.
  101634. */
  101635. directIntensity: number;
  101636. /**
  101637. * Intensity of the emissive part of the material.
  101638. * This helps controlling the emissive effect without modifying the emissive color.
  101639. */
  101640. emissiveIntensity: number;
  101641. /**
  101642. * Intensity of the environment e.g. how much the environment will light the object
  101643. * either through harmonics for rough material or through the refelction for shiny ones.
  101644. */
  101645. environmentIntensity: number;
  101646. /**
  101647. * This is a special control allowing the reduction of the specular highlights coming from the
  101648. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101649. */
  101650. specularIntensity: number;
  101651. /**
  101652. * Debug Control allowing disabling the bump map on this material.
  101653. */
  101654. disableBumpMap: boolean;
  101655. /**
  101656. * AKA Diffuse Texture in standard nomenclature.
  101657. */
  101658. albedoTexture: BaseTexture;
  101659. /**
  101660. * AKA Occlusion Texture in other nomenclature.
  101661. */
  101662. ambientTexture: BaseTexture;
  101663. /**
  101664. * AKA Occlusion Texture Intensity in other nomenclature.
  101665. */
  101666. ambientTextureStrength: number;
  101667. /**
  101668. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101669. * 1 means it completely occludes it
  101670. * 0 mean it has no impact
  101671. */
  101672. ambientTextureImpactOnAnalyticalLights: number;
  101673. /**
  101674. * Stores the alpha values in a texture.
  101675. */
  101676. opacityTexture: BaseTexture;
  101677. /**
  101678. * Stores the reflection values in a texture.
  101679. */
  101680. reflectionTexture: Nullable<BaseTexture>;
  101681. /**
  101682. * Stores the emissive values in a texture.
  101683. */
  101684. emissiveTexture: BaseTexture;
  101685. /**
  101686. * AKA Specular texture in other nomenclature.
  101687. */
  101688. reflectivityTexture: BaseTexture;
  101689. /**
  101690. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101691. */
  101692. metallicTexture: BaseTexture;
  101693. /**
  101694. * Specifies the metallic scalar of the metallic/roughness workflow.
  101695. * Can also be used to scale the metalness values of the metallic texture.
  101696. */
  101697. metallic: Nullable<number>;
  101698. /**
  101699. * Specifies the roughness scalar of the metallic/roughness workflow.
  101700. * Can also be used to scale the roughness values of the metallic texture.
  101701. */
  101702. roughness: Nullable<number>;
  101703. /**
  101704. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101705. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101706. */
  101707. microSurfaceTexture: BaseTexture;
  101708. /**
  101709. * Stores surface normal data used to displace a mesh in a texture.
  101710. */
  101711. bumpTexture: BaseTexture;
  101712. /**
  101713. * Stores the pre-calculated light information of a mesh in a texture.
  101714. */
  101715. lightmapTexture: BaseTexture;
  101716. /**
  101717. * Stores the refracted light information in a texture.
  101718. */
  101719. refractionTexture: BaseTexture;
  101720. /**
  101721. * The color of a material in ambient lighting.
  101722. */
  101723. ambientColor: Color3;
  101724. /**
  101725. * AKA Diffuse Color in other nomenclature.
  101726. */
  101727. albedoColor: Color3;
  101728. /**
  101729. * AKA Specular Color in other nomenclature.
  101730. */
  101731. reflectivityColor: Color3;
  101732. /**
  101733. * The color reflected from the material.
  101734. */
  101735. reflectionColor: Color3;
  101736. /**
  101737. * The color emitted from the material.
  101738. */
  101739. emissiveColor: Color3;
  101740. /**
  101741. * AKA Glossiness in other nomenclature.
  101742. */
  101743. microSurface: number;
  101744. /**
  101745. * source material index of refraction (IOR)' / 'destination material IOR.
  101746. */
  101747. indexOfRefraction: number;
  101748. /**
  101749. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101750. */
  101751. invertRefractionY: boolean;
  101752. /**
  101753. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101754. * Materials half opaque for instance using refraction could benefit from this control.
  101755. */
  101756. linkRefractionWithTransparency: boolean;
  101757. /**
  101758. * If true, the light map contains occlusion information instead of lighting info.
  101759. */
  101760. useLightmapAsShadowmap: boolean;
  101761. /**
  101762. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101763. */
  101764. useAlphaFromAlbedoTexture: boolean;
  101765. /**
  101766. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101767. */
  101768. forceAlphaTest: boolean;
  101769. /**
  101770. * Defines the alpha limits in alpha test mode.
  101771. */
  101772. alphaCutOff: number;
  101773. /**
  101774. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101775. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101776. */
  101777. useSpecularOverAlpha: boolean;
  101778. /**
  101779. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101780. */
  101781. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101782. /**
  101783. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101784. */
  101785. useRoughnessFromMetallicTextureAlpha: boolean;
  101786. /**
  101787. * Specifies if the metallic texture contains the roughness information in its green channel.
  101788. */
  101789. useRoughnessFromMetallicTextureGreen: boolean;
  101790. /**
  101791. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101792. */
  101793. useMetallnessFromMetallicTextureBlue: boolean;
  101794. /**
  101795. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101796. */
  101797. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101798. /**
  101799. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101800. */
  101801. useAmbientInGrayScale: boolean;
  101802. /**
  101803. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101804. * The material will try to infer what glossiness each pixel should be.
  101805. */
  101806. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101807. /**
  101808. * BJS is using an harcoded light falloff based on a manually sets up range.
  101809. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101810. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101811. */
  101812. /**
  101813. * BJS is using an harcoded light falloff based on a manually sets up range.
  101814. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101815. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101816. */
  101817. usePhysicalLightFalloff: boolean;
  101818. /**
  101819. * In order to support the falloff compatibility with gltf, a special mode has been added
  101820. * to reproduce the gltf light falloff.
  101821. */
  101822. /**
  101823. * In order to support the falloff compatibility with gltf, a special mode has been added
  101824. * to reproduce the gltf light falloff.
  101825. */
  101826. useGLTFLightFalloff: boolean;
  101827. /**
  101828. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101829. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101830. */
  101831. useRadianceOverAlpha: boolean;
  101832. /**
  101833. * Allows using an object space normal map (instead of tangent space).
  101834. */
  101835. useObjectSpaceNormalMap: boolean;
  101836. /**
  101837. * Allows using the bump map in parallax mode.
  101838. */
  101839. useParallax: boolean;
  101840. /**
  101841. * Allows using the bump map in parallax occlusion mode.
  101842. */
  101843. useParallaxOcclusion: boolean;
  101844. /**
  101845. * Controls the scale bias of the parallax mode.
  101846. */
  101847. parallaxScaleBias: number;
  101848. /**
  101849. * If sets to true, disables all the lights affecting the material.
  101850. */
  101851. disableLighting: boolean;
  101852. /**
  101853. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101854. */
  101855. forceIrradianceInFragment: boolean;
  101856. /**
  101857. * Number of Simultaneous lights allowed on the material.
  101858. */
  101859. maxSimultaneousLights: number;
  101860. /**
  101861. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101862. */
  101863. invertNormalMapX: boolean;
  101864. /**
  101865. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101866. */
  101867. invertNormalMapY: boolean;
  101868. /**
  101869. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101870. */
  101871. twoSidedLighting: boolean;
  101872. /**
  101873. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101874. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101875. */
  101876. useAlphaFresnel: boolean;
  101877. /**
  101878. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101879. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101880. */
  101881. useLinearAlphaFresnel: boolean;
  101882. /**
  101883. * Let user defines the brdf lookup texture used for IBL.
  101884. * A default 8bit version is embedded but you could point at :
  101885. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101886. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101887. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101888. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101889. */
  101890. environmentBRDFTexture: Nullable<BaseTexture>;
  101891. /**
  101892. * Force normal to face away from face.
  101893. */
  101894. forceNormalForward: boolean;
  101895. /**
  101896. * Enables specular anti aliasing in the PBR shader.
  101897. * It will both interacts on the Geometry for analytical and IBL lighting.
  101898. * It also prefilter the roughness map based on the bump values.
  101899. */
  101900. enableSpecularAntiAliasing: boolean;
  101901. /**
  101902. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101903. * makes the reflect vector face the model (under horizon).
  101904. */
  101905. useHorizonOcclusion: boolean;
  101906. /**
  101907. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101908. * too much the area relying on ambient texture to define their ambient occlusion.
  101909. */
  101910. useRadianceOcclusion: boolean;
  101911. /**
  101912. * If set to true, no lighting calculations will be applied.
  101913. */
  101914. unlit: boolean;
  101915. /**
  101916. * Gets the image processing configuration used either in this material.
  101917. */
  101918. /**
  101919. * Sets the Default image processing configuration used either in the this material.
  101920. *
  101921. * If sets to null, the scene one is in use.
  101922. */
  101923. imageProcessingConfiguration: ImageProcessingConfiguration;
  101924. /**
  101925. * Gets wether the color curves effect is enabled.
  101926. */
  101927. /**
  101928. * Sets wether the color curves effect is enabled.
  101929. */
  101930. cameraColorCurvesEnabled: boolean;
  101931. /**
  101932. * Gets wether the color grading effect is enabled.
  101933. */
  101934. /**
  101935. * Gets wether the color grading effect is enabled.
  101936. */
  101937. cameraColorGradingEnabled: boolean;
  101938. /**
  101939. * Gets wether tonemapping is enabled or not.
  101940. */
  101941. /**
  101942. * Sets wether tonemapping is enabled or not
  101943. */
  101944. cameraToneMappingEnabled: boolean;
  101945. /**
  101946. * The camera exposure used on this material.
  101947. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101948. * This corresponds to a photographic exposure.
  101949. */
  101950. /**
  101951. * The camera exposure used on this material.
  101952. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101953. * This corresponds to a photographic exposure.
  101954. */
  101955. cameraExposure: number;
  101956. /**
  101957. * Gets The camera contrast used on this material.
  101958. */
  101959. /**
  101960. * Sets The camera contrast used on this material.
  101961. */
  101962. cameraContrast: number;
  101963. /**
  101964. * Gets the Color Grading 2D Lookup Texture.
  101965. */
  101966. /**
  101967. * Sets the Color Grading 2D Lookup Texture.
  101968. */
  101969. cameraColorGradingTexture: Nullable<BaseTexture>;
  101970. /**
  101971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101973. * 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;
  101974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101975. */
  101976. /**
  101977. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101978. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101979. * 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;
  101980. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101981. */
  101982. cameraColorCurves: Nullable<ColorCurves>;
  101983. /**
  101984. * Instantiates a new PBRMaterial instance.
  101985. *
  101986. * @param name The material name
  101987. * @param scene The scene the material will be use in.
  101988. */
  101989. constructor(name: string, scene: Scene);
  101990. /**
  101991. * Returns the name of this material class.
  101992. */
  101993. getClassName(): string;
  101994. /**
  101995. * Makes a duplicate of the current material.
  101996. * @param name - name to use for the new material.
  101997. */
  101998. clone(name: string): PBRMaterial;
  101999. /**
  102000. * Serializes this PBR Material.
  102001. * @returns - An object with the serialized material.
  102002. */
  102003. serialize(): any;
  102004. /**
  102005. * Parses a PBR Material from a serialized object.
  102006. * @param source - Serialized object.
  102007. * @param scene - BJS scene instance.
  102008. * @param rootUrl - url for the scene object
  102009. * @returns - PBRMaterial
  102010. */
  102011. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  102012. }
  102013. }
  102014. declare module BABYLON {
  102015. /**
  102016. * Direct draw surface info
  102017. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102018. */
  102019. export interface DDSInfo {
  102020. /**
  102021. * Width of the texture
  102022. */
  102023. width: number;
  102024. /**
  102025. * Width of the texture
  102026. */
  102027. height: number;
  102028. /**
  102029. * Number of Mipmaps for the texture
  102030. * @see https://en.wikipedia.org/wiki/Mipmap
  102031. */
  102032. mipmapCount: number;
  102033. /**
  102034. * If the textures format is a known fourCC format
  102035. * @see https://www.fourcc.org/
  102036. */
  102037. isFourCC: boolean;
  102038. /**
  102039. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102040. */
  102041. isRGB: boolean;
  102042. /**
  102043. * If the texture is a lumincance format
  102044. */
  102045. isLuminance: boolean;
  102046. /**
  102047. * If this is a cube texture
  102048. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102049. */
  102050. isCube: boolean;
  102051. /**
  102052. * If the texture is a compressed format eg. FOURCC_DXT1
  102053. */
  102054. isCompressed: boolean;
  102055. /**
  102056. * The dxgiFormat of the texture
  102057. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102058. */
  102059. dxgiFormat: number;
  102060. /**
  102061. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102062. */
  102063. textureType: number;
  102064. /**
  102065. * Sphericle polynomial created for the dds texture
  102066. */
  102067. sphericalPolynomial?: SphericalPolynomial;
  102068. }
  102069. /**
  102070. * Class used to provide DDS decompression tools
  102071. */
  102072. export class DDSTools {
  102073. /**
  102074. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102075. */
  102076. static StoreLODInAlphaChannel: boolean;
  102077. /**
  102078. * Gets DDS information from an array buffer
  102079. * @param arrayBuffer defines the array buffer to read data from
  102080. * @returns the DDS information
  102081. */
  102082. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102083. private static _FloatView;
  102084. private static _Int32View;
  102085. private static _ToHalfFloat;
  102086. private static _FromHalfFloat;
  102087. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102088. private static _GetHalfFloatRGBAArrayBuffer;
  102089. private static _GetFloatRGBAArrayBuffer;
  102090. private static _GetFloatAsUIntRGBAArrayBuffer;
  102091. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102092. private static _GetRGBAArrayBuffer;
  102093. private static _ExtractLongWordOrder;
  102094. private static _GetRGBArrayBuffer;
  102095. private static _GetLuminanceArrayBuffer;
  102096. /**
  102097. * Uploads DDS Levels to a Babylon Texture
  102098. * @hidden
  102099. */
  102100. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102101. }
  102102. interface Engine {
  102103. /**
  102104. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102105. * @param rootUrl defines the url where the file to load is located
  102106. * @param scene defines the current scene
  102107. * @param lodScale defines scale to apply to the mip map selection
  102108. * @param lodOffset defines offset to apply to the mip map selection
  102109. * @param onLoad defines an optional callback raised when the texture is loaded
  102110. * @param onError defines an optional callback raised if there is an issue to load the texture
  102111. * @param format defines the format of the data
  102112. * @param forcedExtension defines the extension to use to pick the right loader
  102113. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102114. * @returns the cube texture as an InternalTexture
  102115. */
  102116. 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;
  102117. }
  102118. }
  102119. declare module BABYLON {
  102120. /**
  102121. * Implementation of the DDS Texture Loader.
  102122. * @hidden
  102123. */
  102124. export class _DDSTextureLoader implements IInternalTextureLoader {
  102125. /**
  102126. * Defines wether the loader supports cascade loading the different faces.
  102127. */
  102128. readonly supportCascades: boolean;
  102129. /**
  102130. * This returns if the loader support the current file information.
  102131. * @param extension defines the file extension of the file being loaded
  102132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102133. * @param fallback defines the fallback internal texture if any
  102134. * @param isBase64 defines whether the texture is encoded as a base64
  102135. * @param isBuffer defines whether the texture data are stored as a buffer
  102136. * @returns true if the loader can load the specified file
  102137. */
  102138. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102139. /**
  102140. * Transform the url before loading if required.
  102141. * @param rootUrl the url of the texture
  102142. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102143. * @returns the transformed texture
  102144. */
  102145. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102146. /**
  102147. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102148. * @param rootUrl the url of the texture
  102149. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102150. * @returns the fallback texture
  102151. */
  102152. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102153. /**
  102154. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102155. * @param data contains the texture data
  102156. * @param texture defines the BabylonJS internal texture
  102157. * @param createPolynomials will be true if polynomials have been requested
  102158. * @param onLoad defines the callback to trigger once the texture is ready
  102159. * @param onError defines the callback to trigger in case of error
  102160. */
  102161. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102162. /**
  102163. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102164. * @param data contains the texture data
  102165. * @param texture defines the BabylonJS internal texture
  102166. * @param callback defines the method to call once ready to upload
  102167. */
  102168. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102169. }
  102170. }
  102171. declare module BABYLON {
  102172. /** @hidden */
  102173. export var rgbdEncodePixelShader: {
  102174. name: string;
  102175. shader: string;
  102176. };
  102177. }
  102178. declare module BABYLON {
  102179. /** @hidden */
  102180. export var rgbdDecodePixelShader: {
  102181. name: string;
  102182. shader: string;
  102183. };
  102184. }
  102185. declare module BABYLON {
  102186. /**
  102187. * Raw texture data and descriptor sufficient for WebGL texture upload
  102188. */
  102189. export interface EnvironmentTextureInfo {
  102190. /**
  102191. * Version of the environment map
  102192. */
  102193. version: number;
  102194. /**
  102195. * Width of image
  102196. */
  102197. width: number;
  102198. /**
  102199. * Irradiance information stored in the file.
  102200. */
  102201. irradiance: any;
  102202. /**
  102203. * Specular information stored in the file.
  102204. */
  102205. specular: any;
  102206. }
  102207. /**
  102208. * Sets of helpers addressing the serialization and deserialization of environment texture
  102209. * stored in a BabylonJS env file.
  102210. * Those files are usually stored as .env files.
  102211. */
  102212. export class EnvironmentTextureTools {
  102213. /**
  102214. * Magic number identifying the env file.
  102215. */
  102216. private static _MagicBytes;
  102217. /**
  102218. * Gets the environment info from an env file.
  102219. * @param data The array buffer containing the .env bytes.
  102220. * @returns the environment file info (the json header) if successfully parsed.
  102221. */
  102222. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102223. /**
  102224. * Creates an environment texture from a loaded cube texture.
  102225. * @param texture defines the cube texture to convert in env file
  102226. * @return a promise containing the environment data if succesfull.
  102227. */
  102228. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102229. /**
  102230. * Creates a JSON representation of the spherical data.
  102231. * @param texture defines the texture containing the polynomials
  102232. * @return the JSON representation of the spherical info
  102233. */
  102234. private static _CreateEnvTextureIrradiance;
  102235. /**
  102236. * Uploads the texture info contained in the env file to the GPU.
  102237. * @param texture defines the internal texture to upload to
  102238. * @param arrayBuffer defines the buffer cotaining the data to load
  102239. * @param info defines the texture info retrieved through the GetEnvInfo method
  102240. * @returns a promise
  102241. */
  102242. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102243. /**
  102244. * Uploads the levels of image data to the GPU.
  102245. * @param texture defines the internal texture to upload to
  102246. * @param imageData defines the array buffer views of image data [mipmap][face]
  102247. * @returns a promise
  102248. */
  102249. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102250. /**
  102251. * Uploads spherical polynomials information to the texture.
  102252. * @param texture defines the texture we are trying to upload the information to
  102253. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102254. */
  102255. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102256. /** @hidden */
  102257. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102258. }
  102259. }
  102260. declare module BABYLON {
  102261. /**
  102262. * Implementation of the ENV Texture Loader.
  102263. * @hidden
  102264. */
  102265. export class _ENVTextureLoader implements IInternalTextureLoader {
  102266. /**
  102267. * Defines wether the loader supports cascade loading the different faces.
  102268. */
  102269. readonly supportCascades: boolean;
  102270. /**
  102271. * This returns if the loader support the current file information.
  102272. * @param extension defines the file extension of the file being loaded
  102273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102274. * @param fallback defines the fallback internal texture if any
  102275. * @param isBase64 defines whether the texture is encoded as a base64
  102276. * @param isBuffer defines whether the texture data are stored as a buffer
  102277. * @returns true if the loader can load the specified file
  102278. */
  102279. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102280. /**
  102281. * Transform the url before loading if required.
  102282. * @param rootUrl the url of the texture
  102283. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102284. * @returns the transformed texture
  102285. */
  102286. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102287. /**
  102288. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102289. * @param rootUrl the url of the texture
  102290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102291. * @returns the fallback texture
  102292. */
  102293. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102294. /**
  102295. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102296. * @param data contains the texture data
  102297. * @param texture defines the BabylonJS internal texture
  102298. * @param createPolynomials will be true if polynomials have been requested
  102299. * @param onLoad defines the callback to trigger once the texture is ready
  102300. * @param onError defines the callback to trigger in case of error
  102301. */
  102302. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102303. /**
  102304. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102305. * @param data contains the texture data
  102306. * @param texture defines the BabylonJS internal texture
  102307. * @param callback defines the method to call once ready to upload
  102308. */
  102309. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102310. }
  102311. }
  102312. declare module BABYLON {
  102313. /**
  102314. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102315. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102316. */
  102317. export class KhronosTextureContainer {
  102318. /** contents of the KTX container file */
  102319. arrayBuffer: any;
  102320. private static HEADER_LEN;
  102321. private static COMPRESSED_2D;
  102322. private static COMPRESSED_3D;
  102323. private static TEX_2D;
  102324. private static TEX_3D;
  102325. /**
  102326. * Gets the openGL type
  102327. */
  102328. glType: number;
  102329. /**
  102330. * Gets the openGL type size
  102331. */
  102332. glTypeSize: number;
  102333. /**
  102334. * Gets the openGL format
  102335. */
  102336. glFormat: number;
  102337. /**
  102338. * Gets the openGL internal format
  102339. */
  102340. glInternalFormat: number;
  102341. /**
  102342. * Gets the base internal format
  102343. */
  102344. glBaseInternalFormat: number;
  102345. /**
  102346. * Gets image width in pixel
  102347. */
  102348. pixelWidth: number;
  102349. /**
  102350. * Gets image height in pixel
  102351. */
  102352. pixelHeight: number;
  102353. /**
  102354. * Gets image depth in pixels
  102355. */
  102356. pixelDepth: number;
  102357. /**
  102358. * Gets the number of array elements
  102359. */
  102360. numberOfArrayElements: number;
  102361. /**
  102362. * Gets the number of faces
  102363. */
  102364. numberOfFaces: number;
  102365. /**
  102366. * Gets the number of mipmap levels
  102367. */
  102368. numberOfMipmapLevels: number;
  102369. /**
  102370. * Gets the bytes of key value data
  102371. */
  102372. bytesOfKeyValueData: number;
  102373. /**
  102374. * Gets the load type
  102375. */
  102376. loadType: number;
  102377. /**
  102378. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102379. */
  102380. isInvalid: boolean;
  102381. /**
  102382. * Creates a new KhronosTextureContainer
  102383. * @param arrayBuffer contents of the KTX container file
  102384. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102385. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102386. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102387. */
  102388. constructor(
  102389. /** contents of the KTX container file */
  102390. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102391. /**
  102392. * Uploads KTX content to a Babylon Texture.
  102393. * It is assumed that the texture has already been created & is currently bound
  102394. * @hidden
  102395. */
  102396. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102397. private _upload2DCompressedLevels;
  102398. }
  102399. }
  102400. declare module BABYLON {
  102401. /**
  102402. * Implementation of the KTX Texture Loader.
  102403. * @hidden
  102404. */
  102405. export class _KTXTextureLoader implements IInternalTextureLoader {
  102406. /**
  102407. * Defines wether the loader supports cascade loading the different faces.
  102408. */
  102409. readonly supportCascades: boolean;
  102410. /**
  102411. * This returns if the loader support the current file information.
  102412. * @param extension defines the file extension of the file being loaded
  102413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102414. * @param fallback defines the fallback internal texture if any
  102415. * @param isBase64 defines whether the texture is encoded as a base64
  102416. * @param isBuffer defines whether the texture data are stored as a buffer
  102417. * @returns true if the loader can load the specified file
  102418. */
  102419. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102420. /**
  102421. * Transform the url before loading if required.
  102422. * @param rootUrl the url of the texture
  102423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102424. * @returns the transformed texture
  102425. */
  102426. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102427. /**
  102428. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102429. * @param rootUrl the url of the texture
  102430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102431. * @returns the fallback texture
  102432. */
  102433. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102434. /**
  102435. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102436. * @param data contains the texture data
  102437. * @param texture defines the BabylonJS internal texture
  102438. * @param createPolynomials will be true if polynomials have been requested
  102439. * @param onLoad defines the callback to trigger once the texture is ready
  102440. * @param onError defines the callback to trigger in case of error
  102441. */
  102442. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102443. /**
  102444. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102445. * @param data contains the texture data
  102446. * @param texture defines the BabylonJS internal texture
  102447. * @param callback defines the method to call once ready to upload
  102448. */
  102449. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102450. }
  102451. }
  102452. declare module BABYLON {
  102453. /** @hidden */
  102454. export var _forceSceneHelpersToBundle: boolean;
  102455. interface Scene {
  102456. /**
  102457. * Creates a default light for the scene.
  102458. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102459. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102460. */
  102461. createDefaultLight(replace?: boolean): void;
  102462. /**
  102463. * Creates a default camera for the scene.
  102464. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102465. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102466. * @param replace has default false, when true replaces the active camera in the scene
  102467. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102468. */
  102469. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102470. /**
  102471. * Creates a default camera and a default light.
  102472. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102473. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102474. * @param replace has the default false, when true replaces the active camera/light in the scene
  102475. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102476. */
  102477. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102478. /**
  102479. * Creates a new sky box
  102480. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102481. * @param environmentTexture defines the texture to use as environment texture
  102482. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102483. * @param scale defines the overall scale of the skybox
  102484. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102485. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102486. * @returns a new mesh holding the sky box
  102487. */
  102488. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102489. /**
  102490. * Creates a new environment
  102491. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102492. * @param options defines the options you can use to configure the environment
  102493. * @returns the new EnvironmentHelper
  102494. */
  102495. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102496. /**
  102497. * Creates a new VREXperienceHelper
  102498. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102499. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102500. * @returns a new VREXperienceHelper
  102501. */
  102502. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102503. /**
  102504. * Creates a new XREXperienceHelper
  102505. * @see http://doc.babylonjs.com/how_to/webxr
  102506. * @returns a promise for a new XREXperienceHelper
  102507. */
  102508. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102509. }
  102510. }
  102511. declare module BABYLON {
  102512. /**
  102513. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102514. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102515. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102516. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102517. */
  102518. export class VideoDome extends TransformNode {
  102519. /**
  102520. * Define the video source as a Monoscopic panoramic 360 video.
  102521. */
  102522. static readonly MODE_MONOSCOPIC: number;
  102523. /**
  102524. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102525. */
  102526. static readonly MODE_TOPBOTTOM: number;
  102527. /**
  102528. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102529. */
  102530. static readonly MODE_SIDEBYSIDE: number;
  102531. private _useDirectMapping;
  102532. /**
  102533. * The video texture being displayed on the sphere
  102534. */
  102535. protected _videoTexture: VideoTexture;
  102536. /**
  102537. * Gets the video texture being displayed on the sphere
  102538. */
  102539. readonly videoTexture: VideoTexture;
  102540. /**
  102541. * The skybox material
  102542. */
  102543. protected _material: BackgroundMaterial;
  102544. /**
  102545. * The surface used for the skybox
  102546. */
  102547. protected _mesh: Mesh;
  102548. /**
  102549. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102550. * Also see the options.resolution property.
  102551. */
  102552. fovMultiplier: number;
  102553. private _videoMode;
  102554. /**
  102555. * Gets or set the current video mode for the video. It can be:
  102556. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102557. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102558. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102559. */
  102560. videoMode: number;
  102561. /**
  102562. * Oberserver used in Stereoscopic VR Mode.
  102563. */
  102564. private _onBeforeCameraRenderObserver;
  102565. /**
  102566. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102567. * @param name Element's name, child elements will append suffixes for their own names.
  102568. * @param urlsOrVideo defines the url(s) or the video element to use
  102569. * @param options An object containing optional or exposed sub element properties
  102570. */
  102571. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102572. resolution?: number;
  102573. clickToPlay?: boolean;
  102574. autoPlay?: boolean;
  102575. loop?: boolean;
  102576. size?: number;
  102577. poster?: string;
  102578. useDirectMapping?: boolean;
  102579. }, scene: Scene);
  102580. private _changeVideoMode;
  102581. /**
  102582. * Releases resources associated with this node.
  102583. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102584. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102585. */
  102586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102587. }
  102588. }
  102589. declare module BABYLON {
  102590. /**
  102591. * This class can be used to get instrumentation data from a Babylon engine
  102592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102593. */
  102594. export class EngineInstrumentation implements IDisposable {
  102595. /**
  102596. * Define the instrumented engine.
  102597. */
  102598. engine: Engine;
  102599. private _captureGPUFrameTime;
  102600. private _gpuFrameTimeToken;
  102601. private _gpuFrameTime;
  102602. private _captureShaderCompilationTime;
  102603. private _shaderCompilationTime;
  102604. private _onBeginFrameObserver;
  102605. private _onEndFrameObserver;
  102606. private _onBeforeShaderCompilationObserver;
  102607. private _onAfterShaderCompilationObserver;
  102608. /**
  102609. * Gets the perf counter used for GPU frame time
  102610. */
  102611. readonly gpuFrameTimeCounter: PerfCounter;
  102612. /**
  102613. * Gets the GPU frame time capture status
  102614. */
  102615. /**
  102616. * Enable or disable the GPU frame time capture
  102617. */
  102618. captureGPUFrameTime: boolean;
  102619. /**
  102620. * Gets the perf counter used for shader compilation time
  102621. */
  102622. readonly shaderCompilationTimeCounter: PerfCounter;
  102623. /**
  102624. * Gets the shader compilation time capture status
  102625. */
  102626. /**
  102627. * Enable or disable the shader compilation time capture
  102628. */
  102629. captureShaderCompilationTime: boolean;
  102630. /**
  102631. * Instantiates a new engine instrumentation.
  102632. * This class can be used to get instrumentation data from a Babylon engine
  102633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102634. * @param engine Defines the engine to instrument
  102635. */
  102636. constructor(
  102637. /**
  102638. * Define the instrumented engine.
  102639. */
  102640. engine: Engine);
  102641. /**
  102642. * Dispose and release associated resources.
  102643. */
  102644. dispose(): void;
  102645. }
  102646. }
  102647. declare module BABYLON {
  102648. /**
  102649. * This class can be used to get instrumentation data from a Babylon engine
  102650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102651. */
  102652. export class SceneInstrumentation implements IDisposable {
  102653. /**
  102654. * Defines the scene to instrument
  102655. */
  102656. scene: Scene;
  102657. private _captureActiveMeshesEvaluationTime;
  102658. private _activeMeshesEvaluationTime;
  102659. private _captureRenderTargetsRenderTime;
  102660. private _renderTargetsRenderTime;
  102661. private _captureFrameTime;
  102662. private _frameTime;
  102663. private _captureRenderTime;
  102664. private _renderTime;
  102665. private _captureInterFrameTime;
  102666. private _interFrameTime;
  102667. private _captureParticlesRenderTime;
  102668. private _particlesRenderTime;
  102669. private _captureSpritesRenderTime;
  102670. private _spritesRenderTime;
  102671. private _capturePhysicsTime;
  102672. private _physicsTime;
  102673. private _captureAnimationsTime;
  102674. private _animationsTime;
  102675. private _captureCameraRenderTime;
  102676. private _cameraRenderTime;
  102677. private _onBeforeActiveMeshesEvaluationObserver;
  102678. private _onAfterActiveMeshesEvaluationObserver;
  102679. private _onBeforeRenderTargetsRenderObserver;
  102680. private _onAfterRenderTargetsRenderObserver;
  102681. private _onAfterRenderObserver;
  102682. private _onBeforeDrawPhaseObserver;
  102683. private _onAfterDrawPhaseObserver;
  102684. private _onBeforeAnimationsObserver;
  102685. private _onBeforeParticlesRenderingObserver;
  102686. private _onAfterParticlesRenderingObserver;
  102687. private _onBeforeSpritesRenderingObserver;
  102688. private _onAfterSpritesRenderingObserver;
  102689. private _onBeforePhysicsObserver;
  102690. private _onAfterPhysicsObserver;
  102691. private _onAfterAnimationsObserver;
  102692. private _onBeforeCameraRenderObserver;
  102693. private _onAfterCameraRenderObserver;
  102694. /**
  102695. * Gets the perf counter used for active meshes evaluation time
  102696. */
  102697. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102698. /**
  102699. * Gets the active meshes evaluation time capture status
  102700. */
  102701. /**
  102702. * Enable or disable the active meshes evaluation time capture
  102703. */
  102704. captureActiveMeshesEvaluationTime: boolean;
  102705. /**
  102706. * Gets the perf counter used for render targets render time
  102707. */
  102708. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102709. /**
  102710. * Gets the render targets render time capture status
  102711. */
  102712. /**
  102713. * Enable or disable the render targets render time capture
  102714. */
  102715. captureRenderTargetsRenderTime: boolean;
  102716. /**
  102717. * Gets the perf counter used for particles render time
  102718. */
  102719. readonly particlesRenderTimeCounter: PerfCounter;
  102720. /**
  102721. * Gets the particles render time capture status
  102722. */
  102723. /**
  102724. * Enable or disable the particles render time capture
  102725. */
  102726. captureParticlesRenderTime: boolean;
  102727. /**
  102728. * Gets the perf counter used for sprites render time
  102729. */
  102730. readonly spritesRenderTimeCounter: PerfCounter;
  102731. /**
  102732. * Gets the sprites render time capture status
  102733. */
  102734. /**
  102735. * Enable or disable the sprites render time capture
  102736. */
  102737. captureSpritesRenderTime: boolean;
  102738. /**
  102739. * Gets the perf counter used for physics time
  102740. */
  102741. readonly physicsTimeCounter: PerfCounter;
  102742. /**
  102743. * Gets the physics time capture status
  102744. */
  102745. /**
  102746. * Enable or disable the physics time capture
  102747. */
  102748. capturePhysicsTime: boolean;
  102749. /**
  102750. * Gets the perf counter used for animations time
  102751. */
  102752. readonly animationsTimeCounter: PerfCounter;
  102753. /**
  102754. * Gets the animations time capture status
  102755. */
  102756. /**
  102757. * Enable or disable the animations time capture
  102758. */
  102759. captureAnimationsTime: boolean;
  102760. /**
  102761. * Gets the perf counter used for frame time capture
  102762. */
  102763. readonly frameTimeCounter: PerfCounter;
  102764. /**
  102765. * Gets the frame time capture status
  102766. */
  102767. /**
  102768. * Enable or disable the frame time capture
  102769. */
  102770. captureFrameTime: boolean;
  102771. /**
  102772. * Gets the perf counter used for inter-frames time capture
  102773. */
  102774. readonly interFrameTimeCounter: PerfCounter;
  102775. /**
  102776. * Gets the inter-frames time capture status
  102777. */
  102778. /**
  102779. * Enable or disable the inter-frames time capture
  102780. */
  102781. captureInterFrameTime: boolean;
  102782. /**
  102783. * Gets the perf counter used for render time capture
  102784. */
  102785. readonly renderTimeCounter: PerfCounter;
  102786. /**
  102787. * Gets the render time capture status
  102788. */
  102789. /**
  102790. * Enable or disable the render time capture
  102791. */
  102792. captureRenderTime: boolean;
  102793. /**
  102794. * Gets the perf counter used for camera render time capture
  102795. */
  102796. readonly cameraRenderTimeCounter: PerfCounter;
  102797. /**
  102798. * Gets the camera render time capture status
  102799. */
  102800. /**
  102801. * Enable or disable the camera render time capture
  102802. */
  102803. captureCameraRenderTime: boolean;
  102804. /**
  102805. * Gets the perf counter used for draw calls
  102806. */
  102807. readonly drawCallsCounter: PerfCounter;
  102808. /**
  102809. * Gets the perf counter used for texture collisions
  102810. */
  102811. readonly textureCollisionsCounter: PerfCounter;
  102812. /**
  102813. * Instantiates a new scene instrumentation.
  102814. * This class can be used to get instrumentation data from a Babylon engine
  102815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102816. * @param scene Defines the scene to instrument
  102817. */
  102818. constructor(
  102819. /**
  102820. * Defines the scene to instrument
  102821. */
  102822. scene: Scene);
  102823. /**
  102824. * Dispose and release associated resources.
  102825. */
  102826. dispose(): void;
  102827. }
  102828. }
  102829. declare module BABYLON {
  102830. /** @hidden */
  102831. export var glowMapGenerationPixelShader: {
  102832. name: string;
  102833. shader: string;
  102834. };
  102835. }
  102836. declare module BABYLON {
  102837. /** @hidden */
  102838. export var glowMapGenerationVertexShader: {
  102839. name: string;
  102840. shader: string;
  102841. };
  102842. }
  102843. declare module BABYLON {
  102844. /**
  102845. * Effect layer options. This helps customizing the behaviour
  102846. * of the effect layer.
  102847. */
  102848. export interface IEffectLayerOptions {
  102849. /**
  102850. * Multiplication factor apply to the canvas size to compute the render target size
  102851. * used to generated the objects (the smaller the faster).
  102852. */
  102853. mainTextureRatio: number;
  102854. /**
  102855. * Enforces a fixed size texture to ensure effect stability across devices.
  102856. */
  102857. mainTextureFixedSize?: number;
  102858. /**
  102859. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102860. */
  102861. alphaBlendingMode: number;
  102862. /**
  102863. * The camera attached to the layer.
  102864. */
  102865. camera: Nullable<Camera>;
  102866. /**
  102867. * The rendering group to draw the layer in.
  102868. */
  102869. renderingGroupId: number;
  102870. }
  102871. /**
  102872. * The effect layer Helps adding post process effect blended with the main pass.
  102873. *
  102874. * This can be for instance use to generate glow or higlight effects on the scene.
  102875. *
  102876. * The effect layer class can not be used directly and is intented to inherited from to be
  102877. * customized per effects.
  102878. */
  102879. export abstract class EffectLayer {
  102880. private _vertexBuffers;
  102881. private _indexBuffer;
  102882. private _cachedDefines;
  102883. private _effectLayerMapGenerationEffect;
  102884. private _effectLayerOptions;
  102885. private _mergeEffect;
  102886. protected _scene: Scene;
  102887. protected _engine: Engine;
  102888. protected _maxSize: number;
  102889. protected _mainTextureDesiredSize: ISize;
  102890. protected _mainTexture: RenderTargetTexture;
  102891. protected _shouldRender: boolean;
  102892. protected _postProcesses: PostProcess[];
  102893. protected _textures: BaseTexture[];
  102894. protected _emissiveTextureAndColor: {
  102895. texture: Nullable<BaseTexture>;
  102896. color: Color4;
  102897. };
  102898. /**
  102899. * The name of the layer
  102900. */
  102901. name: string;
  102902. /**
  102903. * The clear color of the texture used to generate the glow map.
  102904. */
  102905. neutralColor: Color4;
  102906. /**
  102907. * Specifies wether the highlight layer is enabled or not.
  102908. */
  102909. isEnabled: boolean;
  102910. /**
  102911. * Gets the camera attached to the layer.
  102912. */
  102913. readonly camera: Nullable<Camera>;
  102914. /**
  102915. * Gets the rendering group id the layer should render in.
  102916. */
  102917. readonly renderingGroupId: number;
  102918. /**
  102919. * An event triggered when the effect layer has been disposed.
  102920. */
  102921. onDisposeObservable: Observable<EffectLayer>;
  102922. /**
  102923. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  102924. */
  102925. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  102926. /**
  102927. * An event triggered when the generated texture is being merged in the scene.
  102928. */
  102929. onBeforeComposeObservable: Observable<EffectLayer>;
  102930. /**
  102931. * An event triggered when the generated texture has been merged in the scene.
  102932. */
  102933. onAfterComposeObservable: Observable<EffectLayer>;
  102934. /**
  102935. * An event triggered when the efffect layer changes its size.
  102936. */
  102937. onSizeChangedObservable: Observable<EffectLayer>;
  102938. /** @hidden */
  102939. static _SceneComponentInitialization: (scene: Scene) => void;
  102940. /**
  102941. * Instantiates a new effect Layer and references it in the scene.
  102942. * @param name The name of the layer
  102943. * @param scene The scene to use the layer in
  102944. */
  102945. constructor(
  102946. /** The Friendly of the effect in the scene */
  102947. name: string, scene: Scene);
  102948. /**
  102949. * Get the effect name of the layer.
  102950. * @return The effect name
  102951. */
  102952. abstract getEffectName(): string;
  102953. /**
  102954. * Checks for the readiness of the element composing the layer.
  102955. * @param subMesh the mesh to check for
  102956. * @param useInstances specify wether or not to use instances to render the mesh
  102957. * @return true if ready otherwise, false
  102958. */
  102959. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102960. /**
  102961. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102962. * @returns true if the effect requires stencil during the main canvas render pass.
  102963. */
  102964. abstract needStencil(): boolean;
  102965. /**
  102966. * Create the merge effect. This is the shader use to blit the information back
  102967. * to the main canvas at the end of the scene rendering.
  102968. * @returns The effect containing the shader used to merge the effect on the main canvas
  102969. */
  102970. protected abstract _createMergeEffect(): Effect;
  102971. /**
  102972. * Creates the render target textures and post processes used in the effect layer.
  102973. */
  102974. protected abstract _createTextureAndPostProcesses(): void;
  102975. /**
  102976. * Implementation specific of rendering the generating effect on the main canvas.
  102977. * @param effect The effect used to render through
  102978. */
  102979. protected abstract _internalRender(effect: Effect): void;
  102980. /**
  102981. * Sets the required values for both the emissive texture and and the main color.
  102982. */
  102983. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102984. /**
  102985. * Free any resources and references associated to a mesh.
  102986. * Internal use
  102987. * @param mesh The mesh to free.
  102988. */
  102989. abstract _disposeMesh(mesh: Mesh): void;
  102990. /**
  102991. * Serializes this layer (Glow or Highlight for example)
  102992. * @returns a serialized layer object
  102993. */
  102994. abstract serialize?(): any;
  102995. /**
  102996. * Initializes the effect layer with the required options.
  102997. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  102998. */
  102999. protected _init(options: Partial<IEffectLayerOptions>): void;
  103000. /**
  103001. * Generates the index buffer of the full screen quad blending to the main canvas.
  103002. */
  103003. private _generateIndexBuffer;
  103004. /**
  103005. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  103006. */
  103007. private _genrateVertexBuffer;
  103008. /**
  103009. * Sets the main texture desired size which is the closest power of two
  103010. * of the engine canvas size.
  103011. */
  103012. private _setMainTextureSize;
  103013. /**
  103014. * Creates the main texture for the effect layer.
  103015. */
  103016. protected _createMainTexture(): void;
  103017. /**
  103018. * Adds specific effects defines.
  103019. * @param defines The defines to add specifics to.
  103020. */
  103021. protected _addCustomEffectDefines(defines: string[]): void;
  103022. /**
  103023. * Checks for the readiness of the element composing the layer.
  103024. * @param subMesh the mesh to check for
  103025. * @param useInstances specify wether or not to use instances to render the mesh
  103026. * @param emissiveTexture the associated emissive texture used to generate the glow
  103027. * @return true if ready otherwise, false
  103028. */
  103029. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  103030. /**
  103031. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  103032. */
  103033. render(): void;
  103034. /**
  103035. * Determine if a given mesh will be used in the current effect.
  103036. * @param mesh mesh to test
  103037. * @returns true if the mesh will be used
  103038. */
  103039. hasMesh(mesh: AbstractMesh): boolean;
  103040. /**
  103041. * Returns true if the layer contains information to display, otherwise false.
  103042. * @returns true if the glow layer should be rendered
  103043. */
  103044. shouldRender(): boolean;
  103045. /**
  103046. * Returns true if the mesh should render, otherwise false.
  103047. * @param mesh The mesh to render
  103048. * @returns true if it should render otherwise false
  103049. */
  103050. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  103051. /**
  103052. * Returns true if the mesh can be rendered, otherwise false.
  103053. * @param mesh The mesh to render
  103054. * @param material The material used on the mesh
  103055. * @returns true if it can be rendered otherwise false
  103056. */
  103057. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103058. /**
  103059. * Returns true if the mesh should render, otherwise false.
  103060. * @param mesh The mesh to render
  103061. * @returns true if it should render otherwise false
  103062. */
  103063. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  103064. /**
  103065. * Renders the submesh passed in parameter to the generation map.
  103066. */
  103067. protected _renderSubMesh(subMesh: SubMesh): void;
  103068. /**
  103069. * Rebuild the required buffers.
  103070. * @hidden Internal use only.
  103071. */
  103072. _rebuild(): void;
  103073. /**
  103074. * Dispose only the render target textures and post process.
  103075. */
  103076. private _disposeTextureAndPostProcesses;
  103077. /**
  103078. * Dispose the highlight layer and free resources.
  103079. */
  103080. dispose(): void;
  103081. /**
  103082. * Gets the class name of the effect layer
  103083. * @returns the string with the class name of the effect layer
  103084. */
  103085. getClassName(): string;
  103086. /**
  103087. * Creates an effect layer from parsed effect layer data
  103088. * @param parsedEffectLayer defines effect layer data
  103089. * @param scene defines the current scene
  103090. * @param rootUrl defines the root URL containing the effect layer information
  103091. * @returns a parsed effect Layer
  103092. */
  103093. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  103094. }
  103095. }
  103096. declare module BABYLON {
  103097. interface AbstractScene {
  103098. /**
  103099. * The list of effect layers (highlights/glow) added to the scene
  103100. * @see http://doc.babylonjs.com/how_to/highlight_layer
  103101. * @see http://doc.babylonjs.com/how_to/glow_layer
  103102. */
  103103. effectLayers: Array<EffectLayer>;
  103104. /**
  103105. * Removes the given effect layer from this scene.
  103106. * @param toRemove defines the effect layer to remove
  103107. * @returns the index of the removed effect layer
  103108. */
  103109. removeEffectLayer(toRemove: EffectLayer): number;
  103110. /**
  103111. * Adds the given effect layer to this scene
  103112. * @param newEffectLayer defines the effect layer to add
  103113. */
  103114. addEffectLayer(newEffectLayer: EffectLayer): void;
  103115. }
  103116. /**
  103117. * Defines the layer scene component responsible to manage any effect layers
  103118. * in a given scene.
  103119. */
  103120. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  103121. /**
  103122. * The component name helpfull to identify the component in the list of scene components.
  103123. */
  103124. readonly name: string;
  103125. /**
  103126. * The scene the component belongs to.
  103127. */
  103128. scene: Scene;
  103129. private _engine;
  103130. private _renderEffects;
  103131. private _needStencil;
  103132. private _previousStencilState;
  103133. /**
  103134. * Creates a new instance of the component for the given scene
  103135. * @param scene Defines the scene to register the component in
  103136. */
  103137. constructor(scene: Scene);
  103138. /**
  103139. * Registers the component in a given scene
  103140. */
  103141. register(): void;
  103142. /**
  103143. * Rebuilds the elements related to this component in case of
  103144. * context lost for instance.
  103145. */
  103146. rebuild(): void;
  103147. /**
  103148. * Serializes the component data to the specified json object
  103149. * @param serializationObject The object to serialize to
  103150. */
  103151. serialize(serializationObject: any): void;
  103152. /**
  103153. * Adds all the element from the container to the scene
  103154. * @param container the container holding the elements
  103155. */
  103156. addFromContainer(container: AbstractScene): void;
  103157. /**
  103158. * Removes all the elements in the container from the scene
  103159. * @param container contains the elements to remove
  103160. */
  103161. removeFromContainer(container: AbstractScene): void;
  103162. /**
  103163. * Disposes the component and the associated ressources.
  103164. */
  103165. dispose(): void;
  103166. private _isReadyForMesh;
  103167. private _renderMainTexture;
  103168. private _setStencil;
  103169. private _setStencilBack;
  103170. private _draw;
  103171. private _drawCamera;
  103172. private _drawRenderingGroup;
  103173. }
  103174. }
  103175. declare module BABYLON {
  103176. /** @hidden */
  103177. export var glowMapMergePixelShader: {
  103178. name: string;
  103179. shader: string;
  103180. };
  103181. }
  103182. declare module BABYLON {
  103183. /** @hidden */
  103184. export var glowMapMergeVertexShader: {
  103185. name: string;
  103186. shader: string;
  103187. };
  103188. }
  103189. declare module BABYLON {
  103190. interface AbstractScene {
  103191. /**
  103192. * Return a the first highlight layer of the scene with a given name.
  103193. * @param name The name of the highlight layer to look for.
  103194. * @return The highlight layer if found otherwise null.
  103195. */
  103196. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  103197. }
  103198. /**
  103199. * Glow layer options. This helps customizing the behaviour
  103200. * of the glow layer.
  103201. */
  103202. export interface IGlowLayerOptions {
  103203. /**
  103204. * Multiplication factor apply to the canvas size to compute the render target size
  103205. * used to generated the glowing objects (the smaller the faster).
  103206. */
  103207. mainTextureRatio: number;
  103208. /**
  103209. * Enforces a fixed size texture to ensure resize independant blur.
  103210. */
  103211. mainTextureFixedSize?: number;
  103212. /**
  103213. * How big is the kernel of the blur texture.
  103214. */
  103215. blurKernelSize: number;
  103216. /**
  103217. * The camera attached to the layer.
  103218. */
  103219. camera: Nullable<Camera>;
  103220. /**
  103221. * Enable MSAA by chosing the number of samples.
  103222. */
  103223. mainTextureSamples?: number;
  103224. /**
  103225. * The rendering group to draw the layer in.
  103226. */
  103227. renderingGroupId: number;
  103228. }
  103229. /**
  103230. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103231. *
  103232. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103233. * glowy meshes to your scene.
  103234. *
  103235. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103236. */
  103237. export class GlowLayer extends EffectLayer {
  103238. /**
  103239. * Effect Name of the layer.
  103240. */
  103241. static readonly EffectName: string;
  103242. /**
  103243. * The default blur kernel size used for the glow.
  103244. */
  103245. static DefaultBlurKernelSize: number;
  103246. /**
  103247. * The default texture size ratio used for the glow.
  103248. */
  103249. static DefaultTextureRatio: number;
  103250. /**
  103251. * Sets the kernel size of the blur.
  103252. */
  103253. /**
  103254. * Gets the kernel size of the blur.
  103255. */
  103256. blurKernelSize: number;
  103257. /**
  103258. * Sets the glow intensity.
  103259. */
  103260. /**
  103261. * Gets the glow intensity.
  103262. */
  103263. intensity: number;
  103264. private _options;
  103265. private _intensity;
  103266. private _horizontalBlurPostprocess1;
  103267. private _verticalBlurPostprocess1;
  103268. private _horizontalBlurPostprocess2;
  103269. private _verticalBlurPostprocess2;
  103270. private _blurTexture1;
  103271. private _blurTexture2;
  103272. private _postProcesses1;
  103273. private _postProcesses2;
  103274. private _includedOnlyMeshes;
  103275. private _excludedMeshes;
  103276. /**
  103277. * Callback used to let the user override the color selection on a per mesh basis
  103278. */
  103279. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103280. /**
  103281. * Callback used to let the user override the texture selection on a per mesh basis
  103282. */
  103283. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103284. /**
  103285. * Instantiates a new glow Layer and references it to the scene.
  103286. * @param name The name of the layer
  103287. * @param scene The scene to use the layer in
  103288. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103289. */
  103290. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103291. /**
  103292. * Get the effect name of the layer.
  103293. * @return The effect name
  103294. */
  103295. getEffectName(): string;
  103296. /**
  103297. * Create the merge effect. This is the shader use to blit the information back
  103298. * to the main canvas at the end of the scene rendering.
  103299. */
  103300. protected _createMergeEffect(): Effect;
  103301. /**
  103302. * Creates the render target textures and post processes used in the glow layer.
  103303. */
  103304. protected _createTextureAndPostProcesses(): void;
  103305. /**
  103306. * Checks for the readiness of the element composing the layer.
  103307. * @param subMesh the mesh to check for
  103308. * @param useInstances specify wether or not to use instances to render the mesh
  103309. * @param emissiveTexture the associated emissive texture used to generate the glow
  103310. * @return true if ready otherwise, false
  103311. */
  103312. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103313. /**
  103314. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103315. */
  103316. needStencil(): boolean;
  103317. /**
  103318. * Returns true if the mesh can be rendered, otherwise false.
  103319. * @param mesh The mesh to render
  103320. * @param material The material used on the mesh
  103321. * @returns true if it can be rendered otherwise false
  103322. */
  103323. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103324. /**
  103325. * Implementation specific of rendering the generating effect on the main canvas.
  103326. * @param effect The effect used to render through
  103327. */
  103328. protected _internalRender(effect: Effect): void;
  103329. /**
  103330. * Sets the required values for both the emissive texture and and the main color.
  103331. */
  103332. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103333. /**
  103334. * Returns true if the mesh should render, otherwise false.
  103335. * @param mesh The mesh to render
  103336. * @returns true if it should render otherwise false
  103337. */
  103338. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103339. /**
  103340. * Adds specific effects defines.
  103341. * @param defines The defines to add specifics to.
  103342. */
  103343. protected _addCustomEffectDefines(defines: string[]): void;
  103344. /**
  103345. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103346. * @param mesh The mesh to exclude from the glow layer
  103347. */
  103348. addExcludedMesh(mesh: Mesh): void;
  103349. /**
  103350. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103351. * @param mesh The mesh to remove
  103352. */
  103353. removeExcludedMesh(mesh: Mesh): void;
  103354. /**
  103355. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103356. * @param mesh The mesh to include in the glow layer
  103357. */
  103358. addIncludedOnlyMesh(mesh: Mesh): void;
  103359. /**
  103360. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103361. * @param mesh The mesh to remove
  103362. */
  103363. removeIncludedOnlyMesh(mesh: Mesh): void;
  103364. /**
  103365. * Determine if a given mesh will be used in the glow layer
  103366. * @param mesh The mesh to test
  103367. * @returns true if the mesh will be highlighted by the current glow layer
  103368. */
  103369. hasMesh(mesh: AbstractMesh): boolean;
  103370. /**
  103371. * Free any resources and references associated to a mesh.
  103372. * Internal use
  103373. * @param mesh The mesh to free.
  103374. * @hidden
  103375. */
  103376. _disposeMesh(mesh: Mesh): void;
  103377. /**
  103378. * Gets the class name of the effect layer
  103379. * @returns the string with the class name of the effect layer
  103380. */
  103381. getClassName(): string;
  103382. /**
  103383. * Serializes this glow layer
  103384. * @returns a serialized glow layer object
  103385. */
  103386. serialize(): any;
  103387. /**
  103388. * Creates a Glow Layer from parsed glow layer data
  103389. * @param parsedGlowLayer defines glow layer data
  103390. * @param scene defines the current scene
  103391. * @param rootUrl defines the root URL containing the glow layer information
  103392. * @returns a parsed Glow Layer
  103393. */
  103394. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103395. }
  103396. }
  103397. declare module BABYLON {
  103398. /** @hidden */
  103399. export var glowBlurPostProcessPixelShader: {
  103400. name: string;
  103401. shader: string;
  103402. };
  103403. }
  103404. declare module BABYLON {
  103405. interface AbstractScene {
  103406. /**
  103407. * Return a the first highlight layer of the scene with a given name.
  103408. * @param name The name of the highlight layer to look for.
  103409. * @return The highlight layer if found otherwise null.
  103410. */
  103411. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103412. }
  103413. /**
  103414. * Highlight layer options. This helps customizing the behaviour
  103415. * of the highlight layer.
  103416. */
  103417. export interface IHighlightLayerOptions {
  103418. /**
  103419. * Multiplication factor apply to the canvas size to compute the render target size
  103420. * used to generated the glowing objects (the smaller the faster).
  103421. */
  103422. mainTextureRatio: number;
  103423. /**
  103424. * Enforces a fixed size texture to ensure resize independant blur.
  103425. */
  103426. mainTextureFixedSize?: number;
  103427. /**
  103428. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103429. * of the picture to blur (the smaller the faster).
  103430. */
  103431. blurTextureSizeRatio: number;
  103432. /**
  103433. * How big in texel of the blur texture is the vertical blur.
  103434. */
  103435. blurVerticalSize: number;
  103436. /**
  103437. * How big in texel of the blur texture is the horizontal blur.
  103438. */
  103439. blurHorizontalSize: number;
  103440. /**
  103441. * Alpha blending mode used to apply the blur. Default is combine.
  103442. */
  103443. alphaBlendingMode: number;
  103444. /**
  103445. * The camera attached to the layer.
  103446. */
  103447. camera: Nullable<Camera>;
  103448. /**
  103449. * Should we display highlight as a solid stroke?
  103450. */
  103451. isStroke?: boolean;
  103452. /**
  103453. * The rendering group to draw the layer in.
  103454. */
  103455. renderingGroupId: number;
  103456. }
  103457. /**
  103458. * The highlight layer Helps adding a glow effect around a mesh.
  103459. *
  103460. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103461. * glowy meshes to your scene.
  103462. *
  103463. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103464. */
  103465. export class HighlightLayer extends EffectLayer {
  103466. name: string;
  103467. /**
  103468. * Effect Name of the highlight layer.
  103469. */
  103470. static readonly EffectName: string;
  103471. /**
  103472. * The neutral color used during the preparation of the glow effect.
  103473. * This is black by default as the blend operation is a blend operation.
  103474. */
  103475. static NeutralColor: Color4;
  103476. /**
  103477. * Stencil value used for glowing meshes.
  103478. */
  103479. static GlowingMeshStencilReference: number;
  103480. /**
  103481. * Stencil value used for the other meshes in the scene.
  103482. */
  103483. static NormalMeshStencilReference: number;
  103484. /**
  103485. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103486. */
  103487. innerGlow: boolean;
  103488. /**
  103489. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103490. */
  103491. outerGlow: boolean;
  103492. /**
  103493. * Specifies the horizontal size of the blur.
  103494. */
  103495. /**
  103496. * Gets the horizontal size of the blur.
  103497. */
  103498. blurHorizontalSize: number;
  103499. /**
  103500. * Specifies the vertical size of the blur.
  103501. */
  103502. /**
  103503. * Gets the vertical size of the blur.
  103504. */
  103505. blurVerticalSize: number;
  103506. /**
  103507. * An event triggered when the highlight layer is being blurred.
  103508. */
  103509. onBeforeBlurObservable: Observable<HighlightLayer>;
  103510. /**
  103511. * An event triggered when the highlight layer has been blurred.
  103512. */
  103513. onAfterBlurObservable: Observable<HighlightLayer>;
  103514. private _instanceGlowingMeshStencilReference;
  103515. private _options;
  103516. private _downSamplePostprocess;
  103517. private _horizontalBlurPostprocess;
  103518. private _verticalBlurPostprocess;
  103519. private _blurTexture;
  103520. private _meshes;
  103521. private _excludedMeshes;
  103522. /**
  103523. * Instantiates a new highlight Layer and references it to the scene..
  103524. * @param name The name of the layer
  103525. * @param scene The scene to use the layer in
  103526. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103527. */
  103528. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103529. /**
  103530. * Get the effect name of the layer.
  103531. * @return The effect name
  103532. */
  103533. getEffectName(): string;
  103534. /**
  103535. * Create the merge effect. This is the shader use to blit the information back
  103536. * to the main canvas at the end of the scene rendering.
  103537. */
  103538. protected _createMergeEffect(): Effect;
  103539. /**
  103540. * Creates the render target textures and post processes used in the highlight layer.
  103541. */
  103542. protected _createTextureAndPostProcesses(): void;
  103543. /**
  103544. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103545. */
  103546. needStencil(): boolean;
  103547. /**
  103548. * Checks for the readiness of the element composing the layer.
  103549. * @param subMesh the mesh to check for
  103550. * @param useInstances specify wether or not to use instances to render the mesh
  103551. * @param emissiveTexture the associated emissive texture used to generate the glow
  103552. * @return true if ready otherwise, false
  103553. */
  103554. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103555. /**
  103556. * Implementation specific of rendering the generating effect on the main canvas.
  103557. * @param effect The effect used to render through
  103558. */
  103559. protected _internalRender(effect: Effect): void;
  103560. /**
  103561. * Returns true if the layer contains information to display, otherwise false.
  103562. */
  103563. shouldRender(): boolean;
  103564. /**
  103565. * Returns true if the mesh should render, otherwise false.
  103566. * @param mesh The mesh to render
  103567. * @returns true if it should render otherwise false
  103568. */
  103569. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103570. /**
  103571. * Sets the required values for both the emissive texture and and the main color.
  103572. */
  103573. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103574. /**
  103575. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103576. * @param mesh The mesh to exclude from the highlight layer
  103577. */
  103578. addExcludedMesh(mesh: Mesh): void;
  103579. /**
  103580. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103581. * @param mesh The mesh to highlight
  103582. */
  103583. removeExcludedMesh(mesh: Mesh): void;
  103584. /**
  103585. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103586. * @param mesh mesh to test
  103587. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103588. */
  103589. hasMesh(mesh: AbstractMesh): boolean;
  103590. /**
  103591. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103592. * @param mesh The mesh to highlight
  103593. * @param color The color of the highlight
  103594. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103595. */
  103596. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103597. /**
  103598. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103599. * @param mesh The mesh to highlight
  103600. */
  103601. removeMesh(mesh: Mesh): void;
  103602. /**
  103603. * Force the stencil to the normal expected value for none glowing parts
  103604. */
  103605. private _defaultStencilReference;
  103606. /**
  103607. * Free any resources and references associated to a mesh.
  103608. * Internal use
  103609. * @param mesh The mesh to free.
  103610. * @hidden
  103611. */
  103612. _disposeMesh(mesh: Mesh): void;
  103613. /**
  103614. * Dispose the highlight layer and free resources.
  103615. */
  103616. dispose(): void;
  103617. /**
  103618. * Gets the class name of the effect layer
  103619. * @returns the string with the class name of the effect layer
  103620. */
  103621. getClassName(): string;
  103622. /**
  103623. * Serializes this Highlight layer
  103624. * @returns a serialized Highlight layer object
  103625. */
  103626. serialize(): any;
  103627. /**
  103628. * Creates a Highlight layer from parsed Highlight layer data
  103629. * @param parsedHightlightLayer defines the Highlight layer data
  103630. * @param scene defines the current scene
  103631. * @param rootUrl defines the root URL containing the Highlight layer information
  103632. * @returns a parsed Highlight layer
  103633. */
  103634. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103635. }
  103636. }
  103637. declare module BABYLON {
  103638. /** @hidden */
  103639. export var lensFlarePixelShader: {
  103640. name: string;
  103641. shader: string;
  103642. };
  103643. }
  103644. declare module BABYLON {
  103645. /** @hidden */
  103646. export var lensFlareVertexShader: {
  103647. name: string;
  103648. shader: string;
  103649. };
  103650. }
  103651. declare module BABYLON {
  103652. /**
  103653. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103654. * It is usually composed of several `lensFlare`.
  103655. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103656. */
  103657. export class LensFlareSystem {
  103658. /**
  103659. * Define the name of the lens flare system
  103660. */
  103661. name: string;
  103662. /**
  103663. * List of lens flares used in this system.
  103664. */
  103665. lensFlares: LensFlare[];
  103666. /**
  103667. * Define a limit from the border the lens flare can be visible.
  103668. */
  103669. borderLimit: number;
  103670. /**
  103671. * Define a viewport border we do not want to see the lens flare in.
  103672. */
  103673. viewportBorder: number;
  103674. /**
  103675. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103676. */
  103677. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103678. /**
  103679. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103680. */
  103681. layerMask: number;
  103682. /**
  103683. * Define the id of the lens flare system in the scene.
  103684. * (equal to name by default)
  103685. */
  103686. id: string;
  103687. private _scene;
  103688. private _emitter;
  103689. private _vertexBuffers;
  103690. private _indexBuffer;
  103691. private _effect;
  103692. private _positionX;
  103693. private _positionY;
  103694. private _isEnabled;
  103695. /** @hidden */
  103696. static _SceneComponentInitialization: (scene: Scene) => void;
  103697. /**
  103698. * Instantiates a lens flare system.
  103699. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103700. * It is usually composed of several `lensFlare`.
  103701. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103702. * @param name Define the name of the lens flare system in the scene
  103703. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103704. * @param scene Define the scene the lens flare system belongs to
  103705. */
  103706. constructor(
  103707. /**
  103708. * Define the name of the lens flare system
  103709. */
  103710. name: string, emitter: any, scene: Scene);
  103711. /**
  103712. * Define if the lens flare system is enabled.
  103713. */
  103714. isEnabled: boolean;
  103715. /**
  103716. * Get the scene the effects belongs to.
  103717. * @returns the scene holding the lens flare system
  103718. */
  103719. getScene(): Scene;
  103720. /**
  103721. * Get the emitter of the lens flare system.
  103722. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103723. * @returns the emitter of the lens flare system
  103724. */
  103725. getEmitter(): any;
  103726. /**
  103727. * Set the emitter of the lens flare system.
  103728. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103729. * @param newEmitter Define the new emitter of the system
  103730. */
  103731. setEmitter(newEmitter: any): void;
  103732. /**
  103733. * Get the lens flare system emitter position.
  103734. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103735. * @returns the position
  103736. */
  103737. getEmitterPosition(): Vector3;
  103738. /**
  103739. * @hidden
  103740. */
  103741. computeEffectivePosition(globalViewport: Viewport): boolean;
  103742. /** @hidden */
  103743. _isVisible(): boolean;
  103744. /**
  103745. * @hidden
  103746. */
  103747. render(): boolean;
  103748. /**
  103749. * Dispose and release the lens flare with its associated resources.
  103750. */
  103751. dispose(): void;
  103752. /**
  103753. * Parse a lens flare system from a JSON repressentation
  103754. * @param parsedLensFlareSystem Define the JSON to parse
  103755. * @param scene Define the scene the parsed system should be instantiated in
  103756. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103757. * @returns the parsed system
  103758. */
  103759. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103760. /**
  103761. * Serialize the current Lens Flare System into a JSON representation.
  103762. * @returns the serialized JSON
  103763. */
  103764. serialize(): any;
  103765. }
  103766. }
  103767. declare module BABYLON {
  103768. /**
  103769. * This represents one of the lens effect in a `lensFlareSystem`.
  103770. * It controls one of the indiviual texture used in the effect.
  103771. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103772. */
  103773. export class LensFlare {
  103774. /**
  103775. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103776. */
  103777. size: number;
  103778. /**
  103779. * 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.
  103780. */
  103781. position: number;
  103782. /**
  103783. * Define the lens color.
  103784. */
  103785. color: Color3;
  103786. /**
  103787. * Define the lens texture.
  103788. */
  103789. texture: Nullable<Texture>;
  103790. /**
  103791. * Define the alpha mode to render this particular lens.
  103792. */
  103793. alphaMode: number;
  103794. private _system;
  103795. /**
  103796. * Creates a new Lens Flare.
  103797. * This represents one of the lens effect in a `lensFlareSystem`.
  103798. * It controls one of the indiviual texture used in the effect.
  103799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103800. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103801. * @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.
  103802. * @param color Define the lens color
  103803. * @param imgUrl Define the lens texture url
  103804. * @param system Define the `lensFlareSystem` this flare is part of
  103805. * @returns The newly created Lens Flare
  103806. */
  103807. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103808. /**
  103809. * Instantiates a new Lens Flare.
  103810. * This represents one of the lens effect in a `lensFlareSystem`.
  103811. * It controls one of the indiviual texture used in the effect.
  103812. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103813. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103814. * @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.
  103815. * @param color Define the lens color
  103816. * @param imgUrl Define the lens texture url
  103817. * @param system Define the `lensFlareSystem` this flare is part of
  103818. */
  103819. constructor(
  103820. /**
  103821. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103822. */
  103823. size: number,
  103824. /**
  103825. * 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.
  103826. */
  103827. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103828. /**
  103829. * Dispose and release the lens flare with its associated resources.
  103830. */
  103831. dispose(): void;
  103832. }
  103833. }
  103834. declare module BABYLON {
  103835. interface AbstractScene {
  103836. /**
  103837. * The list of lens flare system added to the scene
  103838. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103839. */
  103840. lensFlareSystems: Array<LensFlareSystem>;
  103841. /**
  103842. * Removes the given lens flare system from this scene.
  103843. * @param toRemove The lens flare system to remove
  103844. * @returns The index of the removed lens flare system
  103845. */
  103846. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103847. /**
  103848. * Adds the given lens flare system to this scene
  103849. * @param newLensFlareSystem The lens flare system to add
  103850. */
  103851. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103852. /**
  103853. * Gets a lens flare system using its name
  103854. * @param name defines the name to look for
  103855. * @returns the lens flare system or null if not found
  103856. */
  103857. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103858. /**
  103859. * Gets a lens flare system using its id
  103860. * @param id defines the id to look for
  103861. * @returns the lens flare system or null if not found
  103862. */
  103863. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  103864. }
  103865. /**
  103866. * Defines the lens flare scene component responsible to manage any lens flares
  103867. * in a given scene.
  103868. */
  103869. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  103870. /**
  103871. * The component name helpfull to identify the component in the list of scene components.
  103872. */
  103873. readonly name: string;
  103874. /**
  103875. * The scene the component belongs to.
  103876. */
  103877. scene: Scene;
  103878. /**
  103879. * Creates a new instance of the component for the given scene
  103880. * @param scene Defines the scene to register the component in
  103881. */
  103882. constructor(scene: Scene);
  103883. /**
  103884. * Registers the component in a given scene
  103885. */
  103886. register(): void;
  103887. /**
  103888. * Rebuilds the elements related to this component in case of
  103889. * context lost for instance.
  103890. */
  103891. rebuild(): void;
  103892. /**
  103893. * Adds all the element from the container to the scene
  103894. * @param container the container holding the elements
  103895. */
  103896. addFromContainer(container: AbstractScene): void;
  103897. /**
  103898. * Removes all the elements in the container from the scene
  103899. * @param container contains the elements to remove
  103900. */
  103901. removeFromContainer(container: AbstractScene): void;
  103902. /**
  103903. * Serializes the component data to the specified json object
  103904. * @param serializationObject The object to serialize to
  103905. */
  103906. serialize(serializationObject: any): void;
  103907. /**
  103908. * Disposes the component and the associated ressources.
  103909. */
  103910. dispose(): void;
  103911. private _draw;
  103912. }
  103913. }
  103914. declare module BABYLON {
  103915. /**
  103916. * Defines the shadow generator component responsible to manage any shadow generators
  103917. * in a given scene.
  103918. */
  103919. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  103920. /**
  103921. * The component name helpfull to identify the component in the list of scene components.
  103922. */
  103923. readonly name: string;
  103924. /**
  103925. * The scene the component belongs to.
  103926. */
  103927. scene: Scene;
  103928. /**
  103929. * Creates a new instance of the component for the given scene
  103930. * @param scene Defines the scene to register the component in
  103931. */
  103932. constructor(scene: Scene);
  103933. /**
  103934. * Registers the component in a given scene
  103935. */
  103936. register(): void;
  103937. /**
  103938. * Rebuilds the elements related to this component in case of
  103939. * context lost for instance.
  103940. */
  103941. rebuild(): void;
  103942. /**
  103943. * Serializes the component data to the specified json object
  103944. * @param serializationObject The object to serialize to
  103945. */
  103946. serialize(serializationObject: any): void;
  103947. /**
  103948. * Adds all the element from the container to the scene
  103949. * @param container the container holding the elements
  103950. */
  103951. addFromContainer(container: AbstractScene): void;
  103952. /**
  103953. * Removes all the elements in the container from the scene
  103954. * @param container contains the elements to remove
  103955. */
  103956. removeFromContainer(container: AbstractScene): void;
  103957. /**
  103958. * Rebuilds the elements related to this component in case of
  103959. * context lost for instance.
  103960. */
  103961. dispose(): void;
  103962. private _gatherRenderTargets;
  103963. }
  103964. }
  103965. declare module BABYLON {
  103966. /**
  103967. * A directional light is defined by a direction (what a surprise!).
  103968. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103969. * 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.
  103970. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103971. */
  103972. export class DirectionalLight extends ShadowLight {
  103973. private _shadowFrustumSize;
  103974. /**
  103975. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103976. */
  103977. /**
  103978. * Specifies a fix frustum size for the shadow generation.
  103979. */
  103980. shadowFrustumSize: number;
  103981. private _shadowOrthoScale;
  103982. /**
  103983. * Gets the shadow projection scale against the optimal computed one.
  103984. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103985. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103986. */
  103987. /**
  103988. * Sets the shadow projection scale against the optimal computed one.
  103989. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103990. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103991. */
  103992. shadowOrthoScale: number;
  103993. /**
  103994. * Automatically compute the projection matrix to best fit (including all the casters)
  103995. * on each frame.
  103996. */
  103997. autoUpdateExtends: boolean;
  103998. private _orthoLeft;
  103999. private _orthoRight;
  104000. private _orthoTop;
  104001. private _orthoBottom;
  104002. /**
  104003. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  104004. * The directional light is emitted from everywhere in the given direction.
  104005. * It can cast shadows.
  104006. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104007. * @param name The friendly name of the light
  104008. * @param direction The direction of the light
  104009. * @param scene The scene the light belongs to
  104010. */
  104011. constructor(name: string, direction: Vector3, scene: Scene);
  104012. /**
  104013. * Returns the string "DirectionalLight".
  104014. * @return The class name
  104015. */
  104016. getClassName(): string;
  104017. /**
  104018. * Returns the integer 1.
  104019. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104020. */
  104021. getTypeID(): number;
  104022. /**
  104023. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  104024. * Returns the DirectionalLight Shadow projection matrix.
  104025. */
  104026. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104027. /**
  104028. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  104029. * Returns the DirectionalLight Shadow projection matrix.
  104030. */
  104031. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  104032. /**
  104033. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  104034. * Returns the DirectionalLight Shadow projection matrix.
  104035. */
  104036. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104037. protected _buildUniformLayout(): void;
  104038. /**
  104039. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  104040. * @param effect The effect to update
  104041. * @param lightIndex The index of the light in the effect to update
  104042. * @returns The directional light
  104043. */
  104044. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  104045. /**
  104046. * Gets the minZ used for shadow according to both the scene and the light.
  104047. *
  104048. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104049. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104050. * @param activeCamera The camera we are returning the min for
  104051. * @returns the depth min z
  104052. */
  104053. getDepthMinZ(activeCamera: Camera): number;
  104054. /**
  104055. * Gets the maxZ used for shadow according to both the scene and the light.
  104056. *
  104057. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104058. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104059. * @param activeCamera The camera we are returning the max for
  104060. * @returns the depth max z
  104061. */
  104062. getDepthMaxZ(activeCamera: Camera): number;
  104063. /**
  104064. * Prepares the list of defines specific to the light type.
  104065. * @param defines the list of defines
  104066. * @param lightIndex defines the index of the light for the effect
  104067. */
  104068. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104069. }
  104070. }
  104071. declare module BABYLON {
  104072. /**
  104073. * A point light is a light defined by an unique point in world space.
  104074. * The light is emitted in every direction from this point.
  104075. * A good example of a point light is a standard light bulb.
  104076. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104077. */
  104078. export class PointLight extends ShadowLight {
  104079. private _shadowAngle;
  104080. /**
  104081. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104082. * This specifies what angle the shadow will use to be created.
  104083. *
  104084. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104085. */
  104086. /**
  104087. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104088. * This specifies what angle the shadow will use to be created.
  104089. *
  104090. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104091. */
  104092. shadowAngle: number;
  104093. /**
  104094. * Gets the direction if it has been set.
  104095. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104096. */
  104097. /**
  104098. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104099. */
  104100. direction: Vector3;
  104101. /**
  104102. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  104103. * A PointLight emits the light in every direction.
  104104. * It can cast shadows.
  104105. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  104106. * ```javascript
  104107. * var pointLight = new PointLight("pl", camera.position, scene);
  104108. * ```
  104109. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104110. * @param name The light friendly name
  104111. * @param position The position of the point light in the scene
  104112. * @param scene The scene the lights belongs to
  104113. */
  104114. constructor(name: string, position: Vector3, scene: Scene);
  104115. /**
  104116. * Returns the string "PointLight"
  104117. * @returns the class name
  104118. */
  104119. getClassName(): string;
  104120. /**
  104121. * Returns the integer 0.
  104122. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104123. */
  104124. getTypeID(): number;
  104125. /**
  104126. * Specifies wether or not the shadowmap should be a cube texture.
  104127. * @returns true if the shadowmap needs to be a cube texture.
  104128. */
  104129. needCube(): boolean;
  104130. /**
  104131. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  104132. * @param faceIndex The index of the face we are computed the direction to generate shadow
  104133. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  104134. */
  104135. getShadowDirection(faceIndex?: number): Vector3;
  104136. /**
  104137. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  104138. * - fov = PI / 2
  104139. * - aspect ratio : 1.0
  104140. * - z-near and far equal to the active camera minZ and maxZ.
  104141. * Returns the PointLight.
  104142. */
  104143. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104144. protected _buildUniformLayout(): void;
  104145. /**
  104146. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  104147. * @param effect The effect to update
  104148. * @param lightIndex The index of the light in the effect to update
  104149. * @returns The point light
  104150. */
  104151. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  104152. /**
  104153. * Prepares the list of defines specific to the light type.
  104154. * @param defines the list of defines
  104155. * @param lightIndex defines the index of the light for the effect
  104156. */
  104157. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104158. }
  104159. }
  104160. declare module BABYLON {
  104161. /**
  104162. * A spot light is defined by a position, a direction, an angle, and an exponent.
  104163. * These values define a cone of light starting from the position, emitting toward the direction.
  104164. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  104165. * and the exponent defines the speed of the decay of the light with distance (reach).
  104166. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104167. */
  104168. export class SpotLight extends ShadowLight {
  104169. private _angle;
  104170. private _innerAngle;
  104171. private _cosHalfAngle;
  104172. private _lightAngleScale;
  104173. private _lightAngleOffset;
  104174. /**
  104175. * Gets the cone angle of the spot light in Radians.
  104176. */
  104177. /**
  104178. * Sets the cone angle of the spot light in Radians.
  104179. */
  104180. angle: number;
  104181. /**
  104182. * Only used in gltf falloff mode, this defines the angle where
  104183. * the directional falloff will start before cutting at angle which could be seen
  104184. * as outer angle.
  104185. */
  104186. /**
  104187. * Only used in gltf falloff mode, this defines the angle where
  104188. * the directional falloff will start before cutting at angle which could be seen
  104189. * as outer angle.
  104190. */
  104191. innerAngle: number;
  104192. private _shadowAngleScale;
  104193. /**
  104194. * Allows scaling the angle of the light for shadow generation only.
  104195. */
  104196. /**
  104197. * Allows scaling the angle of the light for shadow generation only.
  104198. */
  104199. shadowAngleScale: number;
  104200. /**
  104201. * The light decay speed with the distance from the emission spot.
  104202. */
  104203. exponent: number;
  104204. private _projectionTextureMatrix;
  104205. /**
  104206. * Allows reading the projecton texture
  104207. */
  104208. readonly projectionTextureMatrix: Matrix;
  104209. protected _projectionTextureLightNear: number;
  104210. /**
  104211. * Gets the near clip of the Spotlight for texture projection.
  104212. */
  104213. /**
  104214. * Sets the near clip of the Spotlight for texture projection.
  104215. */
  104216. projectionTextureLightNear: number;
  104217. protected _projectionTextureLightFar: number;
  104218. /**
  104219. * Gets the far clip of the Spotlight for texture projection.
  104220. */
  104221. /**
  104222. * Sets the far clip of the Spotlight for texture projection.
  104223. */
  104224. projectionTextureLightFar: number;
  104225. protected _projectionTextureUpDirection: Vector3;
  104226. /**
  104227. * Gets the Up vector of the Spotlight for texture projection.
  104228. */
  104229. /**
  104230. * Sets the Up vector of the Spotlight for texture projection.
  104231. */
  104232. projectionTextureUpDirection: Vector3;
  104233. private _projectionTexture;
  104234. /**
  104235. * Gets the projection texture of the light.
  104236. */
  104237. /**
  104238. * Sets the projection texture of the light.
  104239. */
  104240. projectionTexture: Nullable<BaseTexture>;
  104241. private _projectionTextureViewLightDirty;
  104242. private _projectionTextureProjectionLightDirty;
  104243. private _projectionTextureDirty;
  104244. private _projectionTextureViewTargetVector;
  104245. private _projectionTextureViewLightMatrix;
  104246. private _projectionTextureProjectionLightMatrix;
  104247. private _projectionTextureScalingMatrix;
  104248. /**
  104249. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104250. * It can cast shadows.
  104251. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104252. * @param name The light friendly name
  104253. * @param position The position of the spot light in the scene
  104254. * @param direction The direction of the light in the scene
  104255. * @param angle The cone angle of the light in Radians
  104256. * @param exponent The light decay speed with the distance from the emission spot
  104257. * @param scene The scene the lights belongs to
  104258. */
  104259. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104260. /**
  104261. * Returns the string "SpotLight".
  104262. * @returns the class name
  104263. */
  104264. getClassName(): string;
  104265. /**
  104266. * Returns the integer 2.
  104267. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104268. */
  104269. getTypeID(): number;
  104270. /**
  104271. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104272. */
  104273. protected _setDirection(value: Vector3): void;
  104274. /**
  104275. * Overrides the position setter to recompute the projection texture view light Matrix.
  104276. */
  104277. protected _setPosition(value: Vector3): void;
  104278. /**
  104279. * 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.
  104280. * Returns the SpotLight.
  104281. */
  104282. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104283. protected _computeProjectionTextureViewLightMatrix(): void;
  104284. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104285. /**
  104286. * Main function for light texture projection matrix computing.
  104287. */
  104288. protected _computeProjectionTextureMatrix(): void;
  104289. protected _buildUniformLayout(): void;
  104290. private _computeAngleValues;
  104291. /**
  104292. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104293. * @param effect The effect to update
  104294. * @param lightIndex The index of the light in the effect to update
  104295. * @returns The spot light
  104296. */
  104297. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104298. /**
  104299. * Disposes the light and the associated resources.
  104300. */
  104301. dispose(): void;
  104302. /**
  104303. * Prepares the list of defines specific to the light type.
  104304. * @param defines the list of defines
  104305. * @param lightIndex defines the index of the light for the effect
  104306. */
  104307. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104308. }
  104309. }
  104310. declare module BABYLON {
  104311. /**
  104312. * Header information of HDR texture files.
  104313. */
  104314. export interface HDRInfo {
  104315. /**
  104316. * The height of the texture in pixels.
  104317. */
  104318. height: number;
  104319. /**
  104320. * The width of the texture in pixels.
  104321. */
  104322. width: number;
  104323. /**
  104324. * The index of the beginning of the data in the binary file.
  104325. */
  104326. dataPosition: number;
  104327. }
  104328. /**
  104329. * This groups tools to convert HDR texture to native colors array.
  104330. */
  104331. export class HDRTools {
  104332. private static Ldexp;
  104333. private static Rgbe2float;
  104334. private static readStringLine;
  104335. /**
  104336. * Reads header information from an RGBE texture stored in a native array.
  104337. * More information on this format are available here:
  104338. * https://en.wikipedia.org/wiki/RGBE_image_format
  104339. *
  104340. * @param uint8array The binary file stored in native array.
  104341. * @return The header information.
  104342. */
  104343. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104344. /**
  104345. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104346. * This RGBE texture needs to store the information as a panorama.
  104347. *
  104348. * More information on this format are available here:
  104349. * https://en.wikipedia.org/wiki/RGBE_image_format
  104350. *
  104351. * @param buffer The binary file stored in an array buffer.
  104352. * @param size The expected size of the extracted cubemap.
  104353. * @return The Cube Map information.
  104354. */
  104355. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104356. /**
  104357. * Returns the pixels data extracted from an RGBE texture.
  104358. * This pixels will be stored left to right up to down in the R G B order in one array.
  104359. *
  104360. * More information on this format are available here:
  104361. * https://en.wikipedia.org/wiki/RGBE_image_format
  104362. *
  104363. * @param uint8array The binary file stored in an array buffer.
  104364. * @param hdrInfo The header information of the file.
  104365. * @return The pixels data in RGB right to left up to down order.
  104366. */
  104367. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104368. private static RGBE_ReadPixels_RLE;
  104369. }
  104370. }
  104371. declare module BABYLON {
  104372. /**
  104373. * This represents a texture coming from an HDR input.
  104374. *
  104375. * The only supported format is currently panorama picture stored in RGBE format.
  104376. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104377. */
  104378. export class HDRCubeTexture extends BaseTexture {
  104379. private static _facesMapping;
  104380. private _generateHarmonics;
  104381. private _noMipmap;
  104382. private _textureMatrix;
  104383. private _size;
  104384. private _onLoad;
  104385. private _onError;
  104386. /**
  104387. * The texture URL.
  104388. */
  104389. url: string;
  104390. /**
  104391. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104392. */
  104393. coordinatesMode: number;
  104394. protected _isBlocking: boolean;
  104395. /**
  104396. * Sets wether or not the texture is blocking during loading.
  104397. */
  104398. /**
  104399. * Gets wether or not the texture is blocking during loading.
  104400. */
  104401. isBlocking: boolean;
  104402. protected _rotationY: number;
  104403. /**
  104404. * Sets texture matrix rotation angle around Y axis in radians.
  104405. */
  104406. /**
  104407. * Gets texture matrix rotation angle around Y axis radians.
  104408. */
  104409. rotationY: number;
  104410. /**
  104411. * Gets or sets the center of the bounding box associated with the cube texture
  104412. * It must define where the camera used to render the texture was set
  104413. */
  104414. boundingBoxPosition: Vector3;
  104415. private _boundingBoxSize;
  104416. /**
  104417. * Gets or sets the size of the bounding box associated with the cube texture
  104418. * When defined, the cubemap will switch to local mode
  104419. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104420. * @example https://www.babylonjs-playground.com/#RNASML
  104421. */
  104422. boundingBoxSize: Vector3;
  104423. /**
  104424. * Instantiates an HDRTexture from the following parameters.
  104425. *
  104426. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104427. * @param scene The scene the texture will be used in
  104428. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104429. * @param noMipmap Forces to not generate the mipmap if true
  104430. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104431. * @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)
  104432. * @param reserved Reserved flag for internal use.
  104433. */
  104434. 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>);
  104435. /**
  104436. * Get the current class name of the texture useful for serialization or dynamic coding.
  104437. * @returns "HDRCubeTexture"
  104438. */
  104439. getClassName(): string;
  104440. /**
  104441. * Occurs when the file is raw .hdr file.
  104442. */
  104443. private loadTexture;
  104444. clone(): HDRCubeTexture;
  104445. delayLoad(): void;
  104446. /**
  104447. * Get the texture reflection matrix used to rotate/transform the reflection.
  104448. * @returns the reflection matrix
  104449. */
  104450. getReflectionTextureMatrix(): Matrix;
  104451. /**
  104452. * Set the texture reflection matrix used to rotate/transform the reflection.
  104453. * @param value Define the reflection matrix to set
  104454. */
  104455. setReflectionTextureMatrix(value: Matrix): void;
  104456. /**
  104457. * Parses a JSON representation of an HDR Texture in order to create the texture
  104458. * @param parsedTexture Define the JSON representation
  104459. * @param scene Define the scene the texture should be created in
  104460. * @param rootUrl Define the root url in case we need to load relative dependencies
  104461. * @returns the newly created texture after parsing
  104462. */
  104463. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104464. serialize(): any;
  104465. }
  104466. }
  104467. declare module BABYLON {
  104468. /**
  104469. * Class used to control physics engine
  104470. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104471. */
  104472. export class PhysicsEngine implements IPhysicsEngine {
  104473. private _physicsPlugin;
  104474. /**
  104475. * Global value used to control the smallest number supported by the simulation
  104476. */
  104477. static Epsilon: number;
  104478. private _impostors;
  104479. private _joints;
  104480. /**
  104481. * Gets the gravity vector used by the simulation
  104482. */
  104483. gravity: Vector3;
  104484. /**
  104485. * Factory used to create the default physics plugin.
  104486. * @returns The default physics plugin
  104487. */
  104488. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104489. /**
  104490. * Creates a new Physics Engine
  104491. * @param gravity defines the gravity vector used by the simulation
  104492. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104493. */
  104494. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104495. /**
  104496. * Sets the gravity vector used by the simulation
  104497. * @param gravity defines the gravity vector to use
  104498. */
  104499. setGravity(gravity: Vector3): void;
  104500. /**
  104501. * Set the time step of the physics engine.
  104502. * Default is 1/60.
  104503. * To slow it down, enter 1/600 for example.
  104504. * To speed it up, 1/30
  104505. * @param newTimeStep defines the new timestep to apply to this world.
  104506. */
  104507. setTimeStep(newTimeStep?: number): void;
  104508. /**
  104509. * Get the time step of the physics engine.
  104510. * @returns the current time step
  104511. */
  104512. getTimeStep(): number;
  104513. /**
  104514. * Release all resources
  104515. */
  104516. dispose(): void;
  104517. /**
  104518. * Gets the name of the current physics plugin
  104519. * @returns the name of the plugin
  104520. */
  104521. getPhysicsPluginName(): string;
  104522. /**
  104523. * Adding a new impostor for the impostor tracking.
  104524. * This will be done by the impostor itself.
  104525. * @param impostor the impostor to add
  104526. */
  104527. addImpostor(impostor: PhysicsImpostor): void;
  104528. /**
  104529. * Remove an impostor from the engine.
  104530. * This impostor and its mesh will not longer be updated by the physics engine.
  104531. * @param impostor the impostor to remove
  104532. */
  104533. removeImpostor(impostor: PhysicsImpostor): void;
  104534. /**
  104535. * Add a joint to the physics engine
  104536. * @param mainImpostor defines the main impostor to which the joint is added.
  104537. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104538. * @param joint defines the joint that will connect both impostors.
  104539. */
  104540. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104541. /**
  104542. * Removes a joint from the simulation
  104543. * @param mainImpostor defines the impostor used with the joint
  104544. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104545. * @param joint defines the joint to remove
  104546. */
  104547. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104548. /**
  104549. * Called by the scene. No need to call it.
  104550. * @param delta defines the timespam between frames
  104551. */
  104552. _step(delta: number): void;
  104553. /**
  104554. * Gets the current plugin used to run the simulation
  104555. * @returns current plugin
  104556. */
  104557. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104558. /**
  104559. * Gets the list of physic impostors
  104560. * @returns an array of PhysicsImpostor
  104561. */
  104562. getImpostors(): Array<PhysicsImpostor>;
  104563. /**
  104564. * Gets the impostor for a physics enabled object
  104565. * @param object defines the object impersonated by the impostor
  104566. * @returns the PhysicsImpostor or null if not found
  104567. */
  104568. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104569. /**
  104570. * Gets the impostor for a physics body object
  104571. * @param body defines physics body used by the impostor
  104572. * @returns the PhysicsImpostor or null if not found
  104573. */
  104574. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104575. }
  104576. }
  104577. declare module BABYLON {
  104578. /** @hidden */
  104579. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104580. private _useDeltaForWorldStep;
  104581. world: any;
  104582. name: string;
  104583. private _physicsMaterials;
  104584. private _fixedTimeStep;
  104585. BJSCANNON: any;
  104586. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104587. setGravity(gravity: Vector3): void;
  104588. setTimeStep(timeStep: number): void;
  104589. getTimeStep(): number;
  104590. executeStep(delta: number): void;
  104591. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104592. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104593. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104594. private _processChildMeshes;
  104595. removePhysicsBody(impostor: PhysicsImpostor): void;
  104596. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104597. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104598. private _addMaterial;
  104599. private _checkWithEpsilon;
  104600. private _createShape;
  104601. private _createHeightmap;
  104602. private _minus90X;
  104603. private _plus90X;
  104604. private _tmpPosition;
  104605. private _tmpDeltaPosition;
  104606. private _tmpUnityRotation;
  104607. private _updatePhysicsBodyTransformation;
  104608. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104609. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104610. isSupported(): boolean;
  104611. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104612. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104613. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104614. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104615. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104616. getBodyMass(impostor: PhysicsImpostor): number;
  104617. getBodyFriction(impostor: PhysicsImpostor): number;
  104618. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104619. getBodyRestitution(impostor: PhysicsImpostor): number;
  104620. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104621. sleepBody(impostor: PhysicsImpostor): void;
  104622. wakeUpBody(impostor: PhysicsImpostor): void;
  104623. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104624. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104625. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104626. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104627. getRadius(impostor: PhysicsImpostor): number;
  104628. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104629. dispose(): void;
  104630. private _extendNamespace;
  104631. }
  104632. }
  104633. declare module BABYLON {
  104634. /** @hidden */
  104635. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104636. world: any;
  104637. name: string;
  104638. BJSOIMO: any;
  104639. constructor(iterations?: number, oimoInjection?: any);
  104640. setGravity(gravity: Vector3): void;
  104641. setTimeStep(timeStep: number): void;
  104642. getTimeStep(): number;
  104643. private _tmpImpostorsArray;
  104644. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104645. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104646. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104647. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104648. private _tmpPositionVector;
  104649. removePhysicsBody(impostor: PhysicsImpostor): void;
  104650. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104651. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104652. isSupported(): boolean;
  104653. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104654. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104655. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104656. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104657. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104658. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104659. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104660. getBodyMass(impostor: PhysicsImpostor): number;
  104661. getBodyFriction(impostor: PhysicsImpostor): number;
  104662. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104663. getBodyRestitution(impostor: PhysicsImpostor): number;
  104664. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104665. sleepBody(impostor: PhysicsImpostor): void;
  104666. wakeUpBody(impostor: PhysicsImpostor): void;
  104667. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104668. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104669. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104670. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104671. getRadius(impostor: PhysicsImpostor): number;
  104672. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104673. dispose(): void;
  104674. }
  104675. }
  104676. declare module BABYLON {
  104677. interface AbstractScene {
  104678. /**
  104679. * The list of reflection probes added to the scene
  104680. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104681. */
  104682. reflectionProbes: Array<ReflectionProbe>;
  104683. /**
  104684. * Removes the given reflection probe from this scene.
  104685. * @param toRemove The reflection probe to remove
  104686. * @returns The index of the removed reflection probe
  104687. */
  104688. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104689. /**
  104690. * Adds the given reflection probe to this scene.
  104691. * @param newReflectionProbe The reflection probe to add
  104692. */
  104693. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104694. }
  104695. /**
  104696. * Class used to generate realtime reflection / refraction cube textures
  104697. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104698. */
  104699. export class ReflectionProbe {
  104700. /** defines the name of the probe */
  104701. name: string;
  104702. private _scene;
  104703. private _renderTargetTexture;
  104704. private _projectionMatrix;
  104705. private _viewMatrix;
  104706. private _target;
  104707. private _add;
  104708. private _attachedMesh;
  104709. private _invertYAxis;
  104710. /** Gets or sets probe position (center of the cube map) */
  104711. position: Vector3;
  104712. /**
  104713. * Creates a new reflection probe
  104714. * @param name defines the name of the probe
  104715. * @param size defines the texture resolution (for each face)
  104716. * @param scene defines the hosting scene
  104717. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104718. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104719. */
  104720. constructor(
  104721. /** defines the name of the probe */
  104722. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104723. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104724. samples: number;
  104725. /** Gets or sets the refresh rate to use (on every frame by default) */
  104726. refreshRate: number;
  104727. /**
  104728. * Gets the hosting scene
  104729. * @returns a Scene
  104730. */
  104731. getScene(): Scene;
  104732. /** Gets the internal CubeTexture used to render to */
  104733. readonly cubeTexture: RenderTargetTexture;
  104734. /** Gets the list of meshes to render */
  104735. readonly renderList: Nullable<AbstractMesh[]>;
  104736. /**
  104737. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104738. * @param mesh defines the mesh to attach to
  104739. */
  104740. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104741. /**
  104742. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104743. * @param renderingGroupId The rendering group id corresponding to its index
  104744. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104745. */
  104746. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104747. /**
  104748. * Clean all associated resources
  104749. */
  104750. dispose(): void;
  104751. /**
  104752. * Converts the reflection probe information to a readable string for debug purpose.
  104753. * @param fullDetails Supports for multiple levels of logging within scene loading
  104754. * @returns the human readable reflection probe info
  104755. */
  104756. toString(fullDetails?: boolean): string;
  104757. /**
  104758. * Get the class name of the relfection probe.
  104759. * @returns "ReflectionProbe"
  104760. */
  104761. getClassName(): string;
  104762. /**
  104763. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104764. * @returns The JSON representation of the texture
  104765. */
  104766. serialize(): any;
  104767. /**
  104768. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104769. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104770. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104771. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104772. * @returns The parsed reflection probe if successful
  104773. */
  104774. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104775. }
  104776. }
  104777. declare module BABYLON {
  104778. /** @hidden */
  104779. export var _BabylonLoaderRegistered: boolean;
  104780. }
  104781. declare module BABYLON {
  104782. /**
  104783. * The Physically based simple base material of BJS.
  104784. *
  104785. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104786. * It is used as the base class for both the specGloss and metalRough conventions.
  104787. */
  104788. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104789. /**
  104790. * Number of Simultaneous lights allowed on the material.
  104791. */
  104792. maxSimultaneousLights: number;
  104793. /**
  104794. * If sets to true, disables all the lights affecting the material.
  104795. */
  104796. disableLighting: boolean;
  104797. /**
  104798. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104799. */
  104800. environmentTexture: BaseTexture;
  104801. /**
  104802. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104803. */
  104804. invertNormalMapX: boolean;
  104805. /**
  104806. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104807. */
  104808. invertNormalMapY: boolean;
  104809. /**
  104810. * Normal map used in the model.
  104811. */
  104812. normalTexture: BaseTexture;
  104813. /**
  104814. * Emissivie color used to self-illuminate the model.
  104815. */
  104816. emissiveColor: Color3;
  104817. /**
  104818. * Emissivie texture used to self-illuminate the model.
  104819. */
  104820. emissiveTexture: BaseTexture;
  104821. /**
  104822. * Occlusion Channel Strenght.
  104823. */
  104824. occlusionStrength: number;
  104825. /**
  104826. * Occlusion Texture of the material (adding extra occlusion effects).
  104827. */
  104828. occlusionTexture: BaseTexture;
  104829. /**
  104830. * Defines the alpha limits in alpha test mode.
  104831. */
  104832. alphaCutOff: number;
  104833. /**
  104834. * Gets the current double sided mode.
  104835. */
  104836. /**
  104837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104838. */
  104839. doubleSided: boolean;
  104840. /**
  104841. * Stores the pre-calculated light information of a mesh in a texture.
  104842. */
  104843. lightmapTexture: BaseTexture;
  104844. /**
  104845. * If true, the light map contains occlusion information instead of lighting info.
  104846. */
  104847. useLightmapAsShadowmap: boolean;
  104848. /**
  104849. * Instantiates a new PBRMaterial instance.
  104850. *
  104851. * @param name The material name
  104852. * @param scene The scene the material will be use in.
  104853. */
  104854. constructor(name: string, scene: Scene);
  104855. getClassName(): string;
  104856. }
  104857. }
  104858. declare module BABYLON {
  104859. /**
  104860. * The PBR material of BJS following the metal roughness convention.
  104861. *
  104862. * This fits to the PBR convention in the GLTF definition:
  104863. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  104864. */
  104865. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  104866. /**
  104867. * The base color has two different interpretations depending on the value of metalness.
  104868. * When the material is a metal, the base color is the specific measured reflectance value
  104869. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  104870. * of the material.
  104871. */
  104872. baseColor: Color3;
  104873. /**
  104874. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  104875. * well as opacity information in the alpha channel.
  104876. */
  104877. baseTexture: BaseTexture;
  104878. /**
  104879. * Specifies the metallic scalar value of the material.
  104880. * Can also be used to scale the metalness values of the metallic texture.
  104881. */
  104882. metallic: number;
  104883. /**
  104884. * Specifies the roughness scalar value of the material.
  104885. * Can also be used to scale the roughness values of the metallic texture.
  104886. */
  104887. roughness: number;
  104888. /**
  104889. * Texture containing both the metallic value in the B channel and the
  104890. * roughness value in the G channel to keep better precision.
  104891. */
  104892. metallicRoughnessTexture: BaseTexture;
  104893. /**
  104894. * Instantiates a new PBRMetalRoughnessMaterial instance.
  104895. *
  104896. * @param name The material name
  104897. * @param scene The scene the material will be use in.
  104898. */
  104899. constructor(name: string, scene: Scene);
  104900. /**
  104901. * Return the currrent class name of the material.
  104902. */
  104903. getClassName(): string;
  104904. /**
  104905. * Makes a duplicate of the current material.
  104906. * @param name - name to use for the new material.
  104907. */
  104908. clone(name: string): PBRMetallicRoughnessMaterial;
  104909. /**
  104910. * Serialize the material to a parsable JSON object.
  104911. */
  104912. serialize(): any;
  104913. /**
  104914. * Parses a JSON object correponding to the serialize function.
  104915. */
  104916. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  104917. }
  104918. }
  104919. declare module BABYLON {
  104920. /**
  104921. * The PBR material of BJS following the specular glossiness convention.
  104922. *
  104923. * This fits to the PBR convention in the GLTF definition:
  104924. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  104925. */
  104926. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  104927. /**
  104928. * Specifies the diffuse color of the material.
  104929. */
  104930. diffuseColor: Color3;
  104931. /**
  104932. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  104933. * channel.
  104934. */
  104935. diffuseTexture: BaseTexture;
  104936. /**
  104937. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  104938. */
  104939. specularColor: Color3;
  104940. /**
  104941. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  104942. */
  104943. glossiness: number;
  104944. /**
  104945. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  104946. */
  104947. specularGlossinessTexture: BaseTexture;
  104948. /**
  104949. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  104950. *
  104951. * @param name The material name
  104952. * @param scene The scene the material will be use in.
  104953. */
  104954. constructor(name: string, scene: Scene);
  104955. /**
  104956. * Return the currrent class name of the material.
  104957. */
  104958. getClassName(): string;
  104959. /**
  104960. * Makes a duplicate of the current material.
  104961. * @param name - name to use for the new material.
  104962. */
  104963. clone(name: string): PBRSpecularGlossinessMaterial;
  104964. /**
  104965. * Serialize the material to a parsable JSON object.
  104966. */
  104967. serialize(): any;
  104968. /**
  104969. * Parses a JSON object correponding to the serialize function.
  104970. */
  104971. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  104972. }
  104973. }
  104974. declare module BABYLON {
  104975. /**
  104976. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  104977. * It can help converting any input color in a desired output one. This can then be used to create effects
  104978. * from sepia, black and white to sixties or futuristic rendering...
  104979. *
  104980. * The only supported format is currently 3dl.
  104981. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  104982. */
  104983. export class ColorGradingTexture extends BaseTexture {
  104984. /**
  104985. * The current texture matrix. (will always be identity in color grading texture)
  104986. */
  104987. private _textureMatrix;
  104988. /**
  104989. * The texture URL.
  104990. */
  104991. url: string;
  104992. /**
  104993. * Empty line regex stored for GC.
  104994. */
  104995. private static _noneEmptyLineRegex;
  104996. private _engine;
  104997. /**
  104998. * Instantiates a ColorGradingTexture from the following parameters.
  104999. *
  105000. * @param url The location of the color gradind data (currently only supporting 3dl)
  105001. * @param scene The scene the texture will be used in
  105002. */
  105003. constructor(url: string, scene: Scene);
  105004. /**
  105005. * Returns the texture matrix used in most of the material.
  105006. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  105007. */
  105008. getTextureMatrix(): Matrix;
  105009. /**
  105010. * Occurs when the file being loaded is a .3dl LUT file.
  105011. */
  105012. private load3dlTexture;
  105013. /**
  105014. * Starts the loading process of the texture.
  105015. */
  105016. private loadTexture;
  105017. /**
  105018. * Clones the color gradind texture.
  105019. */
  105020. clone(): ColorGradingTexture;
  105021. /**
  105022. * Called during delayed load for textures.
  105023. */
  105024. delayLoad(): void;
  105025. /**
  105026. * Parses a color grading texture serialized by Babylon.
  105027. * @param parsedTexture The texture information being parsedTexture
  105028. * @param scene The scene to load the texture in
  105029. * @param rootUrl The root url of the data assets to load
  105030. * @return A color gradind texture
  105031. */
  105032. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  105033. /**
  105034. * Serializes the LUT texture to json format.
  105035. */
  105036. serialize(): any;
  105037. }
  105038. }
  105039. declare module BABYLON {
  105040. /**
  105041. * Based on jsTGALoader - Javascript loader for TGA file
  105042. * By Vincent Thibault
  105043. * @see http://blog.robrowser.com/javascript-tga-loader.html
  105044. */
  105045. export class TGATools {
  105046. private static _TYPE_INDEXED;
  105047. private static _TYPE_RGB;
  105048. private static _TYPE_GREY;
  105049. private static _TYPE_RLE_INDEXED;
  105050. private static _TYPE_RLE_RGB;
  105051. private static _TYPE_RLE_GREY;
  105052. private static _ORIGIN_MASK;
  105053. private static _ORIGIN_SHIFT;
  105054. private static _ORIGIN_BL;
  105055. private static _ORIGIN_BR;
  105056. private static _ORIGIN_UL;
  105057. private static _ORIGIN_UR;
  105058. /**
  105059. * Gets the header of a TGA file
  105060. * @param data defines the TGA data
  105061. * @returns the header
  105062. */
  105063. static GetTGAHeader(data: Uint8Array): any;
  105064. /**
  105065. * Uploads TGA content to a Babylon Texture
  105066. * @hidden
  105067. */
  105068. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  105069. /** @hidden */
  105070. 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;
  105071. /** @hidden */
  105072. 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;
  105073. /** @hidden */
  105074. 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;
  105075. /** @hidden */
  105076. 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;
  105077. /** @hidden */
  105078. 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;
  105079. /** @hidden */
  105080. 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;
  105081. }
  105082. }
  105083. declare module BABYLON {
  105084. /**
  105085. * Implementation of the TGA Texture Loader.
  105086. * @hidden
  105087. */
  105088. export class _TGATextureLoader implements IInternalTextureLoader {
  105089. /**
  105090. * Defines wether the loader supports cascade loading the different faces.
  105091. */
  105092. readonly supportCascades: boolean;
  105093. /**
  105094. * This returns if the loader support the current file information.
  105095. * @param extension defines the file extension of the file being loaded
  105096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105097. * @param fallback defines the fallback internal texture if any
  105098. * @param isBase64 defines whether the texture is encoded as a base64
  105099. * @param isBuffer defines whether the texture data are stored as a buffer
  105100. * @returns true if the loader can load the specified file
  105101. */
  105102. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105103. /**
  105104. * Transform the url before loading if required.
  105105. * @param rootUrl the url of the texture
  105106. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105107. * @returns the transformed texture
  105108. */
  105109. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105110. /**
  105111. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105112. * @param rootUrl the url of the texture
  105113. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105114. * @returns the fallback texture
  105115. */
  105116. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105117. /**
  105118. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105119. * @param data contains the texture data
  105120. * @param texture defines the BabylonJS internal texture
  105121. * @param createPolynomials will be true if polynomials have been requested
  105122. * @param onLoad defines the callback to trigger once the texture is ready
  105123. * @param onError defines the callback to trigger in case of error
  105124. */
  105125. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105126. /**
  105127. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105128. * @param data contains the texture data
  105129. * @param texture defines the BabylonJS internal texture
  105130. * @param callback defines the method to call once ready to upload
  105131. */
  105132. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105133. }
  105134. }
  105135. declare module BABYLON {
  105136. /**
  105137. * 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.
  105138. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  105139. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  105140. */
  105141. export class CustomProceduralTexture extends ProceduralTexture {
  105142. private _animate;
  105143. private _time;
  105144. private _config;
  105145. private _texturePath;
  105146. /**
  105147. * Instantiates a new Custom Procedural Texture.
  105148. * 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.
  105149. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  105150. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  105151. * @param name Define the name of the texture
  105152. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  105153. * @param size Define the size of the texture to create
  105154. * @param scene Define the scene the texture belongs to
  105155. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  105156. * @param generateMipMaps Define if the texture should creates mip maps or not
  105157. */
  105158. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105159. private _loadJson;
  105160. /**
  105161. * Is the texture ready to be used ? (rendered at least once)
  105162. * @returns true if ready, otherwise, false.
  105163. */
  105164. isReady(): boolean;
  105165. /**
  105166. * Render the texture to its associated render target.
  105167. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  105168. */
  105169. render(useCameraPostProcess?: boolean): void;
  105170. /**
  105171. * Update the list of dependant textures samplers in the shader.
  105172. */
  105173. updateTextures(): void;
  105174. /**
  105175. * Update the uniform values of the procedural texture in the shader.
  105176. */
  105177. updateShaderUniforms(): void;
  105178. /**
  105179. * Define if the texture animates or not.
  105180. */
  105181. animate: boolean;
  105182. }
  105183. }
  105184. declare module BABYLON {
  105185. /** @hidden */
  105186. export var noisePixelShader: {
  105187. name: string;
  105188. shader: string;
  105189. };
  105190. }
  105191. declare module BABYLON {
  105192. /**
  105193. * Class used to generate noise procedural textures
  105194. */
  105195. export class NoiseProceduralTexture extends ProceduralTexture {
  105196. private _time;
  105197. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  105198. brightness: number;
  105199. /** Defines the number of octaves to process */
  105200. octaves: number;
  105201. /** Defines the level of persistence (0.8 by default) */
  105202. persistence: number;
  105203. /** Gets or sets animation speed factor (default is 1) */
  105204. animationSpeedFactor: number;
  105205. /**
  105206. * Creates a new NoiseProceduralTexture
  105207. * @param name defines the name fo the texture
  105208. * @param size defines the size of the texture (default is 256)
  105209. * @param scene defines the hosting scene
  105210. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  105211. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  105212. */
  105213. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105214. private _updateShaderUniforms;
  105215. protected _getDefines(): string;
  105216. /** Generate the current state of the procedural texture */
  105217. render(useCameraPostProcess?: boolean): void;
  105218. /**
  105219. * Serializes this noise procedural texture
  105220. * @returns a serialized noise procedural texture object
  105221. */
  105222. serialize(): any;
  105223. /**
  105224. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105225. * @param parsedTexture defines parsed texture data
  105226. * @param scene defines the current scene
  105227. * @param rootUrl defines the root URL containing noise procedural texture information
  105228. * @returns a parsed NoiseProceduralTexture
  105229. */
  105230. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105231. }
  105232. }
  105233. declare module BABYLON {
  105234. /**
  105235. * Raw cube texture where the raw buffers are passed in
  105236. */
  105237. export class RawCubeTexture extends CubeTexture {
  105238. /**
  105239. * Creates a cube texture where the raw buffers are passed in.
  105240. * @param scene defines the scene the texture is attached to
  105241. * @param data defines the array of data to use to create each face
  105242. * @param size defines the size of the textures
  105243. * @param format defines the format of the data
  105244. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105245. * @param generateMipMaps defines if the engine should generate the mip levels
  105246. * @param invertY defines if data must be stored with Y axis inverted
  105247. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105248. * @param compression defines the compression used (null by default)
  105249. */
  105250. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105251. /**
  105252. * Updates the raw cube texture.
  105253. * @param data defines the data to store
  105254. * @param format defines the data format
  105255. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105256. * @param invertY defines if data must be stored with Y axis inverted
  105257. * @param compression defines the compression used (null by default)
  105258. * @param level defines which level of the texture to update
  105259. */
  105260. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105261. /**
  105262. * Updates a raw cube texture with RGBD encoded data.
  105263. * @param data defines the array of data [mipmap][face] to use to create each face
  105264. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105265. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105266. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105267. * @returns a promsie that resolves when the operation is complete
  105268. */
  105269. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105270. /**
  105271. * Clones the raw cube texture.
  105272. * @return a new cube texture
  105273. */
  105274. clone(): CubeTexture;
  105275. /** @hidden */
  105276. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105277. }
  105278. }
  105279. declare module BABYLON {
  105280. /**
  105281. * Class used to store 3D textures containing user data
  105282. */
  105283. export class RawTexture3D extends Texture {
  105284. /** Gets or sets the texture format to use */
  105285. format: number;
  105286. private _engine;
  105287. /**
  105288. * Create a new RawTexture3D
  105289. * @param data defines the data of the texture
  105290. * @param width defines the width of the texture
  105291. * @param height defines the height of the texture
  105292. * @param depth defines the depth of the texture
  105293. * @param format defines the texture format to use
  105294. * @param scene defines the hosting scene
  105295. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105296. * @param invertY defines if texture must be stored with Y axis inverted
  105297. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105298. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105299. */
  105300. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105301. /** Gets or sets the texture format to use */
  105302. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105303. /**
  105304. * Update the texture with new data
  105305. * @param data defines the data to store in the texture
  105306. */
  105307. update(data: ArrayBufferView): void;
  105308. }
  105309. }
  105310. declare module BABYLON {
  105311. /**
  105312. * Creates a refraction texture used by refraction channel of the standard material.
  105313. * It is like a mirror but to see through a material.
  105314. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105315. */
  105316. export class RefractionTexture extends RenderTargetTexture {
  105317. /**
  105318. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105319. * 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.
  105320. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105321. */
  105322. refractionPlane: Plane;
  105323. /**
  105324. * Define how deep under the surface we should see.
  105325. */
  105326. depth: number;
  105327. /**
  105328. * Creates a refraction texture used by refraction channel of the standard material.
  105329. * It is like a mirror but to see through a material.
  105330. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105331. * @param name Define the texture name
  105332. * @param size Define the size of the underlying texture
  105333. * @param scene Define the scene the refraction belongs to
  105334. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105335. */
  105336. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105337. /**
  105338. * Clone the refraction texture.
  105339. * @returns the cloned texture
  105340. */
  105341. clone(): RefractionTexture;
  105342. /**
  105343. * Serialize the texture to a JSON representation you could use in Parse later on
  105344. * @returns the serialized JSON representation
  105345. */
  105346. serialize(): any;
  105347. }
  105348. }
  105349. declare module BABYLON {
  105350. /**
  105351. * Configuration for Draco compression
  105352. */
  105353. export interface IDracoCompressionConfiguration {
  105354. /**
  105355. * Configuration for the decoder.
  105356. */
  105357. decoder?: {
  105358. /**
  105359. * The url to the WebAssembly module.
  105360. */
  105361. wasmUrl?: string;
  105362. /**
  105363. * The url to the WebAssembly binary.
  105364. */
  105365. wasmBinaryUrl?: string;
  105366. /**
  105367. * The url to the fallback JavaScript module.
  105368. */
  105369. fallbackUrl?: string;
  105370. };
  105371. }
  105372. /**
  105373. * Draco compression (https://google.github.io/draco/)
  105374. *
  105375. * This class wraps the Draco module.
  105376. *
  105377. * **Encoder**
  105378. *
  105379. * The encoder is not currently implemented.
  105380. *
  105381. * **Decoder**
  105382. *
  105383. * 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.
  105384. *
  105385. * To update the configuration, use the following code:
  105386. * ```javascript
  105387. * DracoCompression.Configuration = {
  105388. * decoder: {
  105389. * wasmUrl: "<url to the WebAssembly library>",
  105390. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105391. * fallbackUrl: "<url to the fallback JavaScript library>",
  105392. * }
  105393. * };
  105394. * ```
  105395. *
  105396. * 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.
  105397. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105398. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105399. *
  105400. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105401. * ```javascript
  105402. * var dracoCompression = new DracoCompression();
  105403. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105404. * [VertexBuffer.PositionKind]: 0
  105405. * });
  105406. * ```
  105407. *
  105408. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105409. */
  105410. export class DracoCompression implements IDisposable {
  105411. private static _DecoderModulePromise;
  105412. /**
  105413. * The configuration. Defaults to the following urls:
  105414. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105415. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105416. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105417. */
  105418. static Configuration: IDracoCompressionConfiguration;
  105419. /**
  105420. * Returns true if the decoder is available.
  105421. */
  105422. static readonly DecoderAvailable: boolean;
  105423. /**
  105424. * Constructor
  105425. */
  105426. constructor();
  105427. /**
  105428. * Stop all async operations and release resources.
  105429. */
  105430. dispose(): void;
  105431. /**
  105432. * Decode Draco compressed mesh data to vertex data.
  105433. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105434. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105435. * @returns A promise that resolves with the decoded vertex data
  105436. */
  105437. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105438. [kind: string]: number;
  105439. }): Promise<VertexData>;
  105440. private static _GetDecoderModule;
  105441. private static _LoadScriptAsync;
  105442. private static _LoadFileAsync;
  105443. }
  105444. }
  105445. declare module BABYLON {
  105446. /**
  105447. * Class for building Constructive Solid Geometry
  105448. */
  105449. export class CSG {
  105450. private polygons;
  105451. /**
  105452. * The world matrix
  105453. */
  105454. matrix: Matrix;
  105455. /**
  105456. * Stores the position
  105457. */
  105458. position: Vector3;
  105459. /**
  105460. * Stores the rotation
  105461. */
  105462. rotation: Vector3;
  105463. /**
  105464. * Stores the rotation quaternion
  105465. */
  105466. rotationQuaternion: Nullable<Quaternion>;
  105467. /**
  105468. * Stores the scaling vector
  105469. */
  105470. scaling: Vector3;
  105471. /**
  105472. * Convert the Mesh to CSG
  105473. * @param mesh The Mesh to convert to CSG
  105474. * @returns A new CSG from the Mesh
  105475. */
  105476. static FromMesh(mesh: Mesh): CSG;
  105477. /**
  105478. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105479. * @param polygons Polygons used to construct a CSG solid
  105480. */
  105481. private static FromPolygons;
  105482. /**
  105483. * Clones, or makes a deep copy, of the CSG
  105484. * @returns A new CSG
  105485. */
  105486. clone(): CSG;
  105487. /**
  105488. * Unions this CSG with another CSG
  105489. * @param csg The CSG to union against this CSG
  105490. * @returns The unioned CSG
  105491. */
  105492. union(csg: CSG): CSG;
  105493. /**
  105494. * Unions this CSG with another CSG in place
  105495. * @param csg The CSG to union against this CSG
  105496. */
  105497. unionInPlace(csg: CSG): void;
  105498. /**
  105499. * Subtracts this CSG with another CSG
  105500. * @param csg The CSG to subtract against this CSG
  105501. * @returns A new CSG
  105502. */
  105503. subtract(csg: CSG): CSG;
  105504. /**
  105505. * Subtracts this CSG with another CSG in place
  105506. * @param csg The CSG to subtact against this CSG
  105507. */
  105508. subtractInPlace(csg: CSG): void;
  105509. /**
  105510. * Intersect this CSG with another CSG
  105511. * @param csg The CSG to intersect against this CSG
  105512. * @returns A new CSG
  105513. */
  105514. intersect(csg: CSG): CSG;
  105515. /**
  105516. * Intersects this CSG with another CSG in place
  105517. * @param csg The CSG to intersect against this CSG
  105518. */
  105519. intersectInPlace(csg: CSG): void;
  105520. /**
  105521. * Return a new CSG solid with solid and empty space switched. This solid is
  105522. * not modified.
  105523. * @returns A new CSG solid with solid and empty space switched
  105524. */
  105525. inverse(): CSG;
  105526. /**
  105527. * Inverses the CSG in place
  105528. */
  105529. inverseInPlace(): void;
  105530. /**
  105531. * This is used to keep meshes transformations so they can be restored
  105532. * when we build back a Babylon Mesh
  105533. * NB : All CSG operations are performed in world coordinates
  105534. * @param csg The CSG to copy the transform attributes from
  105535. * @returns This CSG
  105536. */
  105537. copyTransformAttributes(csg: CSG): CSG;
  105538. /**
  105539. * Build Raw mesh from CSG
  105540. * Coordinates here are in world space
  105541. * @param name The name of the mesh geometry
  105542. * @param scene The Scene
  105543. * @param keepSubMeshes Specifies if the submeshes should be kept
  105544. * @returns A new Mesh
  105545. */
  105546. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105547. /**
  105548. * Build Mesh from CSG taking material and transforms into account
  105549. * @param name The name of the Mesh
  105550. * @param material The material of the Mesh
  105551. * @param scene The Scene
  105552. * @param keepSubMeshes Specifies if submeshes should be kept
  105553. * @returns The new Mesh
  105554. */
  105555. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105556. }
  105557. }
  105558. declare module BABYLON {
  105559. /**
  105560. * Class used to create a trail following a mesh
  105561. */
  105562. export class TrailMesh extends Mesh {
  105563. private _generator;
  105564. private _autoStart;
  105565. private _running;
  105566. private _diameter;
  105567. private _length;
  105568. private _sectionPolygonPointsCount;
  105569. private _sectionVectors;
  105570. private _sectionNormalVectors;
  105571. private _beforeRenderObserver;
  105572. /**
  105573. * @constructor
  105574. * @param name The value used by scene.getMeshByName() to do a lookup.
  105575. * @param generator The mesh to generate a trail.
  105576. * @param scene The scene to add this mesh to.
  105577. * @param diameter Diameter of trailing mesh. Default is 1.
  105578. * @param length Length of trailing mesh. Default is 60.
  105579. * @param autoStart Automatically start trailing mesh. Default true.
  105580. */
  105581. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105582. /**
  105583. * "TrailMesh"
  105584. * @returns "TrailMesh"
  105585. */
  105586. getClassName(): string;
  105587. private _createMesh;
  105588. /**
  105589. * Start trailing mesh.
  105590. */
  105591. start(): void;
  105592. /**
  105593. * Stop trailing mesh.
  105594. */
  105595. stop(): void;
  105596. /**
  105597. * Update trailing mesh geometry.
  105598. */
  105599. update(): void;
  105600. /**
  105601. * Returns a new TrailMesh object.
  105602. * @param name is a string, the name given to the new mesh
  105603. * @param newGenerator use new generator object for cloned trail mesh
  105604. * @returns a new mesh
  105605. */
  105606. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105607. /**
  105608. * Serializes this trail mesh
  105609. * @param serializationObject object to write serialization to
  105610. */
  105611. serialize(serializationObject: any): void;
  105612. /**
  105613. * Parses a serialized trail mesh
  105614. * @param parsedMesh the serialized mesh
  105615. * @param scene the scene to create the trail mesh in
  105616. * @returns the created trail mesh
  105617. */
  105618. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105619. }
  105620. }
  105621. declare module BABYLON {
  105622. /**
  105623. * Class containing static functions to help procedurally build meshes
  105624. */
  105625. export class RibbonBuilder {
  105626. /**
  105627. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105628. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105629. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105630. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105631. * * 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
  105632. * * 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
  105633. * * 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
  105634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105636. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105637. * * 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
  105638. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105639. * * 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
  105640. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105642. * @param name defines the name of the mesh
  105643. * @param options defines the options used to create the mesh
  105644. * @param scene defines the hosting scene
  105645. * @returns the ribbon mesh
  105646. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105648. */
  105649. static CreateRibbon(name: string, options: {
  105650. pathArray: Vector3[][];
  105651. closeArray?: boolean;
  105652. closePath?: boolean;
  105653. offset?: number;
  105654. updatable?: boolean;
  105655. sideOrientation?: number;
  105656. frontUVs?: Vector4;
  105657. backUVs?: Vector4;
  105658. instance?: Mesh;
  105659. invertUV?: boolean;
  105660. uvs?: Vector2[];
  105661. colors?: Color4[];
  105662. }, scene?: Nullable<Scene>): Mesh;
  105663. }
  105664. }
  105665. declare module BABYLON {
  105666. /**
  105667. * Class containing static functions to help procedurally build meshes
  105668. */
  105669. export class TorusKnotBuilder {
  105670. /**
  105671. * Creates a torus knot mesh
  105672. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105673. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105674. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105675. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105679. * @param name defines the name of the mesh
  105680. * @param options defines the options used to create the mesh
  105681. * @param scene defines the hosting scene
  105682. * @returns the torus knot mesh
  105683. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105684. */
  105685. static CreateTorusKnot(name: string, options: {
  105686. radius?: number;
  105687. tube?: number;
  105688. radialSegments?: number;
  105689. tubularSegments?: number;
  105690. p?: number;
  105691. q?: number;
  105692. updatable?: boolean;
  105693. sideOrientation?: number;
  105694. frontUVs?: Vector4;
  105695. backUVs?: Vector4;
  105696. }, scene: any): Mesh;
  105697. }
  105698. }
  105699. declare module BABYLON {
  105700. /**
  105701. * Polygon
  105702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105703. */
  105704. export class Polygon {
  105705. /**
  105706. * Creates a rectangle
  105707. * @param xmin bottom X coord
  105708. * @param ymin bottom Y coord
  105709. * @param xmax top X coord
  105710. * @param ymax top Y coord
  105711. * @returns points that make the resulting rectation
  105712. */
  105713. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105714. /**
  105715. * Creates a circle
  105716. * @param radius radius of circle
  105717. * @param cx scale in x
  105718. * @param cy scale in y
  105719. * @param numberOfSides number of sides that make up the circle
  105720. * @returns points that make the resulting circle
  105721. */
  105722. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105723. /**
  105724. * Creates a polygon from input string
  105725. * @param input Input polygon data
  105726. * @returns the parsed points
  105727. */
  105728. static Parse(input: string): Vector2[];
  105729. /**
  105730. * Starts building a polygon from x and y coordinates
  105731. * @param x x coordinate
  105732. * @param y y coordinate
  105733. * @returns the started path2
  105734. */
  105735. static StartingAt(x: number, y: number): Path2;
  105736. }
  105737. /**
  105738. * Builds a polygon
  105739. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105740. */
  105741. export class PolygonMeshBuilder {
  105742. private _points;
  105743. private _outlinepoints;
  105744. private _holes;
  105745. private _name;
  105746. private _scene;
  105747. private _epoints;
  105748. private _eholes;
  105749. private _addToepoint;
  105750. /**
  105751. * Babylon reference to the earcut plugin.
  105752. */
  105753. bjsEarcut: any;
  105754. /**
  105755. * Creates a PolygonMeshBuilder
  105756. * @param name name of the builder
  105757. * @param contours Path of the polygon
  105758. * @param scene scene to add to
  105759. * @param earcutInjection can be used to inject your own earcut reference
  105760. */
  105761. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105762. /**
  105763. * Adds a whole within the polygon
  105764. * @param hole Array of points defining the hole
  105765. * @returns this
  105766. */
  105767. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105768. /**
  105769. * Creates the polygon
  105770. * @param updatable If the mesh should be updatable
  105771. * @param depth The depth of the mesh created
  105772. * @returns the created mesh
  105773. */
  105774. build(updatable?: boolean, depth?: number): Mesh;
  105775. /**
  105776. * Adds a side to the polygon
  105777. * @param positions points that make the polygon
  105778. * @param normals normals of the polygon
  105779. * @param uvs uvs of the polygon
  105780. * @param indices indices of the polygon
  105781. * @param bounds bounds of the polygon
  105782. * @param points points of the polygon
  105783. * @param depth depth of the polygon
  105784. * @param flip flip of the polygon
  105785. */
  105786. private addSide;
  105787. }
  105788. }
  105789. declare module BABYLON {
  105790. /**
  105791. * Class containing static functions to help procedurally build meshes
  105792. */
  105793. export class PolygonBuilder {
  105794. /**
  105795. * Creates a polygon mesh
  105796. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105797. * * 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
  105798. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105801. * * Remember you can only change the shape positions, not their number when updating a polygon
  105802. * @param name defines the name of the mesh
  105803. * @param options defines the options used to create the mesh
  105804. * @param scene defines the hosting scene
  105805. * @param earcutInjection can be used to inject your own earcut reference
  105806. * @returns the polygon mesh
  105807. */
  105808. static CreatePolygon(name: string, options: {
  105809. shape: Vector3[];
  105810. holes?: Vector3[][];
  105811. depth?: number;
  105812. faceUV?: Vector4[];
  105813. faceColors?: Color4[];
  105814. updatable?: boolean;
  105815. sideOrientation?: number;
  105816. frontUVs?: Vector4;
  105817. backUVs?: Vector4;
  105818. }, scene: Scene, earcutInjection?: any): Mesh;
  105819. /**
  105820. * Creates an extruded polygon mesh, with depth in the Y direction.
  105821. * * 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)
  105822. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105823. * @param name defines the name of the mesh
  105824. * @param options defines the options used to create the mesh
  105825. * @param scene defines the hosting scene
  105826. * @param earcutInjection can be used to inject your own earcut reference
  105827. * @returns the polygon mesh
  105828. */
  105829. static ExtrudePolygon(name: string, options: {
  105830. shape: Vector3[];
  105831. holes?: Vector3[][];
  105832. depth?: number;
  105833. faceUV?: Vector4[];
  105834. faceColors?: Color4[];
  105835. updatable?: boolean;
  105836. sideOrientation?: number;
  105837. frontUVs?: Vector4;
  105838. backUVs?: Vector4;
  105839. }, scene: Scene, earcutInjection?: any): Mesh;
  105840. }
  105841. }
  105842. declare module BABYLON {
  105843. /**
  105844. * Class containing static functions to help procedurally build meshes
  105845. */
  105846. export class ShapeBuilder {
  105847. /**
  105848. * 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.
  105849. * * 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.
  105850. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105851. * * 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.
  105852. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105853. * * 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
  105854. * * 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
  105855. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105858. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105860. * @param name defines the name of the mesh
  105861. * @param options defines the options used to create the mesh
  105862. * @param scene defines the hosting scene
  105863. * @returns the extruded shape mesh
  105864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105866. */
  105867. static ExtrudeShape(name: string, options: {
  105868. shape: Vector3[];
  105869. path: Vector3[];
  105870. scale?: number;
  105871. rotation?: number;
  105872. cap?: number;
  105873. updatable?: boolean;
  105874. sideOrientation?: number;
  105875. frontUVs?: Vector4;
  105876. backUVs?: Vector4;
  105877. instance?: Mesh;
  105878. invertUV?: boolean;
  105879. }, scene?: Nullable<Scene>): Mesh;
  105880. /**
  105881. * Creates an custom extruded shape mesh.
  105882. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105883. * * 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.
  105884. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105885. * * 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
  105886. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105887. * * 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
  105888. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105889. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105890. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105891. * * 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
  105892. * * 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
  105893. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105896. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105898. * @param name defines the name of the mesh
  105899. * @param options defines the options used to create the mesh
  105900. * @param scene defines the hosting scene
  105901. * @returns the custom extruded shape mesh
  105902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105905. */
  105906. static ExtrudeShapeCustom(name: string, options: {
  105907. shape: Vector3[];
  105908. path: Vector3[];
  105909. scaleFunction?: any;
  105910. rotationFunction?: any;
  105911. ribbonCloseArray?: boolean;
  105912. ribbonClosePath?: boolean;
  105913. cap?: number;
  105914. updatable?: boolean;
  105915. sideOrientation?: number;
  105916. frontUVs?: Vector4;
  105917. backUVs?: Vector4;
  105918. instance?: Mesh;
  105919. invertUV?: boolean;
  105920. }, scene: Scene): Mesh;
  105921. private static _ExtrudeShapeGeneric;
  105922. }
  105923. }
  105924. declare module BABYLON {
  105925. /**
  105926. * Class containing static functions to help procedurally build meshes
  105927. */
  105928. export class LatheBuilder {
  105929. /**
  105930. * Creates lathe mesh.
  105931. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105932. * * 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
  105933. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105934. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105935. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105936. * * 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
  105937. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105938. * * 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
  105939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105941. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105943. * @param name defines the name of the mesh
  105944. * @param options defines the options used to create the mesh
  105945. * @param scene defines the hosting scene
  105946. * @returns the lathe mesh
  105947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105948. */
  105949. static CreateLathe(name: string, options: {
  105950. shape: Vector3[];
  105951. radius?: number;
  105952. tessellation?: number;
  105953. clip?: number;
  105954. arc?: number;
  105955. closed?: boolean;
  105956. updatable?: boolean;
  105957. sideOrientation?: number;
  105958. frontUVs?: Vector4;
  105959. backUVs?: Vector4;
  105960. cap?: number;
  105961. invertUV?: boolean;
  105962. }, scene: Scene): Mesh;
  105963. }
  105964. }
  105965. declare module BABYLON {
  105966. /**
  105967. * Class containing static functions to help procedurally build meshes
  105968. */
  105969. export class TubeBuilder {
  105970. /**
  105971. * Creates a tube mesh.
  105972. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105973. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105974. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105975. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105976. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105977. * * 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)
  105978. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105979. * * 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
  105980. * * 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
  105981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105985. * @param name defines the name of the mesh
  105986. * @param options defines the options used to create the mesh
  105987. * @param scene defines the hosting scene
  105988. * @returns the tube mesh
  105989. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105990. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105991. */
  105992. static CreateTube(name: string, options: {
  105993. path: Vector3[];
  105994. radius?: number;
  105995. tessellation?: number;
  105996. radiusFunction?: {
  105997. (i: number, distance: number): number;
  105998. };
  105999. cap?: number;
  106000. arc?: number;
  106001. updatable?: boolean;
  106002. sideOrientation?: number;
  106003. frontUVs?: Vector4;
  106004. backUVs?: Vector4;
  106005. instance?: Mesh;
  106006. invertUV?: boolean;
  106007. }, scene: Scene): Mesh;
  106008. }
  106009. }
  106010. declare module BABYLON {
  106011. /**
  106012. * Class containing static functions to help procedurally build meshes
  106013. */
  106014. export class IcoSphereBuilder {
  106015. /**
  106016. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106017. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106018. * * 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`)
  106019. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106020. * * 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
  106021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106024. * @param name defines the name of the mesh
  106025. * @param options defines the options used to create the mesh
  106026. * @param scene defines the hosting scene
  106027. * @returns the icosahedron mesh
  106028. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106029. */
  106030. static CreateIcoSphere(name: string, options: {
  106031. radius?: number;
  106032. radiusX?: number;
  106033. radiusY?: number;
  106034. radiusZ?: number;
  106035. flat?: boolean;
  106036. subdivisions?: number;
  106037. sideOrientation?: number;
  106038. frontUVs?: Vector4;
  106039. backUVs?: Vector4;
  106040. updatable?: boolean;
  106041. }, scene: Scene): Mesh;
  106042. }
  106043. }
  106044. declare module BABYLON {
  106045. /**
  106046. * Class containing static functions to help procedurally build meshes
  106047. */
  106048. export class DecalBuilder {
  106049. /**
  106050. * Creates a decal mesh.
  106051. * 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
  106052. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106053. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106054. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106055. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106056. * @param name defines the name of the mesh
  106057. * @param sourceMesh defines the mesh where the decal must be applied
  106058. * @param options defines the options used to create the mesh
  106059. * @param scene defines the hosting scene
  106060. * @returns the decal mesh
  106061. * @see https://doc.babylonjs.com/how_to/decals
  106062. */
  106063. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106064. position?: Vector3;
  106065. normal?: Vector3;
  106066. size?: Vector3;
  106067. angle?: number;
  106068. }): Mesh;
  106069. }
  106070. }
  106071. declare module BABYLON {
  106072. /**
  106073. * Class containing static functions to help procedurally build meshes
  106074. */
  106075. export class MeshBuilder {
  106076. /**
  106077. * Creates a box mesh
  106078. * * The parameter `size` sets the size (float) of each box side (default 1)
  106079. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106080. * * 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)
  106081. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106085. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106086. * @param name defines the name of the mesh
  106087. * @param options defines the options used to create the mesh
  106088. * @param scene defines the hosting scene
  106089. * @returns the box mesh
  106090. */
  106091. static CreateBox(name: string, options: {
  106092. size?: number;
  106093. width?: number;
  106094. height?: number;
  106095. depth?: number;
  106096. faceUV?: Vector4[];
  106097. faceColors?: Color4[];
  106098. sideOrientation?: number;
  106099. frontUVs?: Vector4;
  106100. backUVs?: Vector4;
  106101. updatable?: boolean;
  106102. }, scene?: Nullable<Scene>): Mesh;
  106103. /**
  106104. * Creates a sphere mesh
  106105. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106106. * * 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`)
  106107. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106108. * * 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
  106109. * * 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)
  106110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106113. * @param name defines the name of the mesh
  106114. * @param options defines the options used to create the mesh
  106115. * @param scene defines the hosting scene
  106116. * @returns the sphere mesh
  106117. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106118. */
  106119. static CreateSphere(name: string, options: {
  106120. segments?: number;
  106121. diameter?: number;
  106122. diameterX?: number;
  106123. diameterY?: number;
  106124. diameterZ?: number;
  106125. arc?: number;
  106126. slice?: number;
  106127. sideOrientation?: number;
  106128. frontUVs?: Vector4;
  106129. backUVs?: Vector4;
  106130. updatable?: boolean;
  106131. }, scene: any): Mesh;
  106132. /**
  106133. * Creates a plane polygonal mesh. By default, this is a disc
  106134. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106135. * * 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
  106136. * * 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
  106137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106140. * @param name defines the name of the mesh
  106141. * @param options defines the options used to create the mesh
  106142. * @param scene defines the hosting scene
  106143. * @returns the plane polygonal mesh
  106144. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106145. */
  106146. static CreateDisc(name: string, options: {
  106147. radius?: number;
  106148. tessellation?: number;
  106149. arc?: number;
  106150. updatable?: boolean;
  106151. sideOrientation?: number;
  106152. frontUVs?: Vector4;
  106153. backUVs?: Vector4;
  106154. }, scene?: Nullable<Scene>): Mesh;
  106155. /**
  106156. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106157. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106158. * * 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`)
  106159. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106160. * * 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
  106161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106164. * @param name defines the name of the mesh
  106165. * @param options defines the options used to create the mesh
  106166. * @param scene defines the hosting scene
  106167. * @returns the icosahedron mesh
  106168. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106169. */
  106170. static CreateIcoSphere(name: string, options: {
  106171. radius?: number;
  106172. radiusX?: number;
  106173. radiusY?: number;
  106174. radiusZ?: number;
  106175. flat?: boolean;
  106176. subdivisions?: number;
  106177. sideOrientation?: number;
  106178. frontUVs?: Vector4;
  106179. backUVs?: Vector4;
  106180. updatable?: boolean;
  106181. }, scene: Scene): Mesh;
  106182. /**
  106183. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106184. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106185. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106186. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106187. * * 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
  106188. * * 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
  106189. * * 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
  106190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106193. * * 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
  106194. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106195. * * 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
  106196. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106198. * @param name defines the name of the mesh
  106199. * @param options defines the options used to create the mesh
  106200. * @param scene defines the hosting scene
  106201. * @returns the ribbon mesh
  106202. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106204. */
  106205. static CreateRibbon(name: string, options: {
  106206. pathArray: Vector3[][];
  106207. closeArray?: boolean;
  106208. closePath?: boolean;
  106209. offset?: number;
  106210. updatable?: boolean;
  106211. sideOrientation?: number;
  106212. frontUVs?: Vector4;
  106213. backUVs?: Vector4;
  106214. instance?: Mesh;
  106215. invertUV?: boolean;
  106216. uvs?: Vector2[];
  106217. colors?: Color4[];
  106218. }, scene?: Nullable<Scene>): Mesh;
  106219. /**
  106220. * Creates a cylinder or a cone mesh
  106221. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106222. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106223. * * 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.
  106224. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106225. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106226. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106227. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106228. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106229. * * 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).
  106230. * * 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
  106231. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106232. * * 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
  106233. * * 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.
  106234. * * If `enclose` is false, a ring surface is one element.
  106235. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106236. * * 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
  106237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106240. * @param name defines the name of the mesh
  106241. * @param options defines the options used to create the mesh
  106242. * @param scene defines the hosting scene
  106243. * @returns the cylinder mesh
  106244. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106245. */
  106246. static CreateCylinder(name: string, options: {
  106247. height?: number;
  106248. diameterTop?: number;
  106249. diameterBottom?: number;
  106250. diameter?: number;
  106251. tessellation?: number;
  106252. subdivisions?: number;
  106253. arc?: number;
  106254. faceColors?: Color4[];
  106255. faceUV?: Vector4[];
  106256. updatable?: boolean;
  106257. hasRings?: boolean;
  106258. enclose?: boolean;
  106259. sideOrientation?: number;
  106260. frontUVs?: Vector4;
  106261. backUVs?: Vector4;
  106262. }, scene: any): Mesh;
  106263. /**
  106264. * Creates a torus mesh
  106265. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106266. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106267. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106271. * @param name defines the name of the mesh
  106272. * @param options defines the options used to create the mesh
  106273. * @param scene defines the hosting scene
  106274. * @returns the torus mesh
  106275. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106276. */
  106277. static CreateTorus(name: string, options: {
  106278. diameter?: number;
  106279. thickness?: number;
  106280. tessellation?: number;
  106281. updatable?: boolean;
  106282. sideOrientation?: number;
  106283. frontUVs?: Vector4;
  106284. backUVs?: Vector4;
  106285. }, scene: any): Mesh;
  106286. /**
  106287. * Creates a torus knot mesh
  106288. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106289. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106290. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106291. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106295. * @param name defines the name of the mesh
  106296. * @param options defines the options used to create the mesh
  106297. * @param scene defines the hosting scene
  106298. * @returns the torus knot mesh
  106299. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106300. */
  106301. static CreateTorusKnot(name: string, options: {
  106302. radius?: number;
  106303. tube?: number;
  106304. radialSegments?: number;
  106305. tubularSegments?: number;
  106306. p?: number;
  106307. q?: number;
  106308. updatable?: boolean;
  106309. sideOrientation?: number;
  106310. frontUVs?: Vector4;
  106311. backUVs?: Vector4;
  106312. }, scene: any): Mesh;
  106313. /**
  106314. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106315. * * 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
  106316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106317. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106318. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106319. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106320. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106321. * * 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
  106322. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106325. * @param name defines the name of the new line system
  106326. * @param options defines the options used to create the line system
  106327. * @param scene defines the hosting scene
  106328. * @returns a new line system mesh
  106329. */
  106330. static CreateLineSystem(name: string, options: {
  106331. lines: Vector3[][];
  106332. updatable?: boolean;
  106333. instance?: Nullable<LinesMesh>;
  106334. colors?: Nullable<Color4[][]>;
  106335. useVertexAlpha?: boolean;
  106336. }, scene: Nullable<Scene>): LinesMesh;
  106337. /**
  106338. * Creates a line mesh
  106339. * 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
  106340. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106341. * * The parameter `points` is an array successive Vector3
  106342. * * 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
  106343. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106344. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106345. * * When updating an instance, remember that only point positions can change, not the number of points
  106346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106348. * @param name defines the name of the new line system
  106349. * @param options defines the options used to create the line system
  106350. * @param scene defines the hosting scene
  106351. * @returns a new line mesh
  106352. */
  106353. static CreateLines(name: string, options: {
  106354. points: Vector3[];
  106355. updatable?: boolean;
  106356. instance?: Nullable<LinesMesh>;
  106357. colors?: Color4[];
  106358. useVertexAlpha?: boolean;
  106359. }, scene?: Nullable<Scene>): LinesMesh;
  106360. /**
  106361. * Creates a dashed line mesh
  106362. * * 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
  106363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106364. * * The parameter `points` is an array successive Vector3
  106365. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106366. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106367. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106368. * * 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
  106369. * * When updating an instance, remember that only point positions can change, not the number of points
  106370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106371. * @param name defines the name of the mesh
  106372. * @param options defines the options used to create the mesh
  106373. * @param scene defines the hosting scene
  106374. * @returns the dashed line mesh
  106375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106376. */
  106377. static CreateDashedLines(name: string, options: {
  106378. points: Vector3[];
  106379. dashSize?: number;
  106380. gapSize?: number;
  106381. dashNb?: number;
  106382. updatable?: boolean;
  106383. instance?: LinesMesh;
  106384. }, scene?: Nullable<Scene>): LinesMesh;
  106385. /**
  106386. * 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.
  106387. * * 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.
  106388. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106389. * * 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.
  106390. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106391. * * 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
  106392. * * 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
  106393. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106398. * @param name defines the name of the mesh
  106399. * @param options defines the options used to create the mesh
  106400. * @param scene defines the hosting scene
  106401. * @returns the extruded shape mesh
  106402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106404. */
  106405. static ExtrudeShape(name: string, options: {
  106406. shape: Vector3[];
  106407. path: Vector3[];
  106408. scale?: number;
  106409. rotation?: number;
  106410. cap?: number;
  106411. updatable?: boolean;
  106412. sideOrientation?: number;
  106413. frontUVs?: Vector4;
  106414. backUVs?: Vector4;
  106415. instance?: Mesh;
  106416. invertUV?: boolean;
  106417. }, scene?: Nullable<Scene>): Mesh;
  106418. /**
  106419. * Creates an custom extruded shape mesh.
  106420. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106421. * * 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.
  106422. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106423. * * 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
  106424. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106425. * * 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
  106426. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106427. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106428. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106429. * * 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
  106430. * * 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
  106431. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106434. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106436. * @param name defines the name of the mesh
  106437. * @param options defines the options used to create the mesh
  106438. * @param scene defines the hosting scene
  106439. * @returns the custom extruded shape mesh
  106440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106441. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106443. */
  106444. static ExtrudeShapeCustom(name: string, options: {
  106445. shape: Vector3[];
  106446. path: Vector3[];
  106447. scaleFunction?: any;
  106448. rotationFunction?: any;
  106449. ribbonCloseArray?: boolean;
  106450. ribbonClosePath?: boolean;
  106451. cap?: number;
  106452. updatable?: boolean;
  106453. sideOrientation?: number;
  106454. frontUVs?: Vector4;
  106455. backUVs?: Vector4;
  106456. instance?: Mesh;
  106457. invertUV?: boolean;
  106458. }, scene: Scene): Mesh;
  106459. /**
  106460. * Creates lathe mesh.
  106461. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106462. * * 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
  106463. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106464. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106465. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106466. * * 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
  106467. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106468. * * 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
  106469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106471. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106473. * @param name defines the name of the mesh
  106474. * @param options defines the options used to create the mesh
  106475. * @param scene defines the hosting scene
  106476. * @returns the lathe mesh
  106477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106478. */
  106479. static CreateLathe(name: string, options: {
  106480. shape: Vector3[];
  106481. radius?: number;
  106482. tessellation?: number;
  106483. clip?: number;
  106484. arc?: number;
  106485. closed?: boolean;
  106486. updatable?: boolean;
  106487. sideOrientation?: number;
  106488. frontUVs?: Vector4;
  106489. backUVs?: Vector4;
  106490. cap?: number;
  106491. invertUV?: boolean;
  106492. }, scene: Scene): Mesh;
  106493. /**
  106494. * Creates a plane mesh
  106495. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106496. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106497. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106501. * @param name defines the name of the mesh
  106502. * @param options defines the options used to create the mesh
  106503. * @param scene defines the hosting scene
  106504. * @returns the plane mesh
  106505. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106506. */
  106507. static CreatePlane(name: string, options: {
  106508. size?: number;
  106509. width?: number;
  106510. height?: number;
  106511. sideOrientation?: number;
  106512. frontUVs?: Vector4;
  106513. backUVs?: Vector4;
  106514. updatable?: boolean;
  106515. sourcePlane?: Plane;
  106516. }, scene: Scene): Mesh;
  106517. /**
  106518. * Creates a ground mesh
  106519. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106520. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106522. * @param name defines the name of the mesh
  106523. * @param options defines the options used to create the mesh
  106524. * @param scene defines the hosting scene
  106525. * @returns the ground mesh
  106526. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106527. */
  106528. static CreateGround(name: string, options: {
  106529. width?: number;
  106530. height?: number;
  106531. subdivisions?: number;
  106532. subdivisionsX?: number;
  106533. subdivisionsY?: number;
  106534. updatable?: boolean;
  106535. }, scene: any): Mesh;
  106536. /**
  106537. * Creates a tiled ground mesh
  106538. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106539. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106540. * * 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
  106541. * * 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
  106542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106543. * @param name defines the name of the mesh
  106544. * @param options defines the options used to create the mesh
  106545. * @param scene defines the hosting scene
  106546. * @returns the tiled ground mesh
  106547. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106548. */
  106549. static CreateTiledGround(name: string, options: {
  106550. xmin: number;
  106551. zmin: number;
  106552. xmax: number;
  106553. zmax: number;
  106554. subdivisions?: {
  106555. w: number;
  106556. h: number;
  106557. };
  106558. precision?: {
  106559. w: number;
  106560. h: number;
  106561. };
  106562. updatable?: boolean;
  106563. }, scene: Scene): Mesh;
  106564. /**
  106565. * Creates a ground mesh from a height map
  106566. * * The parameter `url` sets the URL of the height map image resource.
  106567. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106568. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106569. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106570. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106571. * * 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.
  106572. * * 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).
  106573. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106575. * @param name defines the name of the mesh
  106576. * @param url defines the url to the height map
  106577. * @param options defines the options used to create the mesh
  106578. * @param scene defines the hosting scene
  106579. * @returns the ground mesh
  106580. * @see https://doc.babylonjs.com/babylon101/height_map
  106581. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106582. */
  106583. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106584. width?: number;
  106585. height?: number;
  106586. subdivisions?: number;
  106587. minHeight?: number;
  106588. maxHeight?: number;
  106589. colorFilter?: Color3;
  106590. alphaFilter?: number;
  106591. updatable?: boolean;
  106592. onReady?: (mesh: GroundMesh) => void;
  106593. }, scene: Scene): GroundMesh;
  106594. /**
  106595. * Creates a polygon mesh
  106596. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106597. * * 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
  106598. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106601. * * Remember you can only change the shape positions, not their number when updating a polygon
  106602. * @param name defines the name of the mesh
  106603. * @param options defines the options used to create the mesh
  106604. * @param scene defines the hosting scene
  106605. * @param earcutInjection can be used to inject your own earcut reference
  106606. * @returns the polygon mesh
  106607. */
  106608. static CreatePolygon(name: string, options: {
  106609. shape: Vector3[];
  106610. holes?: Vector3[][];
  106611. depth?: number;
  106612. faceUV?: Vector4[];
  106613. faceColors?: Color4[];
  106614. updatable?: boolean;
  106615. sideOrientation?: number;
  106616. frontUVs?: Vector4;
  106617. backUVs?: Vector4;
  106618. }, scene: Scene, earcutInjection?: any): Mesh;
  106619. /**
  106620. * Creates an extruded polygon mesh, with depth in the Y direction.
  106621. * * 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)
  106622. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106623. * @param name defines the name of the mesh
  106624. * @param options defines the options used to create the mesh
  106625. * @param scene defines the hosting scene
  106626. * @param earcutInjection can be used to inject your own earcut reference
  106627. * @returns the polygon mesh
  106628. */
  106629. static ExtrudePolygon(name: string, options: {
  106630. shape: Vector3[];
  106631. holes?: Vector3[][];
  106632. depth?: number;
  106633. faceUV?: Vector4[];
  106634. faceColors?: Color4[];
  106635. updatable?: boolean;
  106636. sideOrientation?: number;
  106637. frontUVs?: Vector4;
  106638. backUVs?: Vector4;
  106639. }, scene: Scene, earcutInjection?: any): Mesh;
  106640. /**
  106641. * Creates a tube mesh.
  106642. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106643. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106644. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106645. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106646. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106647. * * 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)
  106648. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106649. * * 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
  106650. * * 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
  106651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106655. * @param name defines the name of the mesh
  106656. * @param options defines the options used to create the mesh
  106657. * @param scene defines the hosting scene
  106658. * @returns the tube mesh
  106659. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106660. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106661. */
  106662. static CreateTube(name: string, options: {
  106663. path: Vector3[];
  106664. radius?: number;
  106665. tessellation?: number;
  106666. radiusFunction?: {
  106667. (i: number, distance: number): number;
  106668. };
  106669. cap?: number;
  106670. arc?: number;
  106671. updatable?: boolean;
  106672. sideOrientation?: number;
  106673. frontUVs?: Vector4;
  106674. backUVs?: Vector4;
  106675. instance?: Mesh;
  106676. invertUV?: boolean;
  106677. }, scene: Scene): Mesh;
  106678. /**
  106679. * Creates a polyhedron mesh
  106680. * * 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
  106681. * * The parameter `size` (positive float, default 1) sets the polygon size
  106682. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106683. * * 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`
  106684. * * 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
  106685. * * 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)`)
  106686. * * 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
  106687. * * 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
  106688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106691. * @param name defines the name of the mesh
  106692. * @param options defines the options used to create the mesh
  106693. * @param scene defines the hosting scene
  106694. * @returns the polyhedron mesh
  106695. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106696. */
  106697. static CreatePolyhedron(name: string, options: {
  106698. type?: number;
  106699. size?: number;
  106700. sizeX?: number;
  106701. sizeY?: number;
  106702. sizeZ?: number;
  106703. custom?: any;
  106704. faceUV?: Vector4[];
  106705. faceColors?: Color4[];
  106706. flat?: boolean;
  106707. updatable?: boolean;
  106708. sideOrientation?: number;
  106709. frontUVs?: Vector4;
  106710. backUVs?: Vector4;
  106711. }, scene: Scene): Mesh;
  106712. /**
  106713. * Creates a decal mesh.
  106714. * 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
  106715. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106716. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106717. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106718. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106719. * @param name defines the name of the mesh
  106720. * @param sourceMesh defines the mesh where the decal must be applied
  106721. * @param options defines the options used to create the mesh
  106722. * @param scene defines the hosting scene
  106723. * @returns the decal mesh
  106724. * @see https://doc.babylonjs.com/how_to/decals
  106725. */
  106726. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106727. position?: Vector3;
  106728. normal?: Vector3;
  106729. size?: Vector3;
  106730. angle?: number;
  106731. }): Mesh;
  106732. }
  106733. }
  106734. declare module BABYLON {
  106735. /**
  106736. * A simplifier interface for future simplification implementations
  106737. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106738. */
  106739. export interface ISimplifier {
  106740. /**
  106741. * Simplification of a given mesh according to the given settings.
  106742. * Since this requires computation, it is assumed that the function runs async.
  106743. * @param settings The settings of the simplification, including quality and distance
  106744. * @param successCallback A callback that will be called after the mesh was simplified.
  106745. * @param errorCallback in case of an error, this callback will be called. optional.
  106746. */
  106747. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106748. }
  106749. /**
  106750. * Expected simplification settings.
  106751. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106752. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106753. */
  106754. export interface ISimplificationSettings {
  106755. /**
  106756. * Gets or sets the expected quality
  106757. */
  106758. quality: number;
  106759. /**
  106760. * Gets or sets the distance when this optimized version should be used
  106761. */
  106762. distance: number;
  106763. /**
  106764. * Gets an already optimized mesh
  106765. */
  106766. optimizeMesh?: boolean;
  106767. }
  106768. /**
  106769. * Class used to specify simplification options
  106770. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106771. */
  106772. export class SimplificationSettings implements ISimplificationSettings {
  106773. /** expected quality */
  106774. quality: number;
  106775. /** distance when this optimized version should be used */
  106776. distance: number;
  106777. /** already optimized mesh */
  106778. optimizeMesh?: boolean | undefined;
  106779. /**
  106780. * Creates a SimplificationSettings
  106781. * @param quality expected quality
  106782. * @param distance distance when this optimized version should be used
  106783. * @param optimizeMesh already optimized mesh
  106784. */
  106785. constructor(
  106786. /** expected quality */
  106787. quality: number,
  106788. /** distance when this optimized version should be used */
  106789. distance: number,
  106790. /** already optimized mesh */
  106791. optimizeMesh?: boolean | undefined);
  106792. }
  106793. /**
  106794. * Interface used to define a simplification task
  106795. */
  106796. export interface ISimplificationTask {
  106797. /**
  106798. * Array of settings
  106799. */
  106800. settings: Array<ISimplificationSettings>;
  106801. /**
  106802. * Simplification type
  106803. */
  106804. simplificationType: SimplificationType;
  106805. /**
  106806. * Mesh to simplify
  106807. */
  106808. mesh: Mesh;
  106809. /**
  106810. * Callback called on success
  106811. */
  106812. successCallback?: () => void;
  106813. /**
  106814. * Defines if parallel processing can be used
  106815. */
  106816. parallelProcessing: boolean;
  106817. }
  106818. /**
  106819. * Queue used to order the simplification tasks
  106820. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106821. */
  106822. export class SimplificationQueue {
  106823. private _simplificationArray;
  106824. /**
  106825. * Gets a boolean indicating that the process is still running
  106826. */
  106827. running: boolean;
  106828. /**
  106829. * Creates a new queue
  106830. */
  106831. constructor();
  106832. /**
  106833. * Adds a new simplification task
  106834. * @param task defines a task to add
  106835. */
  106836. addTask(task: ISimplificationTask): void;
  106837. /**
  106838. * Execute next task
  106839. */
  106840. executeNext(): void;
  106841. /**
  106842. * Execute a simplification task
  106843. * @param task defines the task to run
  106844. */
  106845. runSimplification(task: ISimplificationTask): void;
  106846. private getSimplifier;
  106847. }
  106848. /**
  106849. * The implemented types of simplification
  106850. * At the moment only Quadratic Error Decimation is implemented
  106851. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106852. */
  106853. export enum SimplificationType {
  106854. /** Quadratic error decimation */
  106855. QUADRATIC = 0
  106856. }
  106857. }
  106858. declare module BABYLON {
  106859. interface Scene {
  106860. /** @hidden (Backing field) */
  106861. _simplificationQueue: SimplificationQueue;
  106862. /**
  106863. * Gets or sets the simplification queue attached to the scene
  106864. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106865. */
  106866. simplificationQueue: SimplificationQueue;
  106867. }
  106868. interface Mesh {
  106869. /**
  106870. * Simplify the mesh according to the given array of settings.
  106871. * Function will return immediately and will simplify async
  106872. * @param settings a collection of simplification settings
  106873. * @param parallelProcessing should all levels calculate parallel or one after the other
  106874. * @param simplificationType the type of simplification to run
  106875. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106876. * @returns the current mesh
  106877. */
  106878. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106879. }
  106880. /**
  106881. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106882. * created in a scene
  106883. */
  106884. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106885. /**
  106886. * The component name helpfull to identify the component in the list of scene components.
  106887. */
  106888. readonly name: string;
  106889. /**
  106890. * The scene the component belongs to.
  106891. */
  106892. scene: Scene;
  106893. /**
  106894. * Creates a new instance of the component for the given scene
  106895. * @param scene Defines the scene to register the component in
  106896. */
  106897. constructor(scene: Scene);
  106898. /**
  106899. * Registers the component in a given scene
  106900. */
  106901. register(): void;
  106902. /**
  106903. * Rebuilds the elements related to this component in case of
  106904. * context lost for instance.
  106905. */
  106906. rebuild(): void;
  106907. /**
  106908. * Disposes the component and the associated ressources
  106909. */
  106910. dispose(): void;
  106911. private _beforeCameraUpdate;
  106912. }
  106913. }
  106914. declare module BABYLON {
  106915. /**
  106916. * Class used to enable access to IndexedDB
  106917. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106918. */
  106919. export class Database implements IOfflineProvider {
  106920. private _callbackManifestChecked;
  106921. private _currentSceneUrl;
  106922. private _db;
  106923. private _enableSceneOffline;
  106924. private _enableTexturesOffline;
  106925. private _manifestVersionFound;
  106926. private _mustUpdateRessources;
  106927. private _hasReachedQuota;
  106928. private _isSupported;
  106929. private _idbFactory;
  106930. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106931. private static IsUASupportingBlobStorage;
  106932. /**
  106933. * Gets a boolean indicating if Database storate is enabled (off by default)
  106934. */
  106935. static IDBStorageEnabled: boolean;
  106936. /**
  106937. * Gets a boolean indicating if scene must be saved in the database
  106938. */
  106939. readonly enableSceneOffline: boolean;
  106940. /**
  106941. * Gets a boolean indicating if textures must be saved in the database
  106942. */
  106943. readonly enableTexturesOffline: boolean;
  106944. /**
  106945. * Creates a new Database
  106946. * @param urlToScene defines the url to load the scene
  106947. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106948. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106949. */
  106950. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106951. private static _ParseURL;
  106952. private static _ReturnFullUrlLocation;
  106953. private _checkManifestFile;
  106954. /**
  106955. * Open the database and make it available
  106956. * @param successCallback defines the callback to call on success
  106957. * @param errorCallback defines the callback to call on error
  106958. */
  106959. open(successCallback: () => void, errorCallback: () => void): void;
  106960. /**
  106961. * Loads an image from the database
  106962. * @param url defines the url to load from
  106963. * @param image defines the target DOM image
  106964. */
  106965. loadImage(url: string, image: HTMLImageElement): void;
  106966. private _loadImageFromDBAsync;
  106967. private _saveImageIntoDBAsync;
  106968. private _checkVersionFromDB;
  106969. private _loadVersionFromDBAsync;
  106970. private _saveVersionIntoDBAsync;
  106971. /**
  106972. * Loads a file from database
  106973. * @param url defines the URL to load from
  106974. * @param sceneLoaded defines a callback to call on success
  106975. * @param progressCallBack defines a callback to call when progress changed
  106976. * @param errorCallback defines a callback to call on error
  106977. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106978. */
  106979. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106980. private _loadFileAsync;
  106981. private _saveFileAsync;
  106982. /**
  106983. * Validates if xhr data is correct
  106984. * @param xhr defines the request to validate
  106985. * @param dataType defines the expected data type
  106986. * @returns true if data is correct
  106987. */
  106988. private static _ValidateXHRData;
  106989. }
  106990. }
  106991. declare module BABYLON {
  106992. /** @hidden */
  106993. export var gpuUpdateParticlesPixelShader: {
  106994. name: string;
  106995. shader: string;
  106996. };
  106997. }
  106998. declare module BABYLON {
  106999. /** @hidden */
  107000. export var gpuUpdateParticlesVertexShader: {
  107001. name: string;
  107002. shader: string;
  107003. };
  107004. }
  107005. declare module BABYLON {
  107006. /** @hidden */
  107007. export var clipPlaneFragmentDeclaration2: {
  107008. name: string;
  107009. shader: string;
  107010. };
  107011. }
  107012. declare module BABYLON {
  107013. /** @hidden */
  107014. export var gpuRenderParticlesPixelShader: {
  107015. name: string;
  107016. shader: string;
  107017. };
  107018. }
  107019. declare module BABYLON {
  107020. /** @hidden */
  107021. export var clipPlaneVertexDeclaration2: {
  107022. name: string;
  107023. shader: string;
  107024. };
  107025. }
  107026. declare module BABYLON {
  107027. /** @hidden */
  107028. export var gpuRenderParticlesVertexShader: {
  107029. name: string;
  107030. shader: string;
  107031. };
  107032. }
  107033. declare module BABYLON {
  107034. /**
  107035. * This represents a GPU particle system in Babylon
  107036. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  107037. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  107038. */
  107039. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  107040. /**
  107041. * The layer mask we are rendering the particles through.
  107042. */
  107043. layerMask: number;
  107044. private _capacity;
  107045. private _activeCount;
  107046. private _currentActiveCount;
  107047. private _accumulatedCount;
  107048. private _renderEffect;
  107049. private _updateEffect;
  107050. private _buffer0;
  107051. private _buffer1;
  107052. private _spriteBuffer;
  107053. private _updateVAO;
  107054. private _renderVAO;
  107055. private _targetIndex;
  107056. private _sourceBuffer;
  107057. private _targetBuffer;
  107058. private _engine;
  107059. private _currentRenderId;
  107060. private _started;
  107061. private _stopped;
  107062. private _timeDelta;
  107063. private _randomTexture;
  107064. private _randomTexture2;
  107065. private _attributesStrideSize;
  107066. private _updateEffectOptions;
  107067. private _randomTextureSize;
  107068. private _actualFrame;
  107069. private readonly _rawTextureWidth;
  107070. /**
  107071. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  107072. */
  107073. static readonly IsSupported: boolean;
  107074. /**
  107075. * An event triggered when the system is disposed.
  107076. */
  107077. onDisposeObservable: Observable<GPUParticleSystem>;
  107078. /**
  107079. * Gets the maximum number of particles active at the same time.
  107080. * @returns The max number of active particles.
  107081. */
  107082. getCapacity(): number;
  107083. /**
  107084. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  107085. * to override the particles.
  107086. */
  107087. forceDepthWrite: boolean;
  107088. /**
  107089. * Gets or set the number of active particles
  107090. */
  107091. activeParticleCount: number;
  107092. private _preWarmDone;
  107093. /**
  107094. * Is this system ready to be used/rendered
  107095. * @return true if the system is ready
  107096. */
  107097. isReady(): boolean;
  107098. /**
  107099. * Gets if the system has been started. (Note: this will still be true after stop is called)
  107100. * @returns True if it has been started, otherwise false.
  107101. */
  107102. isStarted(): boolean;
  107103. /**
  107104. * Starts the particle system and begins to emit
  107105. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  107106. */
  107107. start(delay?: number): void;
  107108. /**
  107109. * Stops the particle system.
  107110. */
  107111. stop(): void;
  107112. /**
  107113. * Remove all active particles
  107114. */
  107115. reset(): void;
  107116. /**
  107117. * Returns the string "GPUParticleSystem"
  107118. * @returns a string containing the class name
  107119. */
  107120. getClassName(): string;
  107121. private _colorGradientsTexture;
  107122. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  107123. /**
  107124. * Adds a new color gradient
  107125. * @param gradient defines the gradient to use (between 0 and 1)
  107126. * @param color1 defines the color to affect to the specified gradient
  107127. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  107128. * @returns the current particle system
  107129. */
  107130. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  107131. /**
  107132. * Remove a specific color gradient
  107133. * @param gradient defines the gradient to remove
  107134. * @returns the current particle system
  107135. */
  107136. removeColorGradient(gradient: number): GPUParticleSystem;
  107137. private _angularSpeedGradientsTexture;
  107138. private _sizeGradientsTexture;
  107139. private _velocityGradientsTexture;
  107140. private _limitVelocityGradientsTexture;
  107141. private _dragGradientsTexture;
  107142. private _addFactorGradient;
  107143. /**
  107144. * Adds a new size gradient
  107145. * @param gradient defines the gradient to use (between 0 and 1)
  107146. * @param factor defines the size factor to affect to the specified gradient
  107147. * @returns the current particle system
  107148. */
  107149. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  107150. /**
  107151. * Remove a specific size gradient
  107152. * @param gradient defines the gradient to remove
  107153. * @returns the current particle system
  107154. */
  107155. removeSizeGradient(gradient: number): GPUParticleSystem;
  107156. /**
  107157. * Adds a new angular speed gradient
  107158. * @param gradient defines the gradient to use (between 0 and 1)
  107159. * @param factor defines the angular speed to affect to the specified gradient
  107160. * @returns the current particle system
  107161. */
  107162. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  107163. /**
  107164. * Remove a specific angular speed gradient
  107165. * @param gradient defines the gradient to remove
  107166. * @returns the current particle system
  107167. */
  107168. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  107169. /**
  107170. * Adds a new velocity gradient
  107171. * @param gradient defines the gradient to use (between 0 and 1)
  107172. * @param factor defines the velocity to affect to the specified gradient
  107173. * @returns the current particle system
  107174. */
  107175. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107176. /**
  107177. * Remove a specific velocity gradient
  107178. * @param gradient defines the gradient to remove
  107179. * @returns the current particle system
  107180. */
  107181. removeVelocityGradient(gradient: number): GPUParticleSystem;
  107182. /**
  107183. * Adds a new limit velocity gradient
  107184. * @param gradient defines the gradient to use (between 0 and 1)
  107185. * @param factor defines the limit velocity value to affect to the specified gradient
  107186. * @returns the current particle system
  107187. */
  107188. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107189. /**
  107190. * Remove a specific limit velocity gradient
  107191. * @param gradient defines the gradient to remove
  107192. * @returns the current particle system
  107193. */
  107194. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  107195. /**
  107196. * Adds a new drag gradient
  107197. * @param gradient defines the gradient to use (between 0 and 1)
  107198. * @param factor defines the drag value to affect to the specified gradient
  107199. * @returns the current particle system
  107200. */
  107201. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  107202. /**
  107203. * Remove a specific drag gradient
  107204. * @param gradient defines the gradient to remove
  107205. * @returns the current particle system
  107206. */
  107207. removeDragGradient(gradient: number): GPUParticleSystem;
  107208. /**
  107209. * Not supported by GPUParticleSystem
  107210. * @param gradient defines the gradient to use (between 0 and 1)
  107211. * @param factor defines the emit rate value to affect to the specified gradient
  107212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107213. * @returns the current particle system
  107214. */
  107215. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107216. /**
  107217. * Not supported by GPUParticleSystem
  107218. * @param gradient defines the gradient to remove
  107219. * @returns the current particle system
  107220. */
  107221. removeEmitRateGradient(gradient: number): IParticleSystem;
  107222. /**
  107223. * Not supported by GPUParticleSystem
  107224. * @param gradient defines the gradient to use (between 0 and 1)
  107225. * @param factor defines the start size value to affect to the specified gradient
  107226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107227. * @returns the current particle system
  107228. */
  107229. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107230. /**
  107231. * Not supported by GPUParticleSystem
  107232. * @param gradient defines the gradient to remove
  107233. * @returns the current particle system
  107234. */
  107235. removeStartSizeGradient(gradient: number): IParticleSystem;
  107236. /**
  107237. * Not supported by GPUParticleSystem
  107238. * @param gradient defines the gradient to use (between 0 and 1)
  107239. * @param min defines the color remap minimal range
  107240. * @param max defines the color remap maximal range
  107241. * @returns the current particle system
  107242. */
  107243. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107244. /**
  107245. * Not supported by GPUParticleSystem
  107246. * @param gradient defines the gradient to remove
  107247. * @returns the current particle system
  107248. */
  107249. removeColorRemapGradient(): IParticleSystem;
  107250. /**
  107251. * Not supported by GPUParticleSystem
  107252. * @param gradient defines the gradient to use (between 0 and 1)
  107253. * @param min defines the alpha remap minimal range
  107254. * @param max defines the alpha remap maximal range
  107255. * @returns the current particle system
  107256. */
  107257. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107258. /**
  107259. * Not supported by GPUParticleSystem
  107260. * @param gradient defines the gradient to remove
  107261. * @returns the current particle system
  107262. */
  107263. removeAlphaRemapGradient(): IParticleSystem;
  107264. /**
  107265. * Not supported by GPUParticleSystem
  107266. * @param gradient defines the gradient to use (between 0 and 1)
  107267. * @param color defines the color to affect to the specified gradient
  107268. * @returns the current particle system
  107269. */
  107270. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107271. /**
  107272. * Not supported by GPUParticleSystem
  107273. * @param gradient defines the gradient to remove
  107274. * @returns the current particle system
  107275. */
  107276. removeRampGradient(): IParticleSystem;
  107277. /**
  107278. * Not supported by GPUParticleSystem
  107279. * @returns the list of ramp gradients
  107280. */
  107281. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107282. /**
  107283. * Not supported by GPUParticleSystem
  107284. * Gets or sets a boolean indicating that ramp gradients must be used
  107285. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107286. */
  107287. useRampGradients: boolean;
  107288. /**
  107289. * Not supported by GPUParticleSystem
  107290. * @param gradient defines the gradient to use (between 0 and 1)
  107291. * @param factor defines the life time factor to affect to the specified gradient
  107292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107293. * @returns the current particle system
  107294. */
  107295. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107296. /**
  107297. * Not supported by GPUParticleSystem
  107298. * @param gradient defines the gradient to remove
  107299. * @returns the current particle system
  107300. */
  107301. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107302. /**
  107303. * Instantiates a GPU particle system.
  107304. * 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.
  107305. * @param name The name of the particle system
  107306. * @param options The options used to create the system
  107307. * @param scene The scene the particle system belongs to
  107308. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107309. */
  107310. constructor(name: string, options: Partial<{
  107311. capacity: number;
  107312. randomTextureSize: number;
  107313. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107314. protected _reset(): void;
  107315. private _createUpdateVAO;
  107316. private _createRenderVAO;
  107317. private _initialize;
  107318. /** @hidden */
  107319. _recreateUpdateEffect(): void;
  107320. /** @hidden */
  107321. _recreateRenderEffect(): void;
  107322. /**
  107323. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107324. * @param preWarm defines if we are in the pre-warmimg phase
  107325. */
  107326. animate(preWarm?: boolean): void;
  107327. private _createFactorGradientTexture;
  107328. private _createSizeGradientTexture;
  107329. private _createAngularSpeedGradientTexture;
  107330. private _createVelocityGradientTexture;
  107331. private _createLimitVelocityGradientTexture;
  107332. private _createDragGradientTexture;
  107333. private _createColorGradientTexture;
  107334. /**
  107335. * Renders the particle system in its current state
  107336. * @param preWarm defines if the system should only update the particles but not render them
  107337. * @returns the current number of particles
  107338. */
  107339. render(preWarm?: boolean): number;
  107340. /**
  107341. * Rebuilds the particle system
  107342. */
  107343. rebuild(): void;
  107344. private _releaseBuffers;
  107345. private _releaseVAOs;
  107346. /**
  107347. * Disposes the particle system and free the associated resources
  107348. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107349. */
  107350. dispose(disposeTexture?: boolean): void;
  107351. /**
  107352. * Clones the particle system.
  107353. * @param name The name of the cloned object
  107354. * @param newEmitter The new emitter to use
  107355. * @returns the cloned particle system
  107356. */
  107357. clone(name: string, newEmitter: any): GPUParticleSystem;
  107358. /**
  107359. * Serializes the particle system to a JSON object.
  107360. * @returns the JSON object
  107361. */
  107362. serialize(): any;
  107363. /**
  107364. * Parses a JSON object to create a GPU particle system.
  107365. * @param parsedParticleSystem The JSON object to parse
  107366. * @param scene The scene to create the particle system in
  107367. * @param rootUrl The root url to use to load external dependencies like texture
  107368. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107369. * @returns the parsed GPU particle system
  107370. */
  107371. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107372. }
  107373. }
  107374. declare module BABYLON {
  107375. /**
  107376. * Represents a set of particle systems working together to create a specific effect
  107377. */
  107378. export class ParticleSystemSet implements IDisposable {
  107379. private _emitterCreationOptions;
  107380. private _emitterNode;
  107381. /**
  107382. * Gets the particle system list
  107383. */
  107384. systems: IParticleSystem[];
  107385. /**
  107386. * Gets the emitter node used with this set
  107387. */
  107388. readonly emitterNode: Nullable<TransformNode>;
  107389. /**
  107390. * Creates a new emitter mesh as a sphere
  107391. * @param options defines the options used to create the sphere
  107392. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107393. * @param scene defines the hosting scene
  107394. */
  107395. setEmitterAsSphere(options: {
  107396. diameter: number;
  107397. segments: number;
  107398. color: Color3;
  107399. }, renderingGroupId: number, scene: Scene): void;
  107400. /**
  107401. * Starts all particle systems of the set
  107402. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107403. */
  107404. start(emitter?: AbstractMesh): void;
  107405. /**
  107406. * Release all associated resources
  107407. */
  107408. dispose(): void;
  107409. /**
  107410. * Serialize the set into a JSON compatible object
  107411. * @returns a JSON compatible representation of the set
  107412. */
  107413. serialize(): any;
  107414. /**
  107415. * Parse a new ParticleSystemSet from a serialized source
  107416. * @param data defines a JSON compatible representation of the set
  107417. * @param scene defines the hosting scene
  107418. * @param gpu defines if we want GPU particles or CPU particles
  107419. * @returns a new ParticleSystemSet
  107420. */
  107421. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107422. }
  107423. }
  107424. declare module BABYLON {
  107425. /**
  107426. * This class is made for on one-liner static method to help creating particle system set.
  107427. */
  107428. export class ParticleHelper {
  107429. /**
  107430. * Gets or sets base Assets URL
  107431. */
  107432. static BaseAssetsUrl: string;
  107433. /**
  107434. * Create a default particle system that you can tweak
  107435. * @param emitter defines the emitter to use
  107436. * @param capacity defines the system capacity (default is 500 particles)
  107437. * @param scene defines the hosting scene
  107438. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107439. * @returns the new Particle system
  107440. */
  107441. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107442. /**
  107443. * This is the main static method (one-liner) of this helper to create different particle systems
  107444. * @param type This string represents the type to the particle system to create
  107445. * @param scene The scene where the particle system should live
  107446. * @param gpu If the system will use gpu
  107447. * @returns the ParticleSystemSet created
  107448. */
  107449. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107450. /**
  107451. * Static function used to export a particle system to a ParticleSystemSet variable.
  107452. * Please note that the emitter shape is not exported
  107453. * @param systems defines the particle systems to export
  107454. * @returns the created particle system set
  107455. */
  107456. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107457. }
  107458. }
  107459. declare module BABYLON {
  107460. interface Engine {
  107461. /**
  107462. * Create an effect to use with particle systems.
  107463. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107464. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107465. * @param uniformsNames defines a list of attribute names
  107466. * @param samplers defines an array of string used to represent textures
  107467. * @param defines defines the string containing the defines to use to compile the shaders
  107468. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107469. * @param onCompiled defines a function to call when the effect creation is successful
  107470. * @param onError defines a function to call when the effect creation has failed
  107471. * @returns the new Effect
  107472. */
  107473. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107474. }
  107475. interface Mesh {
  107476. /**
  107477. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107478. * @returns an array of IParticleSystem
  107479. */
  107480. getEmittedParticleSystems(): IParticleSystem[];
  107481. /**
  107482. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107483. * @returns an array of IParticleSystem
  107484. */
  107485. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107486. }
  107487. /**
  107488. * @hidden
  107489. */
  107490. export var _IDoNeedToBeInTheBuild: number;
  107491. }
  107492. declare module BABYLON {
  107493. interface Scene {
  107494. /** @hidden (Backing field) */
  107495. _physicsEngine: Nullable<IPhysicsEngine>;
  107496. /**
  107497. * Gets the current physics engine
  107498. * @returns a IPhysicsEngine or null if none attached
  107499. */
  107500. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107501. /**
  107502. * Enables physics to the current scene
  107503. * @param gravity defines the scene's gravity for the physics engine
  107504. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107505. * @return a boolean indicating if the physics engine was initialized
  107506. */
  107507. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107508. /**
  107509. * Disables and disposes the physics engine associated with the scene
  107510. */
  107511. disablePhysicsEngine(): void;
  107512. /**
  107513. * Gets a boolean indicating if there is an active physics engine
  107514. * @returns a boolean indicating if there is an active physics engine
  107515. */
  107516. isPhysicsEnabled(): boolean;
  107517. /**
  107518. * Deletes a physics compound impostor
  107519. * @param compound defines the compound to delete
  107520. */
  107521. deleteCompoundImpostor(compound: any): void;
  107522. /**
  107523. * An event triggered when physic simulation is about to be run
  107524. */
  107525. onBeforePhysicsObservable: Observable<Scene>;
  107526. /**
  107527. * An event triggered when physic simulation has been done
  107528. */
  107529. onAfterPhysicsObservable: Observable<Scene>;
  107530. }
  107531. interface AbstractMesh {
  107532. /** @hidden */
  107533. _physicsImpostor: Nullable<PhysicsImpostor>;
  107534. /**
  107535. * Gets or sets impostor used for physic simulation
  107536. * @see http://doc.babylonjs.com/features/physics_engine
  107537. */
  107538. physicsImpostor: Nullable<PhysicsImpostor>;
  107539. /**
  107540. * Gets the current physics impostor
  107541. * @see http://doc.babylonjs.com/features/physics_engine
  107542. * @returns a physics impostor or null
  107543. */
  107544. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107545. /** Apply a physic impulse to the mesh
  107546. * @param force defines the force to apply
  107547. * @param contactPoint defines where to apply the force
  107548. * @returns the current mesh
  107549. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107550. */
  107551. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107552. /**
  107553. * Creates a physic joint between two meshes
  107554. * @param otherMesh defines the other mesh to use
  107555. * @param pivot1 defines the pivot to use on this mesh
  107556. * @param pivot2 defines the pivot to use on the other mesh
  107557. * @param options defines additional options (can be plugin dependent)
  107558. * @returns the current mesh
  107559. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107560. */
  107561. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107562. /** @hidden */
  107563. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107564. }
  107565. /**
  107566. * Defines the physics engine scene component responsible to manage a physics engine
  107567. */
  107568. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107569. /**
  107570. * The component name helpful to identify the component in the list of scene components.
  107571. */
  107572. readonly name: string;
  107573. /**
  107574. * The scene the component belongs to.
  107575. */
  107576. scene: Scene;
  107577. /**
  107578. * Creates a new instance of the component for the given scene
  107579. * @param scene Defines the scene to register the component in
  107580. */
  107581. constructor(scene: Scene);
  107582. /**
  107583. * Registers the component in a given scene
  107584. */
  107585. register(): void;
  107586. /**
  107587. * Rebuilds the elements related to this component in case of
  107588. * context lost for instance.
  107589. */
  107590. rebuild(): void;
  107591. /**
  107592. * Disposes the component and the associated ressources
  107593. */
  107594. dispose(): void;
  107595. }
  107596. }
  107597. declare module BABYLON {
  107598. /**
  107599. * A helper for physics simulations
  107600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107601. */
  107602. export class PhysicsHelper {
  107603. private _scene;
  107604. private _physicsEngine;
  107605. /**
  107606. * Initializes the Physics helper
  107607. * @param scene Babylon.js scene
  107608. */
  107609. constructor(scene: Scene);
  107610. /**
  107611. * Applies a radial explosion impulse
  107612. * @param origin the origin of the explosion
  107613. * @param radius the explosion radius
  107614. * @param strength the explosion strength
  107615. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107616. * @returns A physics radial explosion event, or null
  107617. */
  107618. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107619. /**
  107620. * Applies a radial explosion force
  107621. * @param origin the origin of the explosion
  107622. * @param radius the explosion radius
  107623. * @param strength the explosion strength
  107624. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107625. * @returns A physics radial explosion event, or null
  107626. */
  107627. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107628. /**
  107629. * Creates a gravitational field
  107630. * @param origin the origin of the explosion
  107631. * @param radius the explosion radius
  107632. * @param strength the explosion strength
  107633. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107634. * @returns A physics gravitational field event, or null
  107635. */
  107636. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107637. /**
  107638. * Creates a physics updraft event
  107639. * @param origin the origin of the updraft
  107640. * @param radius the radius of the updraft
  107641. * @param strength the strength of the updraft
  107642. * @param height the height of the updraft
  107643. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107644. * @returns A physics updraft event, or null
  107645. */
  107646. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107647. /**
  107648. * Creates a physics vortex event
  107649. * @param origin the of the vortex
  107650. * @param radius the radius of the vortex
  107651. * @param strength the strength of the vortex
  107652. * @param height the height of the vortex
  107653. * @returns a Physics vortex event, or null
  107654. * A physics vortex event or null
  107655. */
  107656. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107657. }
  107658. /**
  107659. * Represents a physics radial explosion event
  107660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107661. */
  107662. export class PhysicsRadialExplosionEvent {
  107663. private _scene;
  107664. private _sphere;
  107665. private _sphereOptions;
  107666. private _rays;
  107667. private _dataFetched;
  107668. /**
  107669. * Initializes a radial explosioin event
  107670. * @param scene BabylonJS scene
  107671. */
  107672. constructor(scene: Scene);
  107673. /**
  107674. * Returns the data related to the radial explosion event (sphere & rays).
  107675. * @returns The radial explosion event data
  107676. */
  107677. getData(): PhysicsRadialExplosionEventData;
  107678. /**
  107679. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107680. * @param impostor A physics imposter
  107681. * @param origin the origin of the explosion
  107682. * @param radius the explosion radius
  107683. * @param strength the explosion strength
  107684. * @param falloff possible options: Constant & Linear
  107685. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107686. */
  107687. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107688. /**
  107689. * Disposes the sphere.
  107690. * @param force Specifies if the sphere should be disposed by force
  107691. */
  107692. dispose(force?: boolean): void;
  107693. /*** Helpers ***/
  107694. private _prepareSphere;
  107695. private _intersectsWithSphere;
  107696. }
  107697. /**
  107698. * Represents a gravitational field event
  107699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107700. */
  107701. export class PhysicsGravitationalFieldEvent {
  107702. private _physicsHelper;
  107703. private _scene;
  107704. private _origin;
  107705. private _radius;
  107706. private _strength;
  107707. private _falloff;
  107708. private _tickCallback;
  107709. private _sphere;
  107710. private _dataFetched;
  107711. /**
  107712. * Initializes the physics gravitational field event
  107713. * @param physicsHelper A physics helper
  107714. * @param scene BabylonJS scene
  107715. * @param origin The origin position of the gravitational field event
  107716. * @param radius The radius of the gravitational field event
  107717. * @param strength The strength of the gravitational field event
  107718. * @param falloff The falloff for the gravitational field event
  107719. */
  107720. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107721. /**
  107722. * Returns the data related to the gravitational field event (sphere).
  107723. * @returns A gravitational field event
  107724. */
  107725. getData(): PhysicsGravitationalFieldEventData;
  107726. /**
  107727. * Enables the gravitational field.
  107728. */
  107729. enable(): void;
  107730. /**
  107731. * Disables the gravitational field.
  107732. */
  107733. disable(): void;
  107734. /**
  107735. * Disposes the sphere.
  107736. * @param force The force to dispose from the gravitational field event
  107737. */
  107738. dispose(force?: boolean): void;
  107739. private _tick;
  107740. }
  107741. /**
  107742. * Represents a physics updraft event
  107743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107744. */
  107745. export class PhysicsUpdraftEvent {
  107746. private _scene;
  107747. private _origin;
  107748. private _radius;
  107749. private _strength;
  107750. private _height;
  107751. private _updraftMode;
  107752. private _physicsEngine;
  107753. private _originTop;
  107754. private _originDirection;
  107755. private _tickCallback;
  107756. private _cylinder;
  107757. private _cylinderPosition;
  107758. private _dataFetched;
  107759. /**
  107760. * Initializes the physics updraft event
  107761. * @param _scene BabylonJS scene
  107762. * @param _origin The origin position of the updraft
  107763. * @param _radius The radius of the updraft
  107764. * @param _strength The strength of the updraft
  107765. * @param _height The height of the updraft
  107766. * @param _updraftMode The mode of the updraft
  107767. */
  107768. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107769. /**
  107770. * Returns the data related to the updraft event (cylinder).
  107771. * @returns A physics updraft event
  107772. */
  107773. getData(): PhysicsUpdraftEventData;
  107774. /**
  107775. * Enables the updraft.
  107776. */
  107777. enable(): void;
  107778. /**
  107779. * Disables the cortex.
  107780. */
  107781. disable(): void;
  107782. /**
  107783. * Disposes the sphere.
  107784. * @param force Specifies if the updraft should be disposed by force
  107785. */
  107786. dispose(force?: boolean): void;
  107787. private getImpostorForceAndContactPoint;
  107788. private _tick;
  107789. /*** Helpers ***/
  107790. private _prepareCylinder;
  107791. private _intersectsWithCylinder;
  107792. }
  107793. /**
  107794. * Represents a physics vortex event
  107795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107796. */
  107797. export class PhysicsVortexEvent {
  107798. private _scene;
  107799. private _origin;
  107800. private _radius;
  107801. private _strength;
  107802. private _height;
  107803. private _physicsEngine;
  107804. private _originTop;
  107805. private _centripetalForceThreshold;
  107806. private _updraftMultiplier;
  107807. private _tickCallback;
  107808. private _cylinder;
  107809. private _cylinderPosition;
  107810. private _dataFetched;
  107811. /**
  107812. * Initializes the physics vortex event
  107813. * @param _scene The BabylonJS scene
  107814. * @param _origin The origin position of the vortex
  107815. * @param _radius The radius of the vortex
  107816. * @param _strength The strength of the vortex
  107817. * @param _height The height of the vortex
  107818. */
  107819. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107820. /**
  107821. * Returns the data related to the vortex event (cylinder).
  107822. * @returns The physics vortex event data
  107823. */
  107824. getData(): PhysicsVortexEventData;
  107825. /**
  107826. * Enables the vortex.
  107827. */
  107828. enable(): void;
  107829. /**
  107830. * Disables the cortex.
  107831. */
  107832. disable(): void;
  107833. /**
  107834. * Disposes the sphere.
  107835. * @param force
  107836. */
  107837. dispose(force?: boolean): void;
  107838. private getImpostorForceAndContactPoint;
  107839. private _tick;
  107840. /*** Helpers ***/
  107841. private _prepareCylinder;
  107842. private _intersectsWithCylinder;
  107843. }
  107844. /**
  107845. * The strenght of the force in correspondence to the distance of the affected object
  107846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107847. */
  107848. export enum PhysicsRadialImpulseFalloff {
  107849. /** Defines that impulse is constant in strength across it's whole radius */
  107850. Constant = 0,
  107851. /** DEfines that impulse gets weaker if it's further from the origin */
  107852. Linear = 1
  107853. }
  107854. /**
  107855. * The strength of the force in correspondence to the distance of the affected object
  107856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107857. */
  107858. export enum PhysicsUpdraftMode {
  107859. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107860. Center = 0,
  107861. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107862. Perpendicular = 1
  107863. }
  107864. /**
  107865. * Interface for a physics force and contact point
  107866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107867. */
  107868. export interface PhysicsForceAndContactPoint {
  107869. /**
  107870. * The force applied at the contact point
  107871. */
  107872. force: Vector3;
  107873. /**
  107874. * The contact point
  107875. */
  107876. contactPoint: Vector3;
  107877. }
  107878. /**
  107879. * Interface for radial explosion event data
  107880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107881. */
  107882. export interface PhysicsRadialExplosionEventData {
  107883. /**
  107884. * A sphere used for the radial explosion event
  107885. */
  107886. sphere: Mesh;
  107887. /**
  107888. * An array of rays for the radial explosion event
  107889. */
  107890. rays: Array<Ray>;
  107891. }
  107892. /**
  107893. * Interface for gravitational field event data
  107894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107895. */
  107896. export interface PhysicsGravitationalFieldEventData {
  107897. /**
  107898. * A sphere mesh used for the gravitational field event
  107899. */
  107900. sphere: Mesh;
  107901. }
  107902. /**
  107903. * Interface for updraft event data
  107904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107905. */
  107906. export interface PhysicsUpdraftEventData {
  107907. /**
  107908. * A cylinder used for the updraft event
  107909. */
  107910. cylinder: Mesh;
  107911. }
  107912. /**
  107913. * Interface for vortex event data
  107914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107915. */
  107916. export interface PhysicsVortexEventData {
  107917. /**
  107918. * A cylinder used for the vortex event
  107919. */
  107920. cylinder: Mesh;
  107921. }
  107922. }
  107923. declare module BABYLON {
  107924. /**
  107925. * AmmoJS Physics plugin
  107926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107927. * @see https://github.com/kripken/ammo.js/
  107928. */
  107929. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107930. private _useDeltaForWorldStep;
  107931. /**
  107932. * Reference to the Ammo library
  107933. */
  107934. bjsAMMO: any;
  107935. /**
  107936. * Created ammoJS world which physics bodies are added to
  107937. */
  107938. world: any;
  107939. /**
  107940. * Name of the plugin
  107941. */
  107942. name: string;
  107943. private _timeStep;
  107944. private _fixedTimeStep;
  107945. private _maxSteps;
  107946. private _tmpQuaternion;
  107947. private _tmpAmmoTransform;
  107948. private _tmpAmmoQuaternion;
  107949. private _tmpAmmoConcreteContactResultCallback;
  107950. private _collisionConfiguration;
  107951. private _dispatcher;
  107952. private _overlappingPairCache;
  107953. private _solver;
  107954. private _tmpAmmoVectorA;
  107955. private _tmpAmmoVectorB;
  107956. private _tmpAmmoVectorC;
  107957. private _tmpContactCallbackResult;
  107958. private static readonly DISABLE_COLLISION_FLAG;
  107959. private static readonly KINEMATIC_FLAG;
  107960. private static readonly DISABLE_DEACTIVATION_FLAG;
  107961. /**
  107962. * Initializes the ammoJS plugin
  107963. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107964. * @param ammoInjection can be used to inject your own ammo reference
  107965. */
  107966. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107967. /**
  107968. * Sets the gravity of the physics world (m/(s^2))
  107969. * @param gravity Gravity to set
  107970. */
  107971. setGravity(gravity: Vector3): void;
  107972. /**
  107973. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107974. * @param timeStep timestep to use in seconds
  107975. */
  107976. setTimeStep(timeStep: number): void;
  107977. /**
  107978. * 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)
  107979. * @param fixedTimeStep fixedTimeStep to use in seconds
  107980. */
  107981. setFixedTimeStep(fixedTimeStep: number): void;
  107982. /**
  107983. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107984. * @param maxSteps the maximum number of steps by the physics engine per frame
  107985. */
  107986. setMaxSteps(maxSteps: number): void;
  107987. /**
  107988. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107989. * @returns the current timestep in seconds
  107990. */
  107991. getTimeStep(): number;
  107992. private _isImpostorInContact;
  107993. private _isImpostorPairInContact;
  107994. private _stepSimulation;
  107995. /**
  107996. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107997. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107998. * After the step the babylon meshes are set to the position of the physics imposters
  107999. * @param delta amount of time to step forward
  108000. * @param impostors array of imposters to update before/after the step
  108001. */
  108002. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108003. private _tmpVector;
  108004. private _tmpMatrix;
  108005. /**
  108006. * Applies an implulse on the imposter
  108007. * @param impostor imposter to apply impulse
  108008. * @param force amount of force to be applied to the imposter
  108009. * @param contactPoint the location to apply the impulse on the imposter
  108010. */
  108011. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108012. /**
  108013. * Applies a force on the imposter
  108014. * @param impostor imposter to apply force
  108015. * @param force amount of force to be applied to the imposter
  108016. * @param contactPoint the location to apply the force on the imposter
  108017. */
  108018. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108019. /**
  108020. * Creates a physics body using the plugin
  108021. * @param impostor the imposter to create the physics body on
  108022. */
  108023. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108024. /**
  108025. * Removes the physics body from the imposter and disposes of the body's memory
  108026. * @param impostor imposter to remove the physics body from
  108027. */
  108028. removePhysicsBody(impostor: PhysicsImpostor): void;
  108029. /**
  108030. * Generates a joint
  108031. * @param impostorJoint the imposter joint to create the joint with
  108032. */
  108033. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108034. /**
  108035. * Removes a joint
  108036. * @param impostorJoint the imposter joint to remove the joint from
  108037. */
  108038. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108039. private _addMeshVerts;
  108040. private _createShape;
  108041. /**
  108042. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108043. * @param impostor imposter containing the physics body and babylon object
  108044. */
  108045. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108046. /**
  108047. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108048. * @param impostor imposter containing the physics body and babylon object
  108049. * @param newPosition new position
  108050. * @param newRotation new rotation
  108051. */
  108052. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108053. /**
  108054. * If this plugin is supported
  108055. * @returns true if its supported
  108056. */
  108057. isSupported(): boolean;
  108058. /**
  108059. * Sets the linear velocity of the physics body
  108060. * @param impostor imposter to set the velocity on
  108061. * @param velocity velocity to set
  108062. */
  108063. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108064. /**
  108065. * Sets the angular velocity of the physics body
  108066. * @param impostor imposter to set the velocity on
  108067. * @param velocity velocity to set
  108068. */
  108069. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108070. /**
  108071. * gets the linear velocity
  108072. * @param impostor imposter to get linear velocity from
  108073. * @returns linear velocity
  108074. */
  108075. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108076. /**
  108077. * gets the angular velocity
  108078. * @param impostor imposter to get angular velocity from
  108079. * @returns angular velocity
  108080. */
  108081. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108082. /**
  108083. * Sets the mass of physics body
  108084. * @param impostor imposter to set the mass on
  108085. * @param mass mass to set
  108086. */
  108087. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108088. /**
  108089. * Gets the mass of the physics body
  108090. * @param impostor imposter to get the mass from
  108091. * @returns mass
  108092. */
  108093. getBodyMass(impostor: PhysicsImpostor): number;
  108094. /**
  108095. * Gets friction of the impostor
  108096. * @param impostor impostor to get friction from
  108097. * @returns friction value
  108098. */
  108099. getBodyFriction(impostor: PhysicsImpostor): number;
  108100. /**
  108101. * Sets friction of the impostor
  108102. * @param impostor impostor to set friction on
  108103. * @param friction friction value
  108104. */
  108105. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108106. /**
  108107. * Gets restitution of the impostor
  108108. * @param impostor impostor to get restitution from
  108109. * @returns restitution value
  108110. */
  108111. getBodyRestitution(impostor: PhysicsImpostor): number;
  108112. /**
  108113. * Sets resitution of the impostor
  108114. * @param impostor impostor to set resitution on
  108115. * @param restitution resitution value
  108116. */
  108117. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108118. /**
  108119. * Sleeps the physics body and stops it from being active
  108120. * @param impostor impostor to sleep
  108121. */
  108122. sleepBody(impostor: PhysicsImpostor): void;
  108123. /**
  108124. * Activates the physics body
  108125. * @param impostor impostor to activate
  108126. */
  108127. wakeUpBody(impostor: PhysicsImpostor): void;
  108128. /**
  108129. * Updates the distance parameters of the joint
  108130. * @param joint joint to update
  108131. * @param maxDistance maximum distance of the joint
  108132. * @param minDistance minimum distance of the joint
  108133. */
  108134. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108135. /**
  108136. * Sets a motor on the joint
  108137. * @param joint joint to set motor on
  108138. * @param speed speed of the motor
  108139. * @param maxForce maximum force of the motor
  108140. * @param motorIndex index of the motor
  108141. */
  108142. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108143. /**
  108144. * Sets the motors limit
  108145. * @param joint joint to set limit on
  108146. * @param upperLimit upper limit
  108147. * @param lowerLimit lower limit
  108148. */
  108149. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108150. /**
  108151. * Syncs the position and rotation of a mesh with the impostor
  108152. * @param mesh mesh to sync
  108153. * @param impostor impostor to update the mesh with
  108154. */
  108155. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108156. /**
  108157. * Gets the radius of the impostor
  108158. * @param impostor impostor to get radius from
  108159. * @returns the radius
  108160. */
  108161. getRadius(impostor: PhysicsImpostor): number;
  108162. /**
  108163. * Gets the box size of the impostor
  108164. * @param impostor impostor to get box size from
  108165. * @param result the resulting box size
  108166. */
  108167. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108168. /**
  108169. * Disposes of the impostor
  108170. */
  108171. dispose(): void;
  108172. }
  108173. }
  108174. declare module BABYLON {
  108175. /** @hidden */
  108176. export var blackAndWhitePixelShader: {
  108177. name: string;
  108178. shader: string;
  108179. };
  108180. }
  108181. declare module BABYLON {
  108182. /**
  108183. * Post process used to render in black and white
  108184. */
  108185. export class BlackAndWhitePostProcess extends PostProcess {
  108186. /**
  108187. * Linear about to convert he result to black and white (default: 1)
  108188. */
  108189. degree: number;
  108190. /**
  108191. * Creates a black and white post process
  108192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  108193. * @param name The name of the effect.
  108194. * @param options The required width/height ratio to downsize to before computing the render pass.
  108195. * @param camera The camera to apply the render pass to.
  108196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108197. * @param engine The engine which the post process will be applied. (default: current engine)
  108198. * @param reusable If the post process can be reused on the same frame. (default: false)
  108199. */
  108200. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108201. }
  108202. }
  108203. declare module BABYLON {
  108204. /**
  108205. * This represents a set of one or more post processes in Babylon.
  108206. * A post process can be used to apply a shader to a texture after it is rendered.
  108207. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108208. */
  108209. export class PostProcessRenderEffect {
  108210. private _postProcesses;
  108211. private _getPostProcesses;
  108212. private _singleInstance;
  108213. private _cameras;
  108214. private _indicesForCamera;
  108215. /**
  108216. * Name of the effect
  108217. * @hidden
  108218. */
  108219. _name: string;
  108220. /**
  108221. * Instantiates a post process render effect.
  108222. * A post process can be used to apply a shader to a texture after it is rendered.
  108223. * @param engine The engine the effect is tied to
  108224. * @param name The name of the effect
  108225. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108226. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108227. */
  108228. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108229. /**
  108230. * Checks if all the post processes in the effect are supported.
  108231. */
  108232. readonly isSupported: boolean;
  108233. /**
  108234. * Updates the current state of the effect
  108235. * @hidden
  108236. */
  108237. _update(): void;
  108238. /**
  108239. * Attaches the effect on cameras
  108240. * @param cameras The camera to attach to.
  108241. * @hidden
  108242. */
  108243. _attachCameras(cameras: Camera): void;
  108244. /**
  108245. * Attaches the effect on cameras
  108246. * @param cameras The camera to attach to.
  108247. * @hidden
  108248. */
  108249. _attachCameras(cameras: Camera[]): void;
  108250. /**
  108251. * Detatches the effect on cameras
  108252. * @param cameras The camera to detatch from.
  108253. * @hidden
  108254. */
  108255. _detachCameras(cameras: Camera): void;
  108256. /**
  108257. * Detatches the effect on cameras
  108258. * @param cameras The camera to detatch from.
  108259. * @hidden
  108260. */
  108261. _detachCameras(cameras: Camera[]): void;
  108262. /**
  108263. * Enables the effect on given cameras
  108264. * @param cameras The camera to enable.
  108265. * @hidden
  108266. */
  108267. _enable(cameras: Camera): void;
  108268. /**
  108269. * Enables the effect on given cameras
  108270. * @param cameras The camera to enable.
  108271. * @hidden
  108272. */
  108273. _enable(cameras: Nullable<Camera[]>): void;
  108274. /**
  108275. * Disables the effect on the given cameras
  108276. * @param cameras The camera to disable.
  108277. * @hidden
  108278. */
  108279. _disable(cameras: Camera): void;
  108280. /**
  108281. * Disables the effect on the given cameras
  108282. * @param cameras The camera to disable.
  108283. * @hidden
  108284. */
  108285. _disable(cameras: Nullable<Camera[]>): void;
  108286. /**
  108287. * Gets a list of the post processes contained in the effect.
  108288. * @param camera The camera to get the post processes on.
  108289. * @returns The list of the post processes in the effect.
  108290. */
  108291. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108292. }
  108293. }
  108294. declare module BABYLON {
  108295. /** @hidden */
  108296. export var extractHighlightsPixelShader: {
  108297. name: string;
  108298. shader: string;
  108299. };
  108300. }
  108301. declare module BABYLON {
  108302. /**
  108303. * 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.
  108304. */
  108305. export class ExtractHighlightsPostProcess extends PostProcess {
  108306. /**
  108307. * The luminance threshold, pixels below this value will be set to black.
  108308. */
  108309. threshold: number;
  108310. /** @hidden */
  108311. _exposure: number;
  108312. /**
  108313. * Post process which has the input texture to be used when performing highlight extraction
  108314. * @hidden
  108315. */
  108316. _inputPostProcess: Nullable<PostProcess>;
  108317. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108318. }
  108319. }
  108320. declare module BABYLON {
  108321. /** @hidden */
  108322. export var bloomMergePixelShader: {
  108323. name: string;
  108324. shader: string;
  108325. };
  108326. }
  108327. declare module BABYLON {
  108328. /**
  108329. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108330. */
  108331. export class BloomMergePostProcess extends PostProcess {
  108332. /** Weight of the bloom to be added to the original input. */
  108333. weight: number;
  108334. /**
  108335. * Creates a new instance of @see BloomMergePostProcess
  108336. * @param name The name of the effect.
  108337. * @param originalFromInput Post process which's input will be used for the merge.
  108338. * @param blurred Blurred highlights post process which's output will be used.
  108339. * @param weight Weight of the bloom to be added to the original input.
  108340. * @param options The required width/height ratio to downsize to before computing the render pass.
  108341. * @param camera The camera to apply the render pass to.
  108342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108343. * @param engine The engine which the post process will be applied. (default: current engine)
  108344. * @param reusable If the post process can be reused on the same frame. (default: false)
  108345. * @param textureType Type of textures used when performing the post process. (default: 0)
  108346. * @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)
  108347. */
  108348. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108349. /** Weight of the bloom to be added to the original input. */
  108350. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108351. }
  108352. }
  108353. declare module BABYLON {
  108354. /**
  108355. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108356. */
  108357. export class BloomEffect extends PostProcessRenderEffect {
  108358. private bloomScale;
  108359. /**
  108360. * @hidden Internal
  108361. */
  108362. _effects: Array<PostProcess>;
  108363. /**
  108364. * @hidden Internal
  108365. */
  108366. _downscale: ExtractHighlightsPostProcess;
  108367. private _blurX;
  108368. private _blurY;
  108369. private _merge;
  108370. /**
  108371. * The luminance threshold to find bright areas of the image to bloom.
  108372. */
  108373. threshold: number;
  108374. /**
  108375. * The strength of the bloom.
  108376. */
  108377. weight: number;
  108378. /**
  108379. * Specifies the size of the bloom blur kernel, relative to the final output size
  108380. */
  108381. kernel: number;
  108382. /**
  108383. * Creates a new instance of @see BloomEffect
  108384. * @param scene The scene the effect belongs to.
  108385. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108386. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108387. * @param bloomWeight The the strength of bloom.
  108388. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108389. * @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)
  108390. */
  108391. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108392. /**
  108393. * Disposes each of the internal effects for a given camera.
  108394. * @param camera The camera to dispose the effect on.
  108395. */
  108396. disposeEffects(camera: Camera): void;
  108397. /**
  108398. * @hidden Internal
  108399. */
  108400. _updateEffects(): void;
  108401. /**
  108402. * Internal
  108403. * @returns if all the contained post processes are ready.
  108404. * @hidden
  108405. */
  108406. _isReady(): boolean;
  108407. }
  108408. }
  108409. declare module BABYLON {
  108410. /** @hidden */
  108411. export var chromaticAberrationPixelShader: {
  108412. name: string;
  108413. shader: string;
  108414. };
  108415. }
  108416. declare module BABYLON {
  108417. /**
  108418. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108419. */
  108420. export class ChromaticAberrationPostProcess extends PostProcess {
  108421. /**
  108422. * The amount of seperation of rgb channels (default: 30)
  108423. */
  108424. aberrationAmount: number;
  108425. /**
  108426. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108427. */
  108428. radialIntensity: number;
  108429. /**
  108430. * 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))
  108431. */
  108432. direction: Vector2;
  108433. /**
  108434. * 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))
  108435. */
  108436. centerPosition: Vector2;
  108437. /**
  108438. * Creates a new instance ChromaticAberrationPostProcess
  108439. * @param name The name of the effect.
  108440. * @param screenWidth The width of the screen to apply the effect on.
  108441. * @param screenHeight The height of the screen to apply the effect on.
  108442. * @param options The required width/height ratio to downsize to before computing the render pass.
  108443. * @param camera The camera to apply the render pass to.
  108444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108445. * @param engine The engine which the post process will be applied. (default: current engine)
  108446. * @param reusable If the post process can be reused on the same frame. (default: false)
  108447. * @param textureType Type of textures used when performing the post process. (default: 0)
  108448. * @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)
  108449. */
  108450. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108451. }
  108452. }
  108453. declare module BABYLON {
  108454. /** @hidden */
  108455. export var circleOfConfusionPixelShader: {
  108456. name: string;
  108457. shader: string;
  108458. };
  108459. }
  108460. declare module BABYLON {
  108461. /**
  108462. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108463. */
  108464. export class CircleOfConfusionPostProcess extends PostProcess {
  108465. /**
  108466. * 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.
  108467. */
  108468. lensSize: number;
  108469. /**
  108470. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108471. */
  108472. fStop: number;
  108473. /**
  108474. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108475. */
  108476. focusDistance: number;
  108477. /**
  108478. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108479. */
  108480. focalLength: number;
  108481. private _depthTexture;
  108482. /**
  108483. * Creates a new instance CircleOfConfusionPostProcess
  108484. * @param name The name of the effect.
  108485. * @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.
  108486. * @param options The required width/height ratio to downsize to before computing the render pass.
  108487. * @param camera The camera to apply the render pass to.
  108488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108489. * @param engine The engine which the post process will be applied. (default: current engine)
  108490. * @param reusable If the post process can be reused on the same frame. (default: false)
  108491. * @param textureType Type of textures used when performing the post process. (default: 0)
  108492. * @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)
  108493. */
  108494. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108495. /**
  108496. * 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.
  108497. */
  108498. depthTexture: RenderTargetTexture;
  108499. }
  108500. }
  108501. declare module BABYLON {
  108502. /** @hidden */
  108503. export var colorCorrectionPixelShader: {
  108504. name: string;
  108505. shader: string;
  108506. };
  108507. }
  108508. declare module BABYLON {
  108509. /**
  108510. *
  108511. * This post-process allows the modification of rendered colors by using
  108512. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108513. *
  108514. * The object needs to be provided an url to a texture containing the color
  108515. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108516. * Use an image editing software to tweak the LUT to match your needs.
  108517. *
  108518. * For an example of a color LUT, see here:
  108519. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108520. * For explanations on color grading, see here:
  108521. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108522. *
  108523. */
  108524. export class ColorCorrectionPostProcess extends PostProcess {
  108525. private _colorTableTexture;
  108526. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108527. }
  108528. }
  108529. declare module BABYLON {
  108530. /** @hidden */
  108531. export var convolutionPixelShader: {
  108532. name: string;
  108533. shader: string;
  108534. };
  108535. }
  108536. declare module BABYLON {
  108537. /**
  108538. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108539. * input texture to perform effects such as edge detection or sharpening
  108540. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108541. */
  108542. export class ConvolutionPostProcess extends PostProcess {
  108543. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108544. kernel: number[];
  108545. /**
  108546. * Creates a new instance ConvolutionPostProcess
  108547. * @param name The name of the effect.
  108548. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108549. * @param options The required width/height ratio to downsize to before computing the render pass.
  108550. * @param camera The camera to apply the render pass to.
  108551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108552. * @param engine The engine which the post process will be applied. (default: current engine)
  108553. * @param reusable If the post process can be reused on the same frame. (default: false)
  108554. * @param textureType Type of textures used when performing the post process. (default: 0)
  108555. */
  108556. constructor(name: string,
  108557. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108558. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108559. /**
  108560. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108561. */
  108562. static EdgeDetect0Kernel: number[];
  108563. /**
  108564. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108565. */
  108566. static EdgeDetect1Kernel: number[];
  108567. /**
  108568. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108569. */
  108570. static EdgeDetect2Kernel: number[];
  108571. /**
  108572. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108573. */
  108574. static SharpenKernel: number[];
  108575. /**
  108576. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108577. */
  108578. static EmbossKernel: number[];
  108579. /**
  108580. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108581. */
  108582. static GaussianKernel: number[];
  108583. }
  108584. }
  108585. declare module BABYLON {
  108586. /**
  108587. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108588. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108589. * based on samples that have a large difference in distance than the center pixel.
  108590. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108591. */
  108592. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108593. direction: Vector2;
  108594. /**
  108595. * Creates a new instance CircleOfConfusionPostProcess
  108596. * @param name The name of the effect.
  108597. * @param scene The scene the effect belongs to.
  108598. * @param direction The direction the blur should be applied.
  108599. * @param kernel The size of the kernel used to blur.
  108600. * @param options The required width/height ratio to downsize to before computing the render pass.
  108601. * @param camera The camera to apply the render pass to.
  108602. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108603. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108605. * @param engine The engine which the post process will be applied. (default: current engine)
  108606. * @param reusable If the post process can be reused on the same frame. (default: false)
  108607. * @param textureType Type of textures used when performing the post process. (default: 0)
  108608. * @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)
  108609. */
  108610. 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);
  108611. }
  108612. }
  108613. declare module BABYLON {
  108614. /** @hidden */
  108615. export var depthOfFieldMergePixelShader: {
  108616. name: string;
  108617. shader: string;
  108618. };
  108619. }
  108620. declare module BABYLON {
  108621. /**
  108622. * Options to be set when merging outputs from the default pipeline.
  108623. */
  108624. export class DepthOfFieldMergePostProcessOptions {
  108625. /**
  108626. * The original image to merge on top of
  108627. */
  108628. originalFromInput: PostProcess;
  108629. /**
  108630. * Parameters to perform the merge of the depth of field effect
  108631. */
  108632. depthOfField?: {
  108633. circleOfConfusion: PostProcess;
  108634. blurSteps: Array<PostProcess>;
  108635. };
  108636. /**
  108637. * Parameters to perform the merge of bloom effect
  108638. */
  108639. bloom?: {
  108640. blurred: PostProcess;
  108641. weight: number;
  108642. };
  108643. }
  108644. /**
  108645. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108646. */
  108647. export class DepthOfFieldMergePostProcess extends PostProcess {
  108648. private blurSteps;
  108649. /**
  108650. * Creates a new instance of DepthOfFieldMergePostProcess
  108651. * @param name The name of the effect.
  108652. * @param originalFromInput Post process which's input will be used for the merge.
  108653. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108654. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108655. * @param options The required width/height ratio to downsize to before computing the render pass.
  108656. * @param camera The camera to apply the render pass to.
  108657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108658. * @param engine The engine which the post process will be applied. (default: current engine)
  108659. * @param reusable If the post process can be reused on the same frame. (default: false)
  108660. * @param textureType Type of textures used when performing the post process. (default: 0)
  108661. * @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)
  108662. */
  108663. 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);
  108664. /**
  108665. * Updates the effect with the current post process compile time values and recompiles the shader.
  108666. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108667. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108668. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108669. * @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
  108670. * @param onCompiled Called when the shader has been compiled.
  108671. * @param onError Called if there is an error when compiling a shader.
  108672. */
  108673. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108674. }
  108675. }
  108676. declare module BABYLON {
  108677. /**
  108678. * Specifies the level of max blur that should be applied when using the depth of field effect
  108679. */
  108680. export enum DepthOfFieldEffectBlurLevel {
  108681. /**
  108682. * Subtle blur
  108683. */
  108684. Low = 0,
  108685. /**
  108686. * Medium blur
  108687. */
  108688. Medium = 1,
  108689. /**
  108690. * Large blur
  108691. */
  108692. High = 2
  108693. }
  108694. /**
  108695. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108696. */
  108697. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108698. private _circleOfConfusion;
  108699. /**
  108700. * @hidden Internal, blurs from high to low
  108701. */
  108702. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108703. private _depthOfFieldBlurY;
  108704. private _dofMerge;
  108705. /**
  108706. * @hidden Internal post processes in depth of field effect
  108707. */
  108708. _effects: Array<PostProcess>;
  108709. /**
  108710. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108711. */
  108712. focalLength: number;
  108713. /**
  108714. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108715. */
  108716. fStop: number;
  108717. /**
  108718. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108719. */
  108720. focusDistance: number;
  108721. /**
  108722. * 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.
  108723. */
  108724. lensSize: number;
  108725. /**
  108726. * Creates a new instance DepthOfFieldEffect
  108727. * @param scene The scene the effect belongs to.
  108728. * @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.
  108729. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108730. * @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)
  108731. */
  108732. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108733. /**
  108734. * 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.
  108735. */
  108736. depthTexture: RenderTargetTexture;
  108737. /**
  108738. * Disposes each of the internal effects for a given camera.
  108739. * @param camera The camera to dispose the effect on.
  108740. */
  108741. disposeEffects(camera: Camera): void;
  108742. /**
  108743. * @hidden Internal
  108744. */
  108745. _updateEffects(): void;
  108746. /**
  108747. * Internal
  108748. * @returns if all the contained post processes are ready.
  108749. * @hidden
  108750. */
  108751. _isReady(): boolean;
  108752. }
  108753. }
  108754. declare module BABYLON {
  108755. /** @hidden */
  108756. export var displayPassPixelShader: {
  108757. name: string;
  108758. shader: string;
  108759. };
  108760. }
  108761. declare module BABYLON {
  108762. /**
  108763. * DisplayPassPostProcess which produces an output the same as it's input
  108764. */
  108765. export class DisplayPassPostProcess extends PostProcess {
  108766. /**
  108767. * Creates the DisplayPassPostProcess
  108768. * @param name The name of the effect.
  108769. * @param options The required width/height ratio to downsize to before computing the render pass.
  108770. * @param camera The camera to apply the render pass to.
  108771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108772. * @param engine The engine which the post process will be applied. (default: current engine)
  108773. * @param reusable If the post process can be reused on the same frame. (default: false)
  108774. */
  108775. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108776. }
  108777. }
  108778. declare module BABYLON {
  108779. /** @hidden */
  108780. export var filterPixelShader: {
  108781. name: string;
  108782. shader: string;
  108783. };
  108784. }
  108785. declare module BABYLON {
  108786. /**
  108787. * Applies a kernel filter to the image
  108788. */
  108789. export class FilterPostProcess extends PostProcess {
  108790. /** The matrix to be applied to the image */
  108791. kernelMatrix: Matrix;
  108792. /**
  108793. *
  108794. * @param name The name of the effect.
  108795. * @param kernelMatrix The matrix to be applied to the image
  108796. * @param options The required width/height ratio to downsize to before computing the render pass.
  108797. * @param camera The camera to apply the render pass to.
  108798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108799. * @param engine The engine which the post process will be applied. (default: current engine)
  108800. * @param reusable If the post process can be reused on the same frame. (default: false)
  108801. */
  108802. constructor(name: string,
  108803. /** The matrix to be applied to the image */
  108804. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108805. }
  108806. }
  108807. declare module BABYLON {
  108808. /** @hidden */
  108809. export var fxaaPixelShader: {
  108810. name: string;
  108811. shader: string;
  108812. };
  108813. }
  108814. declare module BABYLON {
  108815. /** @hidden */
  108816. export var fxaaVertexShader: {
  108817. name: string;
  108818. shader: string;
  108819. };
  108820. }
  108821. declare module BABYLON {
  108822. /**
  108823. * Fxaa post process
  108824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108825. */
  108826. export class FxaaPostProcess extends PostProcess {
  108827. /** @hidden */
  108828. texelWidth: number;
  108829. /** @hidden */
  108830. texelHeight: number;
  108831. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108832. private _getDefines;
  108833. }
  108834. }
  108835. declare module BABYLON {
  108836. /** @hidden */
  108837. export var grainPixelShader: {
  108838. name: string;
  108839. shader: string;
  108840. };
  108841. }
  108842. declare module BABYLON {
  108843. /**
  108844. * The GrainPostProcess adds noise to the image at mid luminance levels
  108845. */
  108846. export class GrainPostProcess extends PostProcess {
  108847. /**
  108848. * The intensity of the grain added (default: 30)
  108849. */
  108850. intensity: number;
  108851. /**
  108852. * If the grain should be randomized on every frame
  108853. */
  108854. animated: boolean;
  108855. /**
  108856. * Creates a new instance of @see GrainPostProcess
  108857. * @param name The name of the effect.
  108858. * @param options The required width/height ratio to downsize to before computing the render pass.
  108859. * @param camera The camera to apply the render pass to.
  108860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108861. * @param engine The engine which the post process will be applied. (default: current engine)
  108862. * @param reusable If the post process can be reused on the same frame. (default: false)
  108863. * @param textureType Type of textures used when performing the post process. (default: 0)
  108864. * @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)
  108865. */
  108866. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108867. }
  108868. }
  108869. declare module BABYLON {
  108870. /** @hidden */
  108871. export var highlightsPixelShader: {
  108872. name: string;
  108873. shader: string;
  108874. };
  108875. }
  108876. declare module BABYLON {
  108877. /**
  108878. * Extracts highlights from the image
  108879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108880. */
  108881. export class HighlightsPostProcess extends PostProcess {
  108882. /**
  108883. * Extracts highlights from the image
  108884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108885. * @param name The name of the effect.
  108886. * @param options The required width/height ratio to downsize to before computing the render pass.
  108887. * @param camera The camera to apply the render pass to.
  108888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108889. * @param engine The engine which the post process will be applied. (default: current engine)
  108890. * @param reusable If the post process can be reused on the same frame. (default: false)
  108891. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108892. */
  108893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108894. }
  108895. }
  108896. declare module BABYLON {
  108897. /** @hidden */
  108898. export var mrtFragmentDeclaration: {
  108899. name: string;
  108900. shader: string;
  108901. };
  108902. }
  108903. declare module BABYLON {
  108904. /** @hidden */
  108905. export var geometryPixelShader: {
  108906. name: string;
  108907. shader: string;
  108908. };
  108909. }
  108910. declare module BABYLON {
  108911. /** @hidden */
  108912. export var geometryVertexShader: {
  108913. name: string;
  108914. shader: string;
  108915. };
  108916. }
  108917. declare module BABYLON {
  108918. /**
  108919. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108920. */
  108921. export class GeometryBufferRenderer {
  108922. /**
  108923. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108924. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108925. */
  108926. static readonly POSITION_TEXTURE_TYPE: number;
  108927. /**
  108928. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108929. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108930. */
  108931. static readonly VELOCITY_TEXTURE_TYPE: number;
  108932. /**
  108933. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108934. * in order to compute objects velocities when enableVelocity is set to "true"
  108935. * @hidden
  108936. */
  108937. _previousTransformationMatrices: {
  108938. [index: number]: Matrix;
  108939. };
  108940. private _scene;
  108941. private _multiRenderTarget;
  108942. private _ratio;
  108943. private _enablePosition;
  108944. private _enableVelocity;
  108945. private _positionIndex;
  108946. private _velocityIndex;
  108947. protected _effect: Effect;
  108948. protected _cachedDefines: string;
  108949. /**
  108950. * Set the render list (meshes to be rendered) used in the G buffer.
  108951. */
  108952. renderList: Mesh[];
  108953. /**
  108954. * Gets wether or not G buffer are supported by the running hardware.
  108955. * This requires draw buffer supports
  108956. */
  108957. readonly isSupported: boolean;
  108958. /**
  108959. * Returns the index of the given texture type in the G-Buffer textures array
  108960. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108961. * @returns the index of the given texture type in the G-Buffer textures array
  108962. */
  108963. getTextureIndex(textureType: number): number;
  108964. /**
  108965. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108966. */
  108967. /**
  108968. * Sets whether or not objects positions are enabled for the G buffer.
  108969. */
  108970. enablePosition: boolean;
  108971. /**
  108972. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108973. */
  108974. /**
  108975. * Sets wether or not objects velocities are enabled for the G buffer.
  108976. */
  108977. enableVelocity: boolean;
  108978. /**
  108979. * Gets the scene associated with the buffer.
  108980. */
  108981. readonly scene: Scene;
  108982. /**
  108983. * Gets the ratio used by the buffer during its creation.
  108984. * How big is the buffer related to the main canvas.
  108985. */
  108986. readonly ratio: number;
  108987. /** @hidden */
  108988. static _SceneComponentInitialization: (scene: Scene) => void;
  108989. /**
  108990. * Creates a new G Buffer for the scene
  108991. * @param scene The scene the buffer belongs to
  108992. * @param ratio How big is the buffer related to the main canvas.
  108993. */
  108994. constructor(scene: Scene, ratio?: number);
  108995. /**
  108996. * Checks wether everything is ready to render a submesh to the G buffer.
  108997. * @param subMesh the submesh to check readiness for
  108998. * @param useInstances is the mesh drawn using instance or not
  108999. * @returns true if ready otherwise false
  109000. */
  109001. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109002. /**
  109003. * Gets the current underlying G Buffer.
  109004. * @returns the buffer
  109005. */
  109006. getGBuffer(): MultiRenderTarget;
  109007. /**
  109008. * Gets the number of samples used to render the buffer (anti aliasing).
  109009. */
  109010. /**
  109011. * Sets the number of samples used to render the buffer (anti aliasing).
  109012. */
  109013. samples: number;
  109014. /**
  109015. * Disposes the renderer and frees up associated resources.
  109016. */
  109017. dispose(): void;
  109018. protected _createRenderTargets(): void;
  109019. }
  109020. }
  109021. declare module BABYLON {
  109022. interface Scene {
  109023. /** @hidden (Backing field) */
  109024. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109025. /**
  109026. * Gets or Sets the current geometry buffer associated to the scene.
  109027. */
  109028. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109029. /**
  109030. * Enables a GeometryBufferRender and associates it with the scene
  109031. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109032. * @returns the GeometryBufferRenderer
  109033. */
  109034. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109035. /**
  109036. * Disables the GeometryBufferRender associated with the scene
  109037. */
  109038. disableGeometryBufferRenderer(): void;
  109039. }
  109040. /**
  109041. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109042. * in several rendering techniques.
  109043. */
  109044. export class GeometryBufferRendererSceneComponent 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. private _gatherRenderTargets;
  109072. }
  109073. }
  109074. declare module BABYLON {
  109075. /** @hidden */
  109076. export var motionBlurPixelShader: {
  109077. name: string;
  109078. shader: string;
  109079. };
  109080. }
  109081. declare module BABYLON {
  109082. /**
  109083. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  109084. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  109085. * As an example, all you have to do is to create the post-process:
  109086. * var mb = new BABYLON.MotionBlurPostProcess(
  109087. * 'mb', // The name of the effect.
  109088. * scene, // The scene containing the objects to blur according to their velocity.
  109089. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  109090. * camera // The camera to apply the render pass to.
  109091. * );
  109092. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  109093. */
  109094. export class MotionBlurPostProcess extends PostProcess {
  109095. /**
  109096. * Defines how much the image is blurred by the movement. Default value is equal to 1
  109097. */
  109098. motionStrength: number;
  109099. /**
  109100. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  109101. */
  109102. /**
  109103. * Sets the number of iterations to be used for motion blur quality
  109104. */
  109105. motionBlurSamples: number;
  109106. private _motionBlurSamples;
  109107. private _geometryBufferRenderer;
  109108. /**
  109109. * Creates a new instance MotionBlurPostProcess
  109110. * @param name The name of the effect.
  109111. * @param scene The scene containing the objects to blur according to their velocity.
  109112. * @param options The required width/height ratio to downsize to before computing the render pass.
  109113. * @param camera The camera to apply the render pass to.
  109114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109115. * @param engine The engine which the post process will be applied. (default: current engine)
  109116. * @param reusable If the post process can be reused on the same frame. (default: false)
  109117. * @param textureType Type of textures used when performing the post process. (default: 0)
  109118. * @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)
  109119. */
  109120. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109121. /**
  109122. * Disposes the post process.
  109123. * @param camera The camera to dispose the post process on.
  109124. */
  109125. dispose(camera?: Camera): void;
  109126. }
  109127. }
  109128. declare module BABYLON {
  109129. /** @hidden */
  109130. export var refractionPixelShader: {
  109131. name: string;
  109132. shader: string;
  109133. };
  109134. }
  109135. declare module BABYLON {
  109136. /**
  109137. * Post process which applies a refractin texture
  109138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  109139. */
  109140. export class RefractionPostProcess extends PostProcess {
  109141. /** the base color of the refraction (used to taint the rendering) */
  109142. color: Color3;
  109143. /** simulated refraction depth */
  109144. depth: number;
  109145. /** the coefficient of the base color (0 to remove base color tainting) */
  109146. colorLevel: number;
  109147. private _refTexture;
  109148. private _ownRefractionTexture;
  109149. /**
  109150. * Gets or sets the refraction texture
  109151. * Please note that you are responsible for disposing the texture if you set it manually
  109152. */
  109153. refractionTexture: Texture;
  109154. /**
  109155. * Initializes the RefractionPostProcess
  109156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  109157. * @param name The name of the effect.
  109158. * @param refractionTextureUrl Url of the refraction texture to use
  109159. * @param color the base color of the refraction (used to taint the rendering)
  109160. * @param depth simulated refraction depth
  109161. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  109162. * @param camera The camera to apply the render pass to.
  109163. * @param options The required width/height ratio to downsize to before computing the render pass.
  109164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109165. * @param engine The engine which the post process will be applied. (default: current engine)
  109166. * @param reusable If the post process can be reused on the same frame. (default: false)
  109167. */
  109168. constructor(name: string, refractionTextureUrl: string,
  109169. /** the base color of the refraction (used to taint the rendering) */
  109170. color: Color3,
  109171. /** simulated refraction depth */
  109172. depth: number,
  109173. /** the coefficient of the base color (0 to remove base color tainting) */
  109174. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109175. /**
  109176. * Disposes of the post process
  109177. * @param camera Camera to dispose post process on
  109178. */
  109179. dispose(camera: Camera): void;
  109180. }
  109181. }
  109182. declare module BABYLON {
  109183. /** @hidden */
  109184. export var sharpenPixelShader: {
  109185. name: string;
  109186. shader: string;
  109187. };
  109188. }
  109189. declare module BABYLON {
  109190. /**
  109191. * The SharpenPostProcess applies a sharpen kernel to every pixel
  109192. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109193. */
  109194. export class SharpenPostProcess extends PostProcess {
  109195. /**
  109196. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  109197. */
  109198. colorAmount: number;
  109199. /**
  109200. * How much sharpness should be applied (default: 0.3)
  109201. */
  109202. edgeAmount: number;
  109203. /**
  109204. * Creates a new instance ConvolutionPostProcess
  109205. * @param name The name of the effect.
  109206. * @param options The required width/height ratio to downsize to before computing the render pass.
  109207. * @param camera The camera to apply the render pass to.
  109208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109209. * @param engine The engine which the post process will be applied. (default: current engine)
  109210. * @param reusable If the post process can be reused on the same frame. (default: false)
  109211. * @param textureType Type of textures used when performing the post process. (default: 0)
  109212. * @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)
  109213. */
  109214. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109215. }
  109216. }
  109217. declare module BABYLON {
  109218. /**
  109219. * PostProcessRenderPipeline
  109220. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109221. */
  109222. export class PostProcessRenderPipeline {
  109223. private engine;
  109224. private _renderEffects;
  109225. private _renderEffectsForIsolatedPass;
  109226. /**
  109227. * @hidden
  109228. */
  109229. protected _cameras: Camera[];
  109230. /** @hidden */
  109231. _name: string;
  109232. /**
  109233. * Gets pipeline name
  109234. */
  109235. readonly name: string;
  109236. /**
  109237. * Initializes a PostProcessRenderPipeline
  109238. * @param engine engine to add the pipeline to
  109239. * @param name name of the pipeline
  109240. */
  109241. constructor(engine: Engine, name: string);
  109242. /**
  109243. * Gets the class name
  109244. * @returns "PostProcessRenderPipeline"
  109245. */
  109246. getClassName(): string;
  109247. /**
  109248. * If all the render effects in the pipeline are supported
  109249. */
  109250. readonly isSupported: boolean;
  109251. /**
  109252. * Adds an effect to the pipeline
  109253. * @param renderEffect the effect to add
  109254. */
  109255. addEffect(renderEffect: PostProcessRenderEffect): void;
  109256. /** @hidden */
  109257. _rebuild(): void;
  109258. /** @hidden */
  109259. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109260. /** @hidden */
  109261. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109262. /** @hidden */
  109263. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109264. /** @hidden */
  109265. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109266. /** @hidden */
  109267. _attachCameras(cameras: Camera, unique: boolean): void;
  109268. /** @hidden */
  109269. _attachCameras(cameras: Camera[], unique: boolean): void;
  109270. /** @hidden */
  109271. _detachCameras(cameras: Camera): void;
  109272. /** @hidden */
  109273. _detachCameras(cameras: Nullable<Camera[]>): void;
  109274. /** @hidden */
  109275. _update(): void;
  109276. /** @hidden */
  109277. _reset(): void;
  109278. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109279. /**
  109280. * Disposes of the pipeline
  109281. */
  109282. dispose(): void;
  109283. }
  109284. }
  109285. declare module BABYLON {
  109286. /**
  109287. * PostProcessRenderPipelineManager class
  109288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109289. */
  109290. export class PostProcessRenderPipelineManager {
  109291. private _renderPipelines;
  109292. /**
  109293. * Initializes a PostProcessRenderPipelineManager
  109294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109295. */
  109296. constructor();
  109297. /**
  109298. * Gets the list of supported render pipelines
  109299. */
  109300. readonly supportedPipelines: PostProcessRenderPipeline[];
  109301. /**
  109302. * Adds a pipeline to the manager
  109303. * @param renderPipeline The pipeline to add
  109304. */
  109305. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109306. /**
  109307. * Attaches a camera to the pipeline
  109308. * @param renderPipelineName The name of the pipeline to attach to
  109309. * @param cameras the camera to attach
  109310. * @param unique if the camera can be attached multiple times to the pipeline
  109311. */
  109312. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109313. /**
  109314. * Detaches a camera from the pipeline
  109315. * @param renderPipelineName The name of the pipeline to detach from
  109316. * @param cameras the camera to detach
  109317. */
  109318. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109319. /**
  109320. * Enables an effect by name on a pipeline
  109321. * @param renderPipelineName the name of the pipeline to enable the effect in
  109322. * @param renderEffectName the name of the effect to enable
  109323. * @param cameras the cameras that the effect should be enabled on
  109324. */
  109325. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109326. /**
  109327. * Disables an effect by name on a pipeline
  109328. * @param renderPipelineName the name of the pipeline to disable the effect in
  109329. * @param renderEffectName the name of the effect to disable
  109330. * @param cameras the cameras that the effect should be disabled on
  109331. */
  109332. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109333. /**
  109334. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109335. */
  109336. update(): void;
  109337. /** @hidden */
  109338. _rebuild(): void;
  109339. /**
  109340. * Disposes of the manager and pipelines
  109341. */
  109342. dispose(): void;
  109343. }
  109344. }
  109345. declare module BABYLON {
  109346. interface Scene {
  109347. /** @hidden (Backing field) */
  109348. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109349. /**
  109350. * Gets the postprocess render pipeline manager
  109351. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109352. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109353. */
  109354. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109355. }
  109356. /**
  109357. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109358. */
  109359. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109360. /**
  109361. * The component name helpfull to identify the component in the list of scene components.
  109362. */
  109363. readonly name: string;
  109364. /**
  109365. * The scene the component belongs to.
  109366. */
  109367. scene: Scene;
  109368. /**
  109369. * Creates a new instance of the component for the given scene
  109370. * @param scene Defines the scene to register the component in
  109371. */
  109372. constructor(scene: Scene);
  109373. /**
  109374. * Registers the component in a given scene
  109375. */
  109376. register(): void;
  109377. /**
  109378. * Rebuilds the elements related to this component in case of
  109379. * context lost for instance.
  109380. */
  109381. rebuild(): void;
  109382. /**
  109383. * Disposes the component and the associated ressources
  109384. */
  109385. dispose(): void;
  109386. private _gatherRenderTargets;
  109387. }
  109388. }
  109389. declare module BABYLON {
  109390. /**
  109391. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109392. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109393. */
  109394. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109395. private _scene;
  109396. private _camerasToBeAttached;
  109397. /**
  109398. * ID of the sharpen post process,
  109399. */
  109400. private readonly SharpenPostProcessId;
  109401. /**
  109402. * @ignore
  109403. * ID of the image processing post process;
  109404. */
  109405. readonly ImageProcessingPostProcessId: string;
  109406. /**
  109407. * @ignore
  109408. * ID of the Fast Approximate Anti-Aliasing post process;
  109409. */
  109410. readonly FxaaPostProcessId: string;
  109411. /**
  109412. * ID of the chromatic aberration post process,
  109413. */
  109414. private readonly ChromaticAberrationPostProcessId;
  109415. /**
  109416. * ID of the grain post process
  109417. */
  109418. private readonly GrainPostProcessId;
  109419. /**
  109420. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109421. */
  109422. sharpen: SharpenPostProcess;
  109423. private _sharpenEffect;
  109424. private bloom;
  109425. /**
  109426. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109427. */
  109428. depthOfField: DepthOfFieldEffect;
  109429. /**
  109430. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109431. */
  109432. fxaa: FxaaPostProcess;
  109433. /**
  109434. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109435. */
  109436. imageProcessing: ImageProcessingPostProcess;
  109437. /**
  109438. * Chromatic aberration post process which will shift rgb colors in the image
  109439. */
  109440. chromaticAberration: ChromaticAberrationPostProcess;
  109441. private _chromaticAberrationEffect;
  109442. /**
  109443. * Grain post process which add noise to the image
  109444. */
  109445. grain: GrainPostProcess;
  109446. private _grainEffect;
  109447. /**
  109448. * Glow post process which adds a glow to emissive areas of the image
  109449. */
  109450. private _glowLayer;
  109451. /**
  109452. * Animations which can be used to tweak settings over a period of time
  109453. */
  109454. animations: Animation[];
  109455. private _imageProcessingConfigurationObserver;
  109456. private _sharpenEnabled;
  109457. private _bloomEnabled;
  109458. private _depthOfFieldEnabled;
  109459. private _depthOfFieldBlurLevel;
  109460. private _fxaaEnabled;
  109461. private _imageProcessingEnabled;
  109462. private _defaultPipelineTextureType;
  109463. private _bloomScale;
  109464. private _chromaticAberrationEnabled;
  109465. private _grainEnabled;
  109466. private _buildAllowed;
  109467. /**
  109468. * Gets active scene
  109469. */
  109470. readonly scene: Scene;
  109471. /**
  109472. * Enable or disable the sharpen process from the pipeline
  109473. */
  109474. sharpenEnabled: boolean;
  109475. private _resizeObserver;
  109476. private _hardwareScaleLevel;
  109477. private _bloomKernel;
  109478. /**
  109479. * Specifies the size of the bloom blur kernel, relative to the final output size
  109480. */
  109481. bloomKernel: number;
  109482. /**
  109483. * Specifies the weight of the bloom in the final rendering
  109484. */
  109485. private _bloomWeight;
  109486. /**
  109487. * Specifies the luma threshold for the area that will be blurred by the bloom
  109488. */
  109489. private _bloomThreshold;
  109490. private _hdr;
  109491. /**
  109492. * The strength of the bloom.
  109493. */
  109494. bloomWeight: number;
  109495. /**
  109496. * The strength of the bloom.
  109497. */
  109498. bloomThreshold: number;
  109499. /**
  109500. * The scale of the bloom, lower value will provide better performance.
  109501. */
  109502. bloomScale: number;
  109503. /**
  109504. * Enable or disable the bloom from the pipeline
  109505. */
  109506. bloomEnabled: boolean;
  109507. private _rebuildBloom;
  109508. /**
  109509. * If the depth of field is enabled.
  109510. */
  109511. depthOfFieldEnabled: boolean;
  109512. /**
  109513. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109514. */
  109515. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109516. /**
  109517. * If the anti aliasing is enabled.
  109518. */
  109519. fxaaEnabled: boolean;
  109520. private _samples;
  109521. /**
  109522. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109523. */
  109524. samples: number;
  109525. /**
  109526. * If image processing is enabled.
  109527. */
  109528. imageProcessingEnabled: boolean;
  109529. /**
  109530. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109531. */
  109532. glowLayerEnabled: boolean;
  109533. /**
  109534. * Enable or disable the chromaticAberration process from the pipeline
  109535. */
  109536. chromaticAberrationEnabled: boolean;
  109537. /**
  109538. * Enable or disable the grain process from the pipeline
  109539. */
  109540. grainEnabled: boolean;
  109541. /**
  109542. * @constructor
  109543. * @param name - The rendering pipeline name (default: "")
  109544. * @param hdr - If high dynamic range textures should be used (default: true)
  109545. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109546. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109547. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109548. */
  109549. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109550. /**
  109551. * Get the class name
  109552. * @returns "DefaultRenderingPipeline"
  109553. */
  109554. getClassName(): string;
  109555. /**
  109556. * Force the compilation of the entire pipeline.
  109557. */
  109558. prepare(): void;
  109559. private _hasCleared;
  109560. private _prevPostProcess;
  109561. private _prevPrevPostProcess;
  109562. private _setAutoClearAndTextureSharing;
  109563. private _depthOfFieldSceneObserver;
  109564. private _buildPipeline;
  109565. private _disposePostProcesses;
  109566. /**
  109567. * Adds a camera to the pipeline
  109568. * @param camera the camera to be added
  109569. */
  109570. addCamera(camera: Camera): void;
  109571. /**
  109572. * Removes a camera from the pipeline
  109573. * @param camera the camera to remove
  109574. */
  109575. removeCamera(camera: Camera): void;
  109576. /**
  109577. * Dispose of the pipeline and stop all post processes
  109578. */
  109579. dispose(): void;
  109580. /**
  109581. * Serialize the rendering pipeline (Used when exporting)
  109582. * @returns the serialized object
  109583. */
  109584. serialize(): any;
  109585. /**
  109586. * Parse the serialized pipeline
  109587. * @param source Source pipeline.
  109588. * @param scene The scene to load the pipeline to.
  109589. * @param rootUrl The URL of the serialized pipeline.
  109590. * @returns An instantiated pipeline from the serialized object.
  109591. */
  109592. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109593. }
  109594. }
  109595. declare module BABYLON {
  109596. /** @hidden */
  109597. export var lensHighlightsPixelShader: {
  109598. name: string;
  109599. shader: string;
  109600. };
  109601. }
  109602. declare module BABYLON {
  109603. /** @hidden */
  109604. export var depthOfFieldPixelShader: {
  109605. name: string;
  109606. shader: string;
  109607. };
  109608. }
  109609. declare module BABYLON {
  109610. /**
  109611. * BABYLON.JS Chromatic Aberration GLSL Shader
  109612. * Author: Olivier Guyot
  109613. * Separates very slightly R, G and B colors on the edges of the screen
  109614. * Inspired by Francois Tarlier & Martins Upitis
  109615. */
  109616. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109617. /**
  109618. * @ignore
  109619. * The chromatic aberration PostProcess id in the pipeline
  109620. */
  109621. LensChromaticAberrationEffect: string;
  109622. /**
  109623. * @ignore
  109624. * The highlights enhancing PostProcess id in the pipeline
  109625. */
  109626. HighlightsEnhancingEffect: string;
  109627. /**
  109628. * @ignore
  109629. * The depth-of-field PostProcess id in the pipeline
  109630. */
  109631. LensDepthOfFieldEffect: string;
  109632. private _scene;
  109633. private _depthTexture;
  109634. private _grainTexture;
  109635. private _chromaticAberrationPostProcess;
  109636. private _highlightsPostProcess;
  109637. private _depthOfFieldPostProcess;
  109638. private _edgeBlur;
  109639. private _grainAmount;
  109640. private _chromaticAberration;
  109641. private _distortion;
  109642. private _highlightsGain;
  109643. private _highlightsThreshold;
  109644. private _dofDistance;
  109645. private _dofAperture;
  109646. private _dofDarken;
  109647. private _dofPentagon;
  109648. private _blurNoise;
  109649. /**
  109650. * @constructor
  109651. *
  109652. * Effect parameters are as follow:
  109653. * {
  109654. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109655. * edge_blur: number; // from 0 to x (1 for realism)
  109656. * distortion: number; // from 0 to x (1 for realism)
  109657. * grain_amount: number; // from 0 to 1
  109658. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109659. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109660. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109661. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109662. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109663. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109664. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109665. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109666. * }
  109667. * Note: if an effect parameter is unset, effect is disabled
  109668. *
  109669. * @param name The rendering pipeline name
  109670. * @param parameters - An object containing all parameters (see above)
  109671. * @param scene The scene linked to this pipeline
  109672. * @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)
  109673. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109674. */
  109675. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109676. /**
  109677. * Sets the amount of blur at the edges
  109678. * @param amount blur amount
  109679. */
  109680. setEdgeBlur(amount: number): void;
  109681. /**
  109682. * Sets edge blur to 0
  109683. */
  109684. disableEdgeBlur(): void;
  109685. /**
  109686. * Sets the amout of grain
  109687. * @param amount Amount of grain
  109688. */
  109689. setGrainAmount(amount: number): void;
  109690. /**
  109691. * Set grain amount to 0
  109692. */
  109693. disableGrain(): void;
  109694. /**
  109695. * Sets the chromatic aberration amount
  109696. * @param amount amount of chromatic aberration
  109697. */
  109698. setChromaticAberration(amount: number): void;
  109699. /**
  109700. * Sets chromatic aberration amount to 0
  109701. */
  109702. disableChromaticAberration(): void;
  109703. /**
  109704. * Sets the EdgeDistortion amount
  109705. * @param amount amount of EdgeDistortion
  109706. */
  109707. setEdgeDistortion(amount: number): void;
  109708. /**
  109709. * Sets edge distortion to 0
  109710. */
  109711. disableEdgeDistortion(): void;
  109712. /**
  109713. * Sets the FocusDistance amount
  109714. * @param amount amount of FocusDistance
  109715. */
  109716. setFocusDistance(amount: number): void;
  109717. /**
  109718. * Disables depth of field
  109719. */
  109720. disableDepthOfField(): void;
  109721. /**
  109722. * Sets the Aperture amount
  109723. * @param amount amount of Aperture
  109724. */
  109725. setAperture(amount: number): void;
  109726. /**
  109727. * Sets the DarkenOutOfFocus amount
  109728. * @param amount amount of DarkenOutOfFocus
  109729. */
  109730. setDarkenOutOfFocus(amount: number): void;
  109731. /**
  109732. * Creates a pentagon bokeh effect
  109733. */
  109734. enablePentagonBokeh(): void;
  109735. /**
  109736. * Disables the pentagon bokeh effect
  109737. */
  109738. disablePentagonBokeh(): void;
  109739. /**
  109740. * Enables noise blur
  109741. */
  109742. enableNoiseBlur(): void;
  109743. /**
  109744. * Disables noise blur
  109745. */
  109746. disableNoiseBlur(): void;
  109747. /**
  109748. * Sets the HighlightsGain amount
  109749. * @param amount amount of HighlightsGain
  109750. */
  109751. setHighlightsGain(amount: number): void;
  109752. /**
  109753. * Sets the HighlightsThreshold amount
  109754. * @param amount amount of HighlightsThreshold
  109755. */
  109756. setHighlightsThreshold(amount: number): void;
  109757. /**
  109758. * Disables highlights
  109759. */
  109760. disableHighlights(): void;
  109761. /**
  109762. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  109763. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  109764. */
  109765. dispose(disableDepthRender?: boolean): void;
  109766. private _createChromaticAberrationPostProcess;
  109767. private _createHighlightsPostProcess;
  109768. private _createDepthOfFieldPostProcess;
  109769. private _createGrainTexture;
  109770. }
  109771. }
  109772. declare module BABYLON {
  109773. /** @hidden */
  109774. export var ssao2PixelShader: {
  109775. name: string;
  109776. shader: string;
  109777. };
  109778. }
  109779. declare module BABYLON {
  109780. /** @hidden */
  109781. export var ssaoCombinePixelShader: {
  109782. name: string;
  109783. shader: string;
  109784. };
  109785. }
  109786. declare module BABYLON {
  109787. /**
  109788. * Render pipeline to produce ssao effect
  109789. */
  109790. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109791. /**
  109792. * @ignore
  109793. * The PassPostProcess id in the pipeline that contains the original scene color
  109794. */
  109795. SSAOOriginalSceneColorEffect: string;
  109796. /**
  109797. * @ignore
  109798. * The SSAO PostProcess id in the pipeline
  109799. */
  109800. SSAORenderEffect: string;
  109801. /**
  109802. * @ignore
  109803. * The horizontal blur PostProcess id in the pipeline
  109804. */
  109805. SSAOBlurHRenderEffect: string;
  109806. /**
  109807. * @ignore
  109808. * The vertical blur PostProcess id in the pipeline
  109809. */
  109810. SSAOBlurVRenderEffect: string;
  109811. /**
  109812. * @ignore
  109813. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109814. */
  109815. SSAOCombineRenderEffect: string;
  109816. /**
  109817. * The output strength of the SSAO post-process. Default value is 1.0.
  109818. */
  109819. totalStrength: number;
  109820. /**
  109821. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109822. */
  109823. maxZ: number;
  109824. /**
  109825. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109826. */
  109827. minZAspect: number;
  109828. private _samples;
  109829. /**
  109830. * Number of samples used for the SSAO calculations. Default value is 8
  109831. */
  109832. samples: number;
  109833. private _textureSamples;
  109834. /**
  109835. * Number of samples to use for antialiasing
  109836. */
  109837. textureSamples: number;
  109838. /**
  109839. * Ratio object used for SSAO ratio and blur ratio
  109840. */
  109841. private _ratio;
  109842. /**
  109843. * Dynamically generated sphere sampler.
  109844. */
  109845. private _sampleSphere;
  109846. /**
  109847. * Blur filter offsets
  109848. */
  109849. private _samplerOffsets;
  109850. private _expensiveBlur;
  109851. /**
  109852. * If bilateral blur should be used
  109853. */
  109854. expensiveBlur: boolean;
  109855. /**
  109856. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109857. */
  109858. radius: number;
  109859. /**
  109860. * The base color of the SSAO post-process
  109861. * The final result is "base + ssao" between [0, 1]
  109862. */
  109863. base: number;
  109864. /**
  109865. * Support test.
  109866. */
  109867. static readonly IsSupported: boolean;
  109868. private _scene;
  109869. private _depthTexture;
  109870. private _normalTexture;
  109871. private _randomTexture;
  109872. private _originalColorPostProcess;
  109873. private _ssaoPostProcess;
  109874. private _blurHPostProcess;
  109875. private _blurVPostProcess;
  109876. private _ssaoCombinePostProcess;
  109877. private _firstUpdate;
  109878. /**
  109879. * Gets active scene
  109880. */
  109881. readonly scene: Scene;
  109882. /**
  109883. * @constructor
  109884. * @param name The rendering pipeline name
  109885. * @param scene The scene linked to this pipeline
  109886. * @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 }
  109887. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109888. */
  109889. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109890. /**
  109891. * Get the class name
  109892. * @returns "SSAO2RenderingPipeline"
  109893. */
  109894. getClassName(): string;
  109895. /**
  109896. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109897. */
  109898. dispose(disableGeometryBufferRenderer?: boolean): void;
  109899. private _createBlurPostProcess;
  109900. /** @hidden */
  109901. _rebuild(): void;
  109902. private _bits;
  109903. private _radicalInverse_VdC;
  109904. private _hammersley;
  109905. private _hemisphereSample_uniform;
  109906. private _generateHemisphere;
  109907. private _createSSAOPostProcess;
  109908. private _createSSAOCombinePostProcess;
  109909. private _createRandomTexture;
  109910. /**
  109911. * Serialize the rendering pipeline (Used when exporting)
  109912. * @returns the serialized object
  109913. */
  109914. serialize(): any;
  109915. /**
  109916. * Parse the serialized pipeline
  109917. * @param source Source pipeline.
  109918. * @param scene The scene to load the pipeline to.
  109919. * @param rootUrl The URL of the serialized pipeline.
  109920. * @returns An instantiated pipeline from the serialized object.
  109921. */
  109922. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109923. }
  109924. }
  109925. declare module BABYLON {
  109926. /** @hidden */
  109927. export var ssaoPixelShader: {
  109928. name: string;
  109929. shader: string;
  109930. };
  109931. }
  109932. declare module BABYLON {
  109933. /**
  109934. * Render pipeline to produce ssao effect
  109935. */
  109936. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109937. /**
  109938. * @ignore
  109939. * The PassPostProcess id in the pipeline that contains the original scene color
  109940. */
  109941. SSAOOriginalSceneColorEffect: string;
  109942. /**
  109943. * @ignore
  109944. * The SSAO PostProcess id in the pipeline
  109945. */
  109946. SSAORenderEffect: string;
  109947. /**
  109948. * @ignore
  109949. * The horizontal blur PostProcess id in the pipeline
  109950. */
  109951. SSAOBlurHRenderEffect: string;
  109952. /**
  109953. * @ignore
  109954. * The vertical blur PostProcess id in the pipeline
  109955. */
  109956. SSAOBlurVRenderEffect: string;
  109957. /**
  109958. * @ignore
  109959. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109960. */
  109961. SSAOCombineRenderEffect: string;
  109962. /**
  109963. * The output strength of the SSAO post-process. Default value is 1.0.
  109964. */
  109965. totalStrength: number;
  109966. /**
  109967. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109968. */
  109969. radius: number;
  109970. /**
  109971. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109972. * Must not be equal to fallOff and superior to fallOff.
  109973. * Default value is 0.0075
  109974. */
  109975. area: number;
  109976. /**
  109977. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109978. * Must not be equal to area and inferior to area.
  109979. * Default value is 0.000001
  109980. */
  109981. fallOff: number;
  109982. /**
  109983. * The base color of the SSAO post-process
  109984. * The final result is "base + ssao" between [0, 1]
  109985. */
  109986. base: number;
  109987. private _scene;
  109988. private _depthTexture;
  109989. private _randomTexture;
  109990. private _originalColorPostProcess;
  109991. private _ssaoPostProcess;
  109992. private _blurHPostProcess;
  109993. private _blurVPostProcess;
  109994. private _ssaoCombinePostProcess;
  109995. private _firstUpdate;
  109996. /**
  109997. * Gets active scene
  109998. */
  109999. readonly scene: Scene;
  110000. /**
  110001. * @constructor
  110002. * @param name - The rendering pipeline name
  110003. * @param scene - The scene linked to this pipeline
  110004. * @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 }
  110005. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  110006. */
  110007. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  110008. /**
  110009. * Get the class name
  110010. * @returns "SSAORenderingPipeline"
  110011. */
  110012. getClassName(): string;
  110013. /**
  110014. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  110015. */
  110016. dispose(disableDepthRender?: boolean): void;
  110017. private _createBlurPostProcess;
  110018. /** @hidden */
  110019. _rebuild(): void;
  110020. private _createSSAOPostProcess;
  110021. private _createSSAOCombinePostProcess;
  110022. private _createRandomTexture;
  110023. }
  110024. }
  110025. declare module BABYLON {
  110026. /** @hidden */
  110027. export var standardPixelShader: {
  110028. name: string;
  110029. shader: string;
  110030. };
  110031. }
  110032. declare module BABYLON {
  110033. /**
  110034. * Standard rendering pipeline
  110035. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110036. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  110037. */
  110038. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110039. /**
  110040. * Public members
  110041. */
  110042. /**
  110043. * Post-process which contains the original scene color before the pipeline applies all the effects
  110044. */
  110045. originalPostProcess: Nullable<PostProcess>;
  110046. /**
  110047. * Post-process used to down scale an image x4
  110048. */
  110049. downSampleX4PostProcess: Nullable<PostProcess>;
  110050. /**
  110051. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  110052. */
  110053. brightPassPostProcess: Nullable<PostProcess>;
  110054. /**
  110055. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  110056. */
  110057. blurHPostProcesses: PostProcess[];
  110058. /**
  110059. * Post-process array storing all the vertical blur post-processes used by the pipeline
  110060. */
  110061. blurVPostProcesses: PostProcess[];
  110062. /**
  110063. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  110064. */
  110065. textureAdderPostProcess: Nullable<PostProcess>;
  110066. /**
  110067. * Post-process used to create volumetric lighting effect
  110068. */
  110069. volumetricLightPostProcess: Nullable<PostProcess>;
  110070. /**
  110071. * Post-process used to smooth the previous volumetric light post-process on the X axis
  110072. */
  110073. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  110074. /**
  110075. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  110076. */
  110077. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  110078. /**
  110079. * Post-process used to merge the volumetric light effect and the real scene color
  110080. */
  110081. volumetricLightMergePostProces: Nullable<PostProcess>;
  110082. /**
  110083. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  110084. */
  110085. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  110086. /**
  110087. * Base post-process used to calculate the average luminance of the final image for HDR
  110088. */
  110089. luminancePostProcess: Nullable<PostProcess>;
  110090. /**
  110091. * Post-processes used to create down sample post-processes in order to get
  110092. * the average luminance of the final image for HDR
  110093. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  110094. */
  110095. luminanceDownSamplePostProcesses: PostProcess[];
  110096. /**
  110097. * Post-process used to create a HDR effect (light adaptation)
  110098. */
  110099. hdrPostProcess: Nullable<PostProcess>;
  110100. /**
  110101. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  110102. */
  110103. textureAdderFinalPostProcess: Nullable<PostProcess>;
  110104. /**
  110105. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  110106. */
  110107. lensFlareFinalPostProcess: Nullable<PostProcess>;
  110108. /**
  110109. * Post-process used to merge the final HDR post-process and the real scene color
  110110. */
  110111. hdrFinalPostProcess: Nullable<PostProcess>;
  110112. /**
  110113. * Post-process used to create a lens flare effect
  110114. */
  110115. lensFlarePostProcess: Nullable<PostProcess>;
  110116. /**
  110117. * Post-process that merges the result of the lens flare post-process and the real scene color
  110118. */
  110119. lensFlareComposePostProcess: Nullable<PostProcess>;
  110120. /**
  110121. * Post-process used to create a motion blur effect
  110122. */
  110123. motionBlurPostProcess: Nullable<PostProcess>;
  110124. /**
  110125. * Post-process used to create a depth of field effect
  110126. */
  110127. depthOfFieldPostProcess: Nullable<PostProcess>;
  110128. /**
  110129. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110130. */
  110131. fxaaPostProcess: Nullable<FxaaPostProcess>;
  110132. /**
  110133. * Represents the brightness threshold in order to configure the illuminated surfaces
  110134. */
  110135. brightThreshold: number;
  110136. /**
  110137. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  110138. */
  110139. blurWidth: number;
  110140. /**
  110141. * Sets if the blur for highlighted surfaces must be only horizontal
  110142. */
  110143. horizontalBlur: boolean;
  110144. /**
  110145. * Sets the overall exposure used by the pipeline
  110146. */
  110147. exposure: number;
  110148. /**
  110149. * Texture used typically to simulate "dirty" on camera lens
  110150. */
  110151. lensTexture: Nullable<Texture>;
  110152. /**
  110153. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  110154. */
  110155. volumetricLightCoefficient: number;
  110156. /**
  110157. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  110158. */
  110159. volumetricLightPower: number;
  110160. /**
  110161. * Used the set the blur intensity to smooth the volumetric lights
  110162. */
  110163. volumetricLightBlurScale: number;
  110164. /**
  110165. * Light (spot or directional) used to generate the volumetric lights rays
  110166. * The source light must have a shadow generate so the pipeline can get its
  110167. * depth map
  110168. */
  110169. sourceLight: Nullable<SpotLight | DirectionalLight>;
  110170. /**
  110171. * For eye adaptation, represents the minimum luminance the eye can see
  110172. */
  110173. hdrMinimumLuminance: number;
  110174. /**
  110175. * For eye adaptation, represents the decrease luminance speed
  110176. */
  110177. hdrDecreaseRate: number;
  110178. /**
  110179. * For eye adaptation, represents the increase luminance speed
  110180. */
  110181. hdrIncreaseRate: number;
  110182. /**
  110183. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  110184. */
  110185. lensColorTexture: Nullable<Texture>;
  110186. /**
  110187. * The overall strengh for the lens flare effect
  110188. */
  110189. lensFlareStrength: number;
  110190. /**
  110191. * Dispersion coefficient for lens flare ghosts
  110192. */
  110193. lensFlareGhostDispersal: number;
  110194. /**
  110195. * Main lens flare halo width
  110196. */
  110197. lensFlareHaloWidth: number;
  110198. /**
  110199. * Based on the lens distortion effect, defines how much the lens flare result
  110200. * is distorted
  110201. */
  110202. lensFlareDistortionStrength: number;
  110203. /**
  110204. * Lens star texture must be used to simulate rays on the flares and is available
  110205. * in the documentation
  110206. */
  110207. lensStarTexture: Nullable<Texture>;
  110208. /**
  110209. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  110210. * flare effect by taking account of the dirt texture
  110211. */
  110212. lensFlareDirtTexture: Nullable<Texture>;
  110213. /**
  110214. * Represents the focal length for the depth of field effect
  110215. */
  110216. depthOfFieldDistance: number;
  110217. /**
  110218. * Represents the blur intensity for the blurred part of the depth of field effect
  110219. */
  110220. depthOfFieldBlurWidth: number;
  110221. /**
  110222. * For motion blur, defines how much the image is blurred by the movement
  110223. */
  110224. motionStrength: number;
  110225. /**
  110226. * List of animations for the pipeline (IAnimatable implementation)
  110227. */
  110228. animations: Animation[];
  110229. /**
  110230. * Private members
  110231. */
  110232. private _scene;
  110233. private _currentDepthOfFieldSource;
  110234. private _basePostProcess;
  110235. private _hdrCurrentLuminance;
  110236. private _floatTextureType;
  110237. private _ratio;
  110238. private _bloomEnabled;
  110239. private _depthOfFieldEnabled;
  110240. private _vlsEnabled;
  110241. private _lensFlareEnabled;
  110242. private _hdrEnabled;
  110243. private _motionBlurEnabled;
  110244. private _fxaaEnabled;
  110245. private _motionBlurSamples;
  110246. private _volumetricLightStepsCount;
  110247. private _samples;
  110248. /**
  110249. * @ignore
  110250. * Specifies if the bloom pipeline is enabled
  110251. */
  110252. BloomEnabled: boolean;
  110253. /**
  110254. * @ignore
  110255. * Specifies if the depth of field pipeline is enabed
  110256. */
  110257. DepthOfFieldEnabled: boolean;
  110258. /**
  110259. * @ignore
  110260. * Specifies if the lens flare pipeline is enabed
  110261. */
  110262. LensFlareEnabled: boolean;
  110263. /**
  110264. * @ignore
  110265. * Specifies if the HDR pipeline is enabled
  110266. */
  110267. HDREnabled: boolean;
  110268. /**
  110269. * @ignore
  110270. * Specifies if the volumetric lights scattering effect is enabled
  110271. */
  110272. VLSEnabled: boolean;
  110273. /**
  110274. * @ignore
  110275. * Specifies if the motion blur effect is enabled
  110276. */
  110277. MotionBlurEnabled: boolean;
  110278. /**
  110279. * Specifies if anti-aliasing is enabled
  110280. */
  110281. fxaaEnabled: boolean;
  110282. /**
  110283. * Specifies the number of steps used to calculate the volumetric lights
  110284. * Typically in interval [50, 200]
  110285. */
  110286. volumetricLightStepsCount: number;
  110287. /**
  110288. * Specifies the number of samples used for the motion blur effect
  110289. * Typically in interval [16, 64]
  110290. */
  110291. motionBlurSamples: number;
  110292. /**
  110293. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110294. */
  110295. samples: number;
  110296. /**
  110297. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110298. * @constructor
  110299. * @param name The rendering pipeline name
  110300. * @param scene The scene linked to this pipeline
  110301. * @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)
  110302. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110303. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110304. */
  110305. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110306. private _buildPipeline;
  110307. private _createDownSampleX4PostProcess;
  110308. private _createBrightPassPostProcess;
  110309. private _createBlurPostProcesses;
  110310. private _createTextureAdderPostProcess;
  110311. private _createVolumetricLightPostProcess;
  110312. private _createLuminancePostProcesses;
  110313. private _createHdrPostProcess;
  110314. private _createLensFlarePostProcess;
  110315. private _createDepthOfFieldPostProcess;
  110316. private _createMotionBlurPostProcess;
  110317. private _getDepthTexture;
  110318. private _disposePostProcesses;
  110319. /**
  110320. * Dispose of the pipeline and stop all post processes
  110321. */
  110322. dispose(): void;
  110323. /**
  110324. * Serialize the rendering pipeline (Used when exporting)
  110325. * @returns the serialized object
  110326. */
  110327. serialize(): any;
  110328. /**
  110329. * Parse the serialized pipeline
  110330. * @param source Source pipeline.
  110331. * @param scene The scene to load the pipeline to.
  110332. * @param rootUrl The URL of the serialized pipeline.
  110333. * @returns An instantiated pipeline from the serialized object.
  110334. */
  110335. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110336. /**
  110337. * Luminance steps
  110338. */
  110339. static LuminanceSteps: number;
  110340. }
  110341. }
  110342. declare module BABYLON {
  110343. /** @hidden */
  110344. export var tonemapPixelShader: {
  110345. name: string;
  110346. shader: string;
  110347. };
  110348. }
  110349. declare module BABYLON {
  110350. /** Defines operator used for tonemapping */
  110351. export enum TonemappingOperator {
  110352. /** Hable */
  110353. Hable = 0,
  110354. /** Reinhard */
  110355. Reinhard = 1,
  110356. /** HejiDawson */
  110357. HejiDawson = 2,
  110358. /** Photographic */
  110359. Photographic = 3
  110360. }
  110361. /**
  110362. * Defines a post process to apply tone mapping
  110363. */
  110364. export class TonemapPostProcess extends PostProcess {
  110365. private _operator;
  110366. /** Defines the required exposure adjustement */
  110367. exposureAdjustment: number;
  110368. /**
  110369. * Creates a new TonemapPostProcess
  110370. * @param name defines the name of the postprocess
  110371. * @param _operator defines the operator to use
  110372. * @param exposureAdjustment defines the required exposure adjustement
  110373. * @param camera defines the camera to use (can be null)
  110374. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110375. * @param engine defines the hosting engine (can be ignore if camera is set)
  110376. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110377. */
  110378. constructor(name: string, _operator: TonemappingOperator,
  110379. /** Defines the required exposure adjustement */
  110380. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110381. }
  110382. }
  110383. declare module BABYLON {
  110384. /** @hidden */
  110385. export var depthVertexShader: {
  110386. name: string;
  110387. shader: string;
  110388. };
  110389. }
  110390. declare module BABYLON {
  110391. /** @hidden */
  110392. export var volumetricLightScatteringPixelShader: {
  110393. name: string;
  110394. shader: string;
  110395. };
  110396. }
  110397. declare module BABYLON {
  110398. /** @hidden */
  110399. export var volumetricLightScatteringPassPixelShader: {
  110400. name: string;
  110401. shader: string;
  110402. };
  110403. }
  110404. declare module BABYLON {
  110405. /**
  110406. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110407. */
  110408. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110409. private _volumetricLightScatteringPass;
  110410. private _volumetricLightScatteringRTT;
  110411. private _viewPort;
  110412. private _screenCoordinates;
  110413. private _cachedDefines;
  110414. /**
  110415. * If not undefined, the mesh position is computed from the attached node position
  110416. */
  110417. attachedNode: {
  110418. position: Vector3;
  110419. };
  110420. /**
  110421. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110422. */
  110423. customMeshPosition: Vector3;
  110424. /**
  110425. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110426. */
  110427. useCustomMeshPosition: boolean;
  110428. /**
  110429. * If the post-process should inverse the light scattering direction
  110430. */
  110431. invert: boolean;
  110432. /**
  110433. * The internal mesh used by the post-process
  110434. */
  110435. mesh: Mesh;
  110436. /**
  110437. * @hidden
  110438. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110439. */
  110440. useDiffuseColor: boolean;
  110441. /**
  110442. * Array containing the excluded meshes not rendered in the internal pass
  110443. */
  110444. excludedMeshes: AbstractMesh[];
  110445. /**
  110446. * Controls the overall intensity of the post-process
  110447. */
  110448. exposure: number;
  110449. /**
  110450. * Dissipates each sample's contribution in range [0, 1]
  110451. */
  110452. decay: number;
  110453. /**
  110454. * Controls the overall intensity of each sample
  110455. */
  110456. weight: number;
  110457. /**
  110458. * Controls the density of each sample
  110459. */
  110460. density: number;
  110461. /**
  110462. * @constructor
  110463. * @param name The post-process name
  110464. * @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)
  110465. * @param camera The camera that the post-process will be attached to
  110466. * @param mesh The mesh used to create the light scattering
  110467. * @param samples The post-process quality, default 100
  110468. * @param samplingModeThe post-process filtering mode
  110469. * @param engine The babylon engine
  110470. * @param reusable If the post-process is reusable
  110471. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110472. */
  110473. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110474. /**
  110475. * Returns the string "VolumetricLightScatteringPostProcess"
  110476. * @returns "VolumetricLightScatteringPostProcess"
  110477. */
  110478. getClassName(): string;
  110479. private _isReady;
  110480. /**
  110481. * Sets the new light position for light scattering effect
  110482. * @param position The new custom light position
  110483. */
  110484. setCustomMeshPosition(position: Vector3): void;
  110485. /**
  110486. * Returns the light position for light scattering effect
  110487. * @return Vector3 The custom light position
  110488. */
  110489. getCustomMeshPosition(): Vector3;
  110490. /**
  110491. * Disposes the internal assets and detaches the post-process from the camera
  110492. */
  110493. dispose(camera: Camera): void;
  110494. /**
  110495. * Returns the render target texture used by the post-process
  110496. * @return the render target texture used by the post-process
  110497. */
  110498. getPass(): RenderTargetTexture;
  110499. private _meshExcluded;
  110500. private _createPass;
  110501. private _updateMeshScreenCoordinates;
  110502. /**
  110503. * Creates a default mesh for the Volumeric Light Scattering post-process
  110504. * @param name The mesh name
  110505. * @param scene The scene where to create the mesh
  110506. * @return the default mesh
  110507. */
  110508. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110509. }
  110510. }
  110511. declare module BABYLON {
  110512. interface Scene {
  110513. /** @hidden (Backing field) */
  110514. _boundingBoxRenderer: BoundingBoxRenderer;
  110515. /** @hidden (Backing field) */
  110516. _forceShowBoundingBoxes: boolean;
  110517. /**
  110518. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110519. */
  110520. forceShowBoundingBoxes: boolean;
  110521. /**
  110522. * Gets the bounding box renderer associated with the scene
  110523. * @returns a BoundingBoxRenderer
  110524. */
  110525. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110526. }
  110527. interface AbstractMesh {
  110528. /** @hidden (Backing field) */
  110529. _showBoundingBox: boolean;
  110530. /**
  110531. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110532. */
  110533. showBoundingBox: boolean;
  110534. }
  110535. /**
  110536. * Component responsible of rendering the bounding box of the meshes in a scene.
  110537. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110538. */
  110539. export class BoundingBoxRenderer implements ISceneComponent {
  110540. /**
  110541. * The component name helpfull to identify the component in the list of scene components.
  110542. */
  110543. readonly name: string;
  110544. /**
  110545. * The scene the component belongs to.
  110546. */
  110547. scene: Scene;
  110548. /**
  110549. * Color of the bounding box lines placed in front of an object
  110550. */
  110551. frontColor: Color3;
  110552. /**
  110553. * Color of the bounding box lines placed behind an object
  110554. */
  110555. backColor: Color3;
  110556. /**
  110557. * Defines if the renderer should show the back lines or not
  110558. */
  110559. showBackLines: boolean;
  110560. /**
  110561. * @hidden
  110562. */
  110563. renderList: SmartArray<BoundingBox>;
  110564. private _colorShader;
  110565. private _vertexBuffers;
  110566. private _indexBuffer;
  110567. /**
  110568. * Instantiates a new bounding box renderer in a scene.
  110569. * @param scene the scene the renderer renders in
  110570. */
  110571. constructor(scene: Scene);
  110572. /**
  110573. * Registers the component in a given scene
  110574. */
  110575. register(): void;
  110576. private _evaluateSubMesh;
  110577. private _activeMesh;
  110578. private _prepareRessources;
  110579. private _createIndexBuffer;
  110580. /**
  110581. * Rebuilds the elements related to this component in case of
  110582. * context lost for instance.
  110583. */
  110584. rebuild(): void;
  110585. /**
  110586. * @hidden
  110587. */
  110588. reset(): void;
  110589. /**
  110590. * Render the bounding boxes of a specific rendering group
  110591. * @param renderingGroupId defines the rendering group to render
  110592. */
  110593. render(renderingGroupId: number): void;
  110594. /**
  110595. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110596. * @param mesh Define the mesh to render the occlusion bounding box for
  110597. */
  110598. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110599. /**
  110600. * Dispose and release the resources attached to this renderer.
  110601. */
  110602. dispose(): void;
  110603. }
  110604. }
  110605. declare module BABYLON {
  110606. /** @hidden */
  110607. export var depthPixelShader: {
  110608. name: string;
  110609. shader: string;
  110610. };
  110611. }
  110612. declare module BABYLON {
  110613. /**
  110614. * This represents a depth renderer in Babylon.
  110615. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110616. */
  110617. export class DepthRenderer {
  110618. private _scene;
  110619. private _depthMap;
  110620. private _effect;
  110621. private _cachedDefines;
  110622. private _camera;
  110623. /**
  110624. * Specifiess that the depth renderer will only be used within
  110625. * the camera it is created for.
  110626. * This can help forcing its rendering during the camera processing.
  110627. */
  110628. useOnlyInActiveCamera: boolean;
  110629. /** @hidden */
  110630. static _SceneComponentInitialization: (scene: Scene) => void;
  110631. /**
  110632. * Instantiates a depth renderer
  110633. * @param scene The scene the renderer belongs to
  110634. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110635. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110636. */
  110637. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110638. /**
  110639. * Creates the depth rendering effect and checks if the effect is ready.
  110640. * @param subMesh The submesh to be used to render the depth map of
  110641. * @param useInstances If multiple world instances should be used
  110642. * @returns if the depth renderer is ready to render the depth map
  110643. */
  110644. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110645. /**
  110646. * Gets the texture which the depth map will be written to.
  110647. * @returns The depth map texture
  110648. */
  110649. getDepthMap(): RenderTargetTexture;
  110650. /**
  110651. * Disposes of the depth renderer.
  110652. */
  110653. dispose(): void;
  110654. }
  110655. }
  110656. declare module BABYLON {
  110657. interface Scene {
  110658. /** @hidden (Backing field) */
  110659. _depthRenderer: {
  110660. [id: string]: DepthRenderer;
  110661. };
  110662. /**
  110663. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110664. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110665. * @returns the created depth renderer
  110666. */
  110667. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110668. /**
  110669. * Disables a depth renderer for a given camera
  110670. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110671. */
  110672. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110673. }
  110674. /**
  110675. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110676. * in several rendering techniques.
  110677. */
  110678. export class DepthRendererSceneComponent implements ISceneComponent {
  110679. /**
  110680. * The component name helpfull to identify the component in the list of scene components.
  110681. */
  110682. readonly name: string;
  110683. /**
  110684. * The scene the component belongs to.
  110685. */
  110686. scene: Scene;
  110687. /**
  110688. * Creates a new instance of the component for the given scene
  110689. * @param scene Defines the scene to register the component in
  110690. */
  110691. constructor(scene: Scene);
  110692. /**
  110693. * Registers the component in a given scene
  110694. */
  110695. register(): void;
  110696. /**
  110697. * Rebuilds the elements related to this component in case of
  110698. * context lost for instance.
  110699. */
  110700. rebuild(): void;
  110701. /**
  110702. * Disposes the component and the associated ressources
  110703. */
  110704. dispose(): void;
  110705. private _gatherRenderTargets;
  110706. private _gatherActiveCameraRenderTargets;
  110707. }
  110708. }
  110709. declare module BABYLON {
  110710. /** @hidden */
  110711. export var outlinePixelShader: {
  110712. name: string;
  110713. shader: string;
  110714. };
  110715. }
  110716. declare module BABYLON {
  110717. /** @hidden */
  110718. export var outlineVertexShader: {
  110719. name: string;
  110720. shader: string;
  110721. };
  110722. }
  110723. declare module BABYLON {
  110724. interface Scene {
  110725. /** @hidden */
  110726. _outlineRenderer: OutlineRenderer;
  110727. /**
  110728. * Gets the outline renderer associated with the scene
  110729. * @returns a OutlineRenderer
  110730. */
  110731. getOutlineRenderer(): OutlineRenderer;
  110732. }
  110733. interface AbstractMesh {
  110734. /** @hidden (Backing field) */
  110735. _renderOutline: boolean;
  110736. /**
  110737. * Gets or sets a boolean indicating if the outline must be rendered as well
  110738. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110739. */
  110740. renderOutline: boolean;
  110741. /** @hidden (Backing field) */
  110742. _renderOverlay: boolean;
  110743. /**
  110744. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110745. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110746. */
  110747. renderOverlay: boolean;
  110748. }
  110749. /**
  110750. * This class is responsible to draw bothe outline/overlay of meshes.
  110751. * It should not be used directly but through the available method on mesh.
  110752. */
  110753. export class OutlineRenderer implements ISceneComponent {
  110754. /**
  110755. * The name of the component. Each component must have a unique name.
  110756. */
  110757. name: string;
  110758. /**
  110759. * The scene the component belongs to.
  110760. */
  110761. scene: Scene;
  110762. /**
  110763. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110764. */
  110765. zOffset: number;
  110766. private _engine;
  110767. private _effect;
  110768. private _cachedDefines;
  110769. private _savedDepthWrite;
  110770. /**
  110771. * Instantiates a new outline renderer. (There could be only one per scene).
  110772. * @param scene Defines the scene it belongs to
  110773. */
  110774. constructor(scene: Scene);
  110775. /**
  110776. * Register the component to one instance of a scene.
  110777. */
  110778. register(): void;
  110779. /**
  110780. * Rebuilds the elements related to this component in case of
  110781. * context lost for instance.
  110782. */
  110783. rebuild(): void;
  110784. /**
  110785. * Disposes the component and the associated ressources.
  110786. */
  110787. dispose(): void;
  110788. /**
  110789. * Renders the outline in the canvas.
  110790. * @param subMesh Defines the sumesh to render
  110791. * @param batch Defines the batch of meshes in case of instances
  110792. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110793. */
  110794. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110795. /**
  110796. * Returns whether or not the outline renderer is ready for a given submesh.
  110797. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110798. * @param subMesh Defines the submesh to check readyness for
  110799. * @param useInstances Defines wheter wee are trying to render instances or not
  110800. * @returns true if ready otherwise false
  110801. */
  110802. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110803. private _beforeRenderingMesh;
  110804. private _afterRenderingMesh;
  110805. }
  110806. }
  110807. declare module BABYLON {
  110808. /**
  110809. * Defines the list of states available for a task inside a AssetsManager
  110810. */
  110811. export enum AssetTaskState {
  110812. /**
  110813. * Initialization
  110814. */
  110815. INIT = 0,
  110816. /**
  110817. * Running
  110818. */
  110819. RUNNING = 1,
  110820. /**
  110821. * Done
  110822. */
  110823. DONE = 2,
  110824. /**
  110825. * Error
  110826. */
  110827. ERROR = 3
  110828. }
  110829. /**
  110830. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110831. */
  110832. export abstract class AbstractAssetTask {
  110833. /**
  110834. * Task name
  110835. */ name: string;
  110836. /**
  110837. * Callback called when the task is successful
  110838. */
  110839. onSuccess: (task: any) => void;
  110840. /**
  110841. * Callback called when the task is not successful
  110842. */
  110843. onError: (task: any, message?: string, exception?: any) => void;
  110844. /**
  110845. * Creates a new AssetsManager
  110846. * @param name defines the name of the task
  110847. */
  110848. constructor(
  110849. /**
  110850. * Task name
  110851. */ name: string);
  110852. private _isCompleted;
  110853. private _taskState;
  110854. private _errorObject;
  110855. /**
  110856. * Get if the task is completed
  110857. */
  110858. readonly isCompleted: boolean;
  110859. /**
  110860. * Gets the current state of the task
  110861. */
  110862. readonly taskState: AssetTaskState;
  110863. /**
  110864. * Gets the current error object (if task is in error)
  110865. */
  110866. readonly errorObject: {
  110867. message?: string;
  110868. exception?: any;
  110869. };
  110870. /**
  110871. * Internal only
  110872. * @hidden
  110873. */
  110874. _setErrorObject(message?: string, exception?: any): void;
  110875. /**
  110876. * Execute the current task
  110877. * @param scene defines the scene where you want your assets to be loaded
  110878. * @param onSuccess is a callback called when the task is successfully executed
  110879. * @param onError is a callback called if an error occurs
  110880. */
  110881. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110882. /**
  110883. * Execute the current task
  110884. * @param scene defines the scene where you want your assets to be loaded
  110885. * @param onSuccess is a callback called when the task is successfully executed
  110886. * @param onError is a callback called if an error occurs
  110887. */
  110888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110889. /**
  110890. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110891. * This can be used with failed tasks that have the reason for failure fixed.
  110892. */
  110893. reset(): void;
  110894. private onErrorCallback;
  110895. private onDoneCallback;
  110896. }
  110897. /**
  110898. * Define the interface used by progress events raised during assets loading
  110899. */
  110900. export interface IAssetsProgressEvent {
  110901. /**
  110902. * Defines the number of remaining tasks to process
  110903. */
  110904. remainingCount: number;
  110905. /**
  110906. * Defines the total number of tasks
  110907. */
  110908. totalCount: number;
  110909. /**
  110910. * Defines the task that was just processed
  110911. */
  110912. task: AbstractAssetTask;
  110913. }
  110914. /**
  110915. * Class used to share progress information about assets loading
  110916. */
  110917. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110918. /**
  110919. * Defines the number of remaining tasks to process
  110920. */
  110921. remainingCount: number;
  110922. /**
  110923. * Defines the total number of tasks
  110924. */
  110925. totalCount: number;
  110926. /**
  110927. * Defines the task that was just processed
  110928. */
  110929. task: AbstractAssetTask;
  110930. /**
  110931. * Creates a AssetsProgressEvent
  110932. * @param remainingCount defines the number of remaining tasks to process
  110933. * @param totalCount defines the total number of tasks
  110934. * @param task defines the task that was just processed
  110935. */
  110936. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110937. }
  110938. /**
  110939. * Define a task used by AssetsManager to load meshes
  110940. */
  110941. export class MeshAssetTask extends AbstractAssetTask {
  110942. /**
  110943. * Defines the name of the task
  110944. */
  110945. name: string;
  110946. /**
  110947. * Defines the list of mesh's names you want to load
  110948. */
  110949. meshesNames: any;
  110950. /**
  110951. * Defines the root url to use as a base to load your meshes and associated resources
  110952. */
  110953. rootUrl: string;
  110954. /**
  110955. * Defines the filename of the scene to load from
  110956. */
  110957. sceneFilename: string;
  110958. /**
  110959. * Gets the list of loaded meshes
  110960. */
  110961. loadedMeshes: Array<AbstractMesh>;
  110962. /**
  110963. * Gets the list of loaded particle systems
  110964. */
  110965. loadedParticleSystems: Array<IParticleSystem>;
  110966. /**
  110967. * Gets the list of loaded skeletons
  110968. */
  110969. loadedSkeletons: Array<Skeleton>;
  110970. /**
  110971. * Gets the list of loaded animation groups
  110972. */
  110973. loadedAnimationGroups: Array<AnimationGroup>;
  110974. /**
  110975. * Callback called when the task is successful
  110976. */
  110977. onSuccess: (task: MeshAssetTask) => void;
  110978. /**
  110979. * Callback called when the task is successful
  110980. */
  110981. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110982. /**
  110983. * Creates a new MeshAssetTask
  110984. * @param name defines the name of the task
  110985. * @param meshesNames defines the list of mesh's names you want to load
  110986. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110987. * @param sceneFilename defines the filename of the scene to load from
  110988. */
  110989. constructor(
  110990. /**
  110991. * Defines the name of the task
  110992. */
  110993. name: string,
  110994. /**
  110995. * Defines the list of mesh's names you want to load
  110996. */
  110997. meshesNames: any,
  110998. /**
  110999. * Defines the root url to use as a base to load your meshes and associated resources
  111000. */
  111001. rootUrl: string,
  111002. /**
  111003. * Defines the filename of the scene to load from
  111004. */
  111005. sceneFilename: string);
  111006. /**
  111007. * Execute the current task
  111008. * @param scene defines the scene where you want your assets to be loaded
  111009. * @param onSuccess is a callback called when the task is successfully executed
  111010. * @param onError is a callback called if an error occurs
  111011. */
  111012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111013. }
  111014. /**
  111015. * Define a task used by AssetsManager to load text content
  111016. */
  111017. export class TextFileAssetTask extends AbstractAssetTask {
  111018. /**
  111019. * Defines the name of the task
  111020. */
  111021. name: string;
  111022. /**
  111023. * Defines the location of the file to load
  111024. */
  111025. url: string;
  111026. /**
  111027. * Gets the loaded text string
  111028. */
  111029. text: string;
  111030. /**
  111031. * Callback called when the task is successful
  111032. */
  111033. onSuccess: (task: TextFileAssetTask) => void;
  111034. /**
  111035. * Callback called when the task is successful
  111036. */
  111037. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  111038. /**
  111039. * Creates a new TextFileAssetTask object
  111040. * @param name defines the name of the task
  111041. * @param url defines the location of the file to load
  111042. */
  111043. constructor(
  111044. /**
  111045. * Defines the name of the task
  111046. */
  111047. name: string,
  111048. /**
  111049. * Defines the location of the file to load
  111050. */
  111051. url: string);
  111052. /**
  111053. * Execute the current task
  111054. * @param scene defines the scene where you want your assets to be loaded
  111055. * @param onSuccess is a callback called when the task is successfully executed
  111056. * @param onError is a callback called if an error occurs
  111057. */
  111058. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111059. }
  111060. /**
  111061. * Define a task used by AssetsManager to load binary data
  111062. */
  111063. export class BinaryFileAssetTask extends AbstractAssetTask {
  111064. /**
  111065. * Defines the name of the task
  111066. */
  111067. name: string;
  111068. /**
  111069. * Defines the location of the file to load
  111070. */
  111071. url: string;
  111072. /**
  111073. * Gets the lodaded data (as an array buffer)
  111074. */
  111075. data: ArrayBuffer;
  111076. /**
  111077. * Callback called when the task is successful
  111078. */
  111079. onSuccess: (task: BinaryFileAssetTask) => void;
  111080. /**
  111081. * Callback called when the task is successful
  111082. */
  111083. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  111084. /**
  111085. * Creates a new BinaryFileAssetTask object
  111086. * @param name defines the name of the new task
  111087. * @param url defines the location of the file to load
  111088. */
  111089. constructor(
  111090. /**
  111091. * Defines the name of the task
  111092. */
  111093. name: string,
  111094. /**
  111095. * Defines the location of the file to load
  111096. */
  111097. url: string);
  111098. /**
  111099. * Execute the current task
  111100. * @param scene defines the scene where you want your assets to be loaded
  111101. * @param onSuccess is a callback called when the task is successfully executed
  111102. * @param onError is a callback called if an error occurs
  111103. */
  111104. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111105. }
  111106. /**
  111107. * Define a task used by AssetsManager to load images
  111108. */
  111109. export class ImageAssetTask extends AbstractAssetTask {
  111110. /**
  111111. * Defines the name of the task
  111112. */
  111113. name: string;
  111114. /**
  111115. * Defines the location of the image to load
  111116. */
  111117. url: string;
  111118. /**
  111119. * Gets the loaded images
  111120. */
  111121. image: HTMLImageElement;
  111122. /**
  111123. * Callback called when the task is successful
  111124. */
  111125. onSuccess: (task: ImageAssetTask) => void;
  111126. /**
  111127. * Callback called when the task is successful
  111128. */
  111129. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  111130. /**
  111131. * Creates a new ImageAssetTask
  111132. * @param name defines the name of the task
  111133. * @param url defines the location of the image to load
  111134. */
  111135. constructor(
  111136. /**
  111137. * Defines the name of the task
  111138. */
  111139. name: string,
  111140. /**
  111141. * Defines the location of the image to load
  111142. */
  111143. url: string);
  111144. /**
  111145. * Execute the current task
  111146. * @param scene defines the scene where you want your assets to be loaded
  111147. * @param onSuccess is a callback called when the task is successfully executed
  111148. * @param onError is a callback called if an error occurs
  111149. */
  111150. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111151. }
  111152. /**
  111153. * Defines the interface used by texture loading tasks
  111154. */
  111155. export interface ITextureAssetTask<TEX extends BaseTexture> {
  111156. /**
  111157. * Gets the loaded texture
  111158. */
  111159. texture: TEX;
  111160. }
  111161. /**
  111162. * Define a task used by AssetsManager to load 2D textures
  111163. */
  111164. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  111165. /**
  111166. * Defines the name of the task
  111167. */
  111168. name: string;
  111169. /**
  111170. * Defines the location of the file to load
  111171. */
  111172. url: string;
  111173. /**
  111174. * Defines if mipmap should not be generated (default is false)
  111175. */
  111176. noMipmap?: boolean | undefined;
  111177. /**
  111178. * Defines if texture must be inverted on Y axis (default is false)
  111179. */
  111180. invertY?: boolean | undefined;
  111181. /**
  111182. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111183. */
  111184. samplingMode: number;
  111185. /**
  111186. * Gets the loaded texture
  111187. */
  111188. texture: Texture;
  111189. /**
  111190. * Callback called when the task is successful
  111191. */
  111192. onSuccess: (task: TextureAssetTask) => void;
  111193. /**
  111194. * Callback called when the task is successful
  111195. */
  111196. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  111197. /**
  111198. * Creates a new TextureAssetTask object
  111199. * @param name defines the name of the task
  111200. * @param url defines the location of the file to load
  111201. * @param noMipmap defines if mipmap should not be generated (default is false)
  111202. * @param invertY defines if texture must be inverted on Y axis (default is false)
  111203. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111204. */
  111205. constructor(
  111206. /**
  111207. * Defines the name of the task
  111208. */
  111209. name: string,
  111210. /**
  111211. * Defines the location of the file to load
  111212. */
  111213. url: string,
  111214. /**
  111215. * Defines if mipmap should not be generated (default is false)
  111216. */
  111217. noMipmap?: boolean | undefined,
  111218. /**
  111219. * Defines if texture must be inverted on Y axis (default is false)
  111220. */
  111221. invertY?: boolean | undefined,
  111222. /**
  111223. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111224. */
  111225. samplingMode?: number);
  111226. /**
  111227. * Execute the current task
  111228. * @param scene defines the scene where you want your assets to be loaded
  111229. * @param onSuccess is a callback called when the task is successfully executed
  111230. * @param onError is a callback called if an error occurs
  111231. */
  111232. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111233. }
  111234. /**
  111235. * Define a task used by AssetsManager to load cube textures
  111236. */
  111237. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111238. /**
  111239. * Defines the name of the task
  111240. */
  111241. name: string;
  111242. /**
  111243. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111244. */
  111245. url: string;
  111246. /**
  111247. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111248. */
  111249. extensions?: string[] | undefined;
  111250. /**
  111251. * Defines if mipmaps should not be generated (default is false)
  111252. */
  111253. noMipmap?: boolean | undefined;
  111254. /**
  111255. * Defines the explicit list of files (undefined by default)
  111256. */
  111257. files?: string[] | undefined;
  111258. /**
  111259. * Gets the loaded texture
  111260. */
  111261. texture: CubeTexture;
  111262. /**
  111263. * Callback called when the task is successful
  111264. */
  111265. onSuccess: (task: CubeTextureAssetTask) => void;
  111266. /**
  111267. * Callback called when the task is successful
  111268. */
  111269. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111270. /**
  111271. * Creates a new CubeTextureAssetTask
  111272. * @param name defines the name of the task
  111273. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111274. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111275. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111276. * @param files defines the explicit list of files (undefined by default)
  111277. */
  111278. constructor(
  111279. /**
  111280. * Defines the name of the task
  111281. */
  111282. name: string,
  111283. /**
  111284. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111285. */
  111286. url: string,
  111287. /**
  111288. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111289. */
  111290. extensions?: string[] | undefined,
  111291. /**
  111292. * Defines if mipmaps should not be generated (default is false)
  111293. */
  111294. noMipmap?: boolean | undefined,
  111295. /**
  111296. * Defines the explicit list of files (undefined by default)
  111297. */
  111298. files?: string[] | undefined);
  111299. /**
  111300. * Execute the current task
  111301. * @param scene defines the scene where you want your assets to be loaded
  111302. * @param onSuccess is a callback called when the task is successfully executed
  111303. * @param onError is a callback called if an error occurs
  111304. */
  111305. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111306. }
  111307. /**
  111308. * Define a task used by AssetsManager to load HDR cube textures
  111309. */
  111310. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111311. /**
  111312. * Defines the name of the task
  111313. */
  111314. name: string;
  111315. /**
  111316. * Defines the location of the file to load
  111317. */
  111318. url: string;
  111319. /**
  111320. * Defines the desired size (the more it increases the longer the generation will be)
  111321. */
  111322. size: number;
  111323. /**
  111324. * Defines if mipmaps should not be generated (default is false)
  111325. */
  111326. noMipmap: boolean;
  111327. /**
  111328. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111329. */
  111330. generateHarmonics: boolean;
  111331. /**
  111332. * 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)
  111333. */
  111334. gammaSpace: boolean;
  111335. /**
  111336. * Internal Use Only
  111337. */
  111338. reserved: boolean;
  111339. /**
  111340. * Gets the loaded texture
  111341. */
  111342. texture: HDRCubeTexture;
  111343. /**
  111344. * Callback called when the task is successful
  111345. */
  111346. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111347. /**
  111348. * Callback called when the task is successful
  111349. */
  111350. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111351. /**
  111352. * Creates a new HDRCubeTextureAssetTask object
  111353. * @param name defines the name of the task
  111354. * @param url defines the location of the file to load
  111355. * @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.
  111356. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111357. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111358. * @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)
  111359. * @param reserved Internal use only
  111360. */
  111361. constructor(
  111362. /**
  111363. * Defines the name of the task
  111364. */
  111365. name: string,
  111366. /**
  111367. * Defines the location of the file to load
  111368. */
  111369. url: string,
  111370. /**
  111371. * Defines the desired size (the more it increases the longer the generation will be)
  111372. */
  111373. size: number,
  111374. /**
  111375. * Defines if mipmaps should not be generated (default is false)
  111376. */
  111377. noMipmap?: boolean,
  111378. /**
  111379. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111380. */
  111381. generateHarmonics?: boolean,
  111382. /**
  111383. * 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)
  111384. */
  111385. gammaSpace?: boolean,
  111386. /**
  111387. * Internal Use Only
  111388. */
  111389. reserved?: boolean);
  111390. /**
  111391. * Execute the current task
  111392. * @param scene defines the scene where you want your assets to be loaded
  111393. * @param onSuccess is a callback called when the task is successfully executed
  111394. * @param onError is a callback called if an error occurs
  111395. */
  111396. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111397. }
  111398. /**
  111399. * This class can be used to easily import assets into a scene
  111400. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111401. */
  111402. export class AssetsManager {
  111403. private _scene;
  111404. private _isLoading;
  111405. protected _tasks: AbstractAssetTask[];
  111406. protected _waitingTasksCount: number;
  111407. protected _totalTasksCount: number;
  111408. /**
  111409. * Callback called when all tasks are processed
  111410. */
  111411. onFinish: (tasks: AbstractAssetTask[]) => void;
  111412. /**
  111413. * Callback called when a task is successful
  111414. */
  111415. onTaskSuccess: (task: AbstractAssetTask) => void;
  111416. /**
  111417. * Callback called when a task had an error
  111418. */
  111419. onTaskError: (task: AbstractAssetTask) => void;
  111420. /**
  111421. * Callback called when a task is done (whatever the result is)
  111422. */
  111423. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111424. /**
  111425. * Observable called when all tasks are processed
  111426. */
  111427. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111428. /**
  111429. * Observable called when a task had an error
  111430. */
  111431. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111432. /**
  111433. * Observable called when all tasks were executed
  111434. */
  111435. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111436. /**
  111437. * Observable called when a task is done (whatever the result is)
  111438. */
  111439. onProgressObservable: Observable<IAssetsProgressEvent>;
  111440. /**
  111441. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111442. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111443. */
  111444. useDefaultLoadingScreen: boolean;
  111445. /**
  111446. * Creates a new AssetsManager
  111447. * @param scene defines the scene to work on
  111448. */
  111449. constructor(scene: Scene);
  111450. /**
  111451. * Add a MeshAssetTask to the list of active tasks
  111452. * @param taskName defines the name of the new task
  111453. * @param meshesNames defines the name of meshes to load
  111454. * @param rootUrl defines the root url to use to locate files
  111455. * @param sceneFilename defines the filename of the scene file
  111456. * @returns a new MeshAssetTask object
  111457. */
  111458. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111459. /**
  111460. * Add a TextFileAssetTask to the list of active tasks
  111461. * @param taskName defines the name of the new task
  111462. * @param url defines the url of the file to load
  111463. * @returns a new TextFileAssetTask object
  111464. */
  111465. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111466. /**
  111467. * Add a BinaryFileAssetTask to the list of active tasks
  111468. * @param taskName defines the name of the new task
  111469. * @param url defines the url of the file to load
  111470. * @returns a new BinaryFileAssetTask object
  111471. */
  111472. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111473. /**
  111474. * Add a ImageAssetTask to the list of active tasks
  111475. * @param taskName defines the name of the new task
  111476. * @param url defines the url of the file to load
  111477. * @returns a new ImageAssetTask object
  111478. */
  111479. addImageTask(taskName: string, url: string): ImageAssetTask;
  111480. /**
  111481. * Add a TextureAssetTask to the list of active tasks
  111482. * @param taskName defines the name of the new task
  111483. * @param url defines the url of the file to load
  111484. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111485. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111486. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111487. * @returns a new TextureAssetTask object
  111488. */
  111489. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111490. /**
  111491. * Add a CubeTextureAssetTask to the list of active tasks
  111492. * @param taskName defines the name of the new task
  111493. * @param url defines the url of the file to load
  111494. * @param extensions defines the extension to use to load the cube map (can be null)
  111495. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111496. * @param files defines the list of files to load (can be null)
  111497. * @returns a new CubeTextureAssetTask object
  111498. */
  111499. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111500. /**
  111501. *
  111502. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111503. * @param taskName defines the name of the new task
  111504. * @param url defines the url of the file to load
  111505. * @param size defines the size you want for the cubemap (can be null)
  111506. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111507. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111508. * @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)
  111509. * @param reserved Internal use only
  111510. * @returns a new HDRCubeTextureAssetTask object
  111511. */
  111512. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111513. /**
  111514. * Remove a task from the assets manager.
  111515. * @param task the task to remove
  111516. */
  111517. removeTask(task: AbstractAssetTask): void;
  111518. private _decreaseWaitingTasksCount;
  111519. private _runTask;
  111520. /**
  111521. * Reset the AssetsManager and remove all tasks
  111522. * @return the current instance of the AssetsManager
  111523. */
  111524. reset(): AssetsManager;
  111525. /**
  111526. * Start the loading process
  111527. * @return the current instance of the AssetsManager
  111528. */
  111529. load(): AssetsManager;
  111530. /**
  111531. * Start the loading process as an async operation
  111532. * @return a promise returning the list of failed tasks
  111533. */
  111534. loadAsync(): Promise<void>;
  111535. }
  111536. }
  111537. declare module BABYLON {
  111538. /**
  111539. * Wrapper class for promise with external resolve and reject.
  111540. */
  111541. export class Deferred<T> {
  111542. /**
  111543. * The promise associated with this deferred object.
  111544. */
  111545. readonly promise: Promise<T>;
  111546. private _resolve;
  111547. private _reject;
  111548. /**
  111549. * The resolve method of the promise associated with this deferred object.
  111550. */
  111551. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111552. /**
  111553. * The reject method of the promise associated with this deferred object.
  111554. */
  111555. readonly reject: (reason?: any) => void;
  111556. /**
  111557. * Constructor for this deferred object.
  111558. */
  111559. constructor();
  111560. }
  111561. }
  111562. declare module BABYLON {
  111563. /**
  111564. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  111565. */
  111566. export class MeshExploder {
  111567. private _centerMesh;
  111568. private _meshes;
  111569. private _meshesOrigins;
  111570. private _toCenterVectors;
  111571. private _scaledDirection;
  111572. private _newPosition;
  111573. private _centerPosition;
  111574. /**
  111575. * Explodes meshes from a center mesh.
  111576. * @param meshes The meshes to explode.
  111577. * @param centerMesh The mesh to be center of explosion.
  111578. */
  111579. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  111580. private _setCenterMesh;
  111581. /**
  111582. * Get class name
  111583. * @returns "MeshExploder"
  111584. */
  111585. getClassName(): string;
  111586. /**
  111587. * "Exploded meshes"
  111588. * @returns Array of meshes with the centerMesh at index 0.
  111589. */
  111590. getMeshes(): Array<Mesh>;
  111591. /**
  111592. * Explodes meshes giving a specific direction
  111593. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  111594. */
  111595. explode(direction?: number): void;
  111596. }
  111597. }
  111598. declare module BABYLON {
  111599. /**
  111600. * Class used to help managing file picking and drag'n'drop
  111601. */
  111602. export class FilesInput {
  111603. /**
  111604. * List of files ready to be loaded
  111605. */
  111606. static readonly FilesToLoad: {
  111607. [key: string]: File;
  111608. };
  111609. /**
  111610. * Callback called when a file is processed
  111611. */
  111612. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111613. private _engine;
  111614. private _currentScene;
  111615. private _sceneLoadedCallback;
  111616. private _progressCallback;
  111617. private _additionalRenderLoopLogicCallback;
  111618. private _textureLoadingCallback;
  111619. private _startingProcessingFilesCallback;
  111620. private _onReloadCallback;
  111621. private _errorCallback;
  111622. private _elementToMonitor;
  111623. private _sceneFileToLoad;
  111624. private _filesToLoad;
  111625. /**
  111626. * Creates a new FilesInput
  111627. * @param engine defines the rendering engine
  111628. * @param scene defines the hosting scene
  111629. * @param sceneLoadedCallback callback called when scene is loaded
  111630. * @param progressCallback callback called to track progress
  111631. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111632. * @param textureLoadingCallback callback called when a texture is loading
  111633. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111634. * @param onReloadCallback callback called when a reload is requested
  111635. * @param errorCallback callback call if an error occurs
  111636. */
  111637. 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);
  111638. private _dragEnterHandler;
  111639. private _dragOverHandler;
  111640. private _dropHandler;
  111641. /**
  111642. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111643. * @param elementToMonitor defines the DOM element to track
  111644. */
  111645. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111646. /**
  111647. * Release all associated resources
  111648. */
  111649. dispose(): void;
  111650. private renderFunction;
  111651. private drag;
  111652. private drop;
  111653. private _traverseFolder;
  111654. private _processFiles;
  111655. /**
  111656. * Load files from a drop event
  111657. * @param event defines the drop event to use as source
  111658. */
  111659. loadFiles(event: any): void;
  111660. private _processReload;
  111661. /**
  111662. * Reload the current scene from the loaded files
  111663. */
  111664. reload(): void;
  111665. }
  111666. }
  111667. declare module BABYLON {
  111668. /**
  111669. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111670. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111671. */
  111672. export class SceneOptimization {
  111673. /**
  111674. * Defines the priority of this optimization (0 by default which means first in the list)
  111675. */
  111676. priority: number;
  111677. /**
  111678. * Gets a string describing the action executed by the current optimization
  111679. * @returns description string
  111680. */
  111681. getDescription(): string;
  111682. /**
  111683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111684. * @param scene defines the current scene where to apply this optimization
  111685. * @param optimizer defines the current optimizer
  111686. * @returns true if everything that can be done was applied
  111687. */
  111688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111689. /**
  111690. * Creates the SceneOptimization object
  111691. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111692. * @param desc defines the description associated with the optimization
  111693. */
  111694. constructor(
  111695. /**
  111696. * Defines the priority of this optimization (0 by default which means first in the list)
  111697. */
  111698. priority?: number);
  111699. }
  111700. /**
  111701. * Defines an optimization used to reduce the size of render target textures
  111702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111703. */
  111704. export class TextureOptimization extends SceneOptimization {
  111705. /**
  111706. * Defines the priority of this optimization (0 by default which means first in the list)
  111707. */
  111708. priority: number;
  111709. /**
  111710. * 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
  111711. */
  111712. maximumSize: number;
  111713. /**
  111714. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111715. */
  111716. step: number;
  111717. /**
  111718. * Gets a string describing the action executed by the current optimization
  111719. * @returns description string
  111720. */
  111721. getDescription(): string;
  111722. /**
  111723. * Creates the TextureOptimization object
  111724. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111725. * @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
  111726. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111727. */
  111728. constructor(
  111729. /**
  111730. * Defines the priority of this optimization (0 by default which means first in the list)
  111731. */
  111732. priority?: number,
  111733. /**
  111734. * 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
  111735. */
  111736. maximumSize?: number,
  111737. /**
  111738. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111739. */
  111740. step?: number);
  111741. /**
  111742. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111743. * @param scene defines the current scene where to apply this optimization
  111744. * @param optimizer defines the current optimizer
  111745. * @returns true if everything that can be done was applied
  111746. */
  111747. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111748. }
  111749. /**
  111750. * Defines an optimization used to increase or decrease the rendering resolution
  111751. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111752. */
  111753. export class HardwareScalingOptimization extends SceneOptimization {
  111754. /**
  111755. * Defines the priority of this optimization (0 by default which means first in the list)
  111756. */
  111757. priority: number;
  111758. /**
  111759. * Defines the maximum scale to use (2 by default)
  111760. */
  111761. maximumScale: number;
  111762. /**
  111763. * Defines the step to use between two passes (0.5 by default)
  111764. */
  111765. step: number;
  111766. private _currentScale;
  111767. private _directionOffset;
  111768. /**
  111769. * Gets a string describing the action executed by the current optimization
  111770. * @return description string
  111771. */
  111772. getDescription(): string;
  111773. /**
  111774. * Creates the HardwareScalingOptimization object
  111775. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111776. * @param maximumScale defines the maximum scale to use (2 by default)
  111777. * @param step defines the step to use between two passes (0.5 by default)
  111778. */
  111779. constructor(
  111780. /**
  111781. * Defines the priority of this optimization (0 by default which means first in the list)
  111782. */
  111783. priority?: number,
  111784. /**
  111785. * Defines the maximum scale to use (2 by default)
  111786. */
  111787. maximumScale?: number,
  111788. /**
  111789. * Defines the step to use between two passes (0.5 by default)
  111790. */
  111791. step?: number);
  111792. /**
  111793. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111794. * @param scene defines the current scene where to apply this optimization
  111795. * @param optimizer defines the current optimizer
  111796. * @returns true if everything that can be done was applied
  111797. */
  111798. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111799. }
  111800. /**
  111801. * Defines an optimization used to remove shadows
  111802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111803. */
  111804. export class ShadowsOptimization extends SceneOptimization {
  111805. /**
  111806. * Gets a string describing the action executed by the current optimization
  111807. * @return description string
  111808. */
  111809. getDescription(): string;
  111810. /**
  111811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111812. * @param scene defines the current scene where to apply this optimization
  111813. * @param optimizer defines the current optimizer
  111814. * @returns true if everything that can be done was applied
  111815. */
  111816. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111817. }
  111818. /**
  111819. * Defines an optimization used to turn post-processes off
  111820. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111821. */
  111822. export class PostProcessesOptimization extends SceneOptimization {
  111823. /**
  111824. * Gets a string describing the action executed by the current optimization
  111825. * @return description string
  111826. */
  111827. getDescription(): string;
  111828. /**
  111829. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111830. * @param scene defines the current scene where to apply this optimization
  111831. * @param optimizer defines the current optimizer
  111832. * @returns true if everything that can be done was applied
  111833. */
  111834. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111835. }
  111836. /**
  111837. * Defines an optimization used to turn lens flares off
  111838. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111839. */
  111840. export class LensFlaresOptimization extends SceneOptimization {
  111841. /**
  111842. * Gets a string describing the action executed by the current optimization
  111843. * @return description string
  111844. */
  111845. getDescription(): string;
  111846. /**
  111847. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111848. * @param scene defines the current scene where to apply this optimization
  111849. * @param optimizer defines the current optimizer
  111850. * @returns true if everything that can be done was applied
  111851. */
  111852. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111853. }
  111854. /**
  111855. * Defines an optimization based on user defined callback.
  111856. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111857. */
  111858. export class CustomOptimization extends SceneOptimization {
  111859. /**
  111860. * Callback called to apply the custom optimization.
  111861. */
  111862. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111863. /**
  111864. * Callback called to get custom description
  111865. */
  111866. onGetDescription: () => string;
  111867. /**
  111868. * Gets a string describing the action executed by the current optimization
  111869. * @returns description string
  111870. */
  111871. getDescription(): string;
  111872. /**
  111873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111874. * @param scene defines the current scene where to apply this optimization
  111875. * @param optimizer defines the current optimizer
  111876. * @returns true if everything that can be done was applied
  111877. */
  111878. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111879. }
  111880. /**
  111881. * Defines an optimization used to turn particles off
  111882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111883. */
  111884. export class ParticlesOptimization extends SceneOptimization {
  111885. /**
  111886. * Gets a string describing the action executed by the current optimization
  111887. * @return description string
  111888. */
  111889. getDescription(): string;
  111890. /**
  111891. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111892. * @param scene defines the current scene where to apply this optimization
  111893. * @param optimizer defines the current optimizer
  111894. * @returns true if everything that can be done was applied
  111895. */
  111896. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111897. }
  111898. /**
  111899. * Defines an optimization used to turn render targets off
  111900. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111901. */
  111902. export class RenderTargetsOptimization extends SceneOptimization {
  111903. /**
  111904. * Gets a string describing the action executed by the current optimization
  111905. * @return description string
  111906. */
  111907. getDescription(): string;
  111908. /**
  111909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111910. * @param scene defines the current scene where to apply this optimization
  111911. * @param optimizer defines the current optimizer
  111912. * @returns true if everything that can be done was applied
  111913. */
  111914. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111915. }
  111916. /**
  111917. * Defines an optimization used to merge meshes with compatible materials
  111918. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111919. */
  111920. export class MergeMeshesOptimization extends SceneOptimization {
  111921. private static _UpdateSelectionTree;
  111922. /**
  111923. * Gets or sets a boolean which defines if optimization octree has to be updated
  111924. */
  111925. /**
  111926. * Gets or sets a boolean which defines if optimization octree has to be updated
  111927. */
  111928. static UpdateSelectionTree: boolean;
  111929. /**
  111930. * Gets a string describing the action executed by the current optimization
  111931. * @return description string
  111932. */
  111933. getDescription(): string;
  111934. private _canBeMerged;
  111935. /**
  111936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111937. * @param scene defines the current scene where to apply this optimization
  111938. * @param optimizer defines the current optimizer
  111939. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111940. * @returns true if everything that can be done was applied
  111941. */
  111942. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111943. }
  111944. /**
  111945. * Defines a list of options used by SceneOptimizer
  111946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111947. */
  111948. export class SceneOptimizerOptions {
  111949. /**
  111950. * Defines the target frame rate to reach (60 by default)
  111951. */
  111952. targetFrameRate: number;
  111953. /**
  111954. * Defines the interval between two checkes (2000ms by default)
  111955. */
  111956. trackerDuration: number;
  111957. /**
  111958. * Gets the list of optimizations to apply
  111959. */
  111960. optimizations: SceneOptimization[];
  111961. /**
  111962. * Creates a new list of options used by SceneOptimizer
  111963. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111964. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111965. */
  111966. constructor(
  111967. /**
  111968. * Defines the target frame rate to reach (60 by default)
  111969. */
  111970. targetFrameRate?: number,
  111971. /**
  111972. * Defines the interval between two checkes (2000ms by default)
  111973. */
  111974. trackerDuration?: number);
  111975. /**
  111976. * Add a new optimization
  111977. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111978. * @returns the current SceneOptimizerOptions
  111979. */
  111980. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111981. /**
  111982. * Add a new custom optimization
  111983. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111984. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111985. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111986. * @returns the current SceneOptimizerOptions
  111987. */
  111988. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111989. /**
  111990. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111991. * @param targetFrameRate defines the target frame rate (60 by default)
  111992. * @returns a SceneOptimizerOptions object
  111993. */
  111994. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111995. /**
  111996. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111997. * @param targetFrameRate defines the target frame rate (60 by default)
  111998. * @returns a SceneOptimizerOptions object
  111999. */
  112000. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112001. /**
  112002. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  112003. * @param targetFrameRate defines the target frame rate (60 by default)
  112004. * @returns a SceneOptimizerOptions object
  112005. */
  112006. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112007. }
  112008. /**
  112009. * Class used to run optimizations in order to reach a target frame rate
  112010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112011. */
  112012. export class SceneOptimizer implements IDisposable {
  112013. private _isRunning;
  112014. private _options;
  112015. private _scene;
  112016. private _currentPriorityLevel;
  112017. private _targetFrameRate;
  112018. private _trackerDuration;
  112019. private _currentFrameRate;
  112020. private _sceneDisposeObserver;
  112021. private _improvementMode;
  112022. /**
  112023. * Defines an observable called when the optimizer reaches the target frame rate
  112024. */
  112025. onSuccessObservable: Observable<SceneOptimizer>;
  112026. /**
  112027. * Defines an observable called when the optimizer enables an optimization
  112028. */
  112029. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  112030. /**
  112031. * Defines an observable called when the optimizer is not able to reach the target frame rate
  112032. */
  112033. onFailureObservable: Observable<SceneOptimizer>;
  112034. /**
  112035. * Gets a boolean indicating if the optimizer is in improvement mode
  112036. */
  112037. readonly isInImprovementMode: boolean;
  112038. /**
  112039. * Gets the current priority level (0 at start)
  112040. */
  112041. readonly currentPriorityLevel: number;
  112042. /**
  112043. * Gets the current frame rate checked by the SceneOptimizer
  112044. */
  112045. readonly currentFrameRate: number;
  112046. /**
  112047. * Gets or sets the current target frame rate (60 by default)
  112048. */
  112049. /**
  112050. * Gets or sets the current target frame rate (60 by default)
  112051. */
  112052. targetFrameRate: number;
  112053. /**
  112054. * Gets or sets the current interval between two checks (every 2000ms by default)
  112055. */
  112056. /**
  112057. * Gets or sets the current interval between two checks (every 2000ms by default)
  112058. */
  112059. trackerDuration: number;
  112060. /**
  112061. * Gets the list of active optimizations
  112062. */
  112063. readonly optimizations: SceneOptimization[];
  112064. /**
  112065. * Creates a new SceneOptimizer
  112066. * @param scene defines the scene to work on
  112067. * @param options defines the options to use with the SceneOptimizer
  112068. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  112069. * @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)
  112070. */
  112071. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  112072. /**
  112073. * Stops the current optimizer
  112074. */
  112075. stop(): void;
  112076. /**
  112077. * Reset the optimizer to initial step (current priority level = 0)
  112078. */
  112079. reset(): void;
  112080. /**
  112081. * Start the optimizer. By default it will try to reach a specific framerate
  112082. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  112083. */
  112084. start(): void;
  112085. private _checkCurrentState;
  112086. /**
  112087. * Release all resources
  112088. */
  112089. dispose(): void;
  112090. /**
  112091. * Helper function to create a SceneOptimizer with one single line of code
  112092. * @param scene defines the scene to work on
  112093. * @param options defines the options to use with the SceneOptimizer
  112094. * @param onSuccess defines a callback to call on success
  112095. * @param onFailure defines a callback to call on failure
  112096. * @returns the new SceneOptimizer object
  112097. */
  112098. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  112099. }
  112100. }
  112101. declare module BABYLON {
  112102. /**
  112103. * Class used to serialize a scene into a string
  112104. */
  112105. export class SceneSerializer {
  112106. /**
  112107. * Clear cache used by a previous serialization
  112108. */
  112109. static ClearCache(): void;
  112110. /**
  112111. * Serialize a scene into a JSON compatible object
  112112. * @param scene defines the scene to serialize
  112113. * @returns a JSON compatible object
  112114. */
  112115. static Serialize(scene: Scene): any;
  112116. /**
  112117. * Serialize a mesh into a JSON compatible object
  112118. * @param toSerialize defines the mesh to serialize
  112119. * @param withParents defines if parents must be serialized as well
  112120. * @param withChildren defines if children must be serialized as well
  112121. * @returns a JSON compatible object
  112122. */
  112123. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  112124. }
  112125. }
  112126. declare module BABYLON {
  112127. /**
  112128. * This represents the different options avilable for the video capture.
  112129. */
  112130. export interface VideoRecorderOptions {
  112131. /** Defines the mime type of the video */
  112132. mimeType: string;
  112133. /** Defines the video the video should be recorded at */
  112134. fps: number;
  112135. /** Defines the chunk size for the recording data */
  112136. recordChunckSize: number;
  112137. /** The audio tracks to attach to the record */
  112138. audioTracks?: MediaStreamTrack[];
  112139. }
  112140. /**
  112141. * This can helps recording videos from BabylonJS.
  112142. * This is based on the available WebRTC functionalities of the browser.
  112143. *
  112144. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  112145. */
  112146. export class VideoRecorder {
  112147. private static readonly _defaultOptions;
  112148. /**
  112149. * Returns wehther or not the VideoRecorder is available in your browser.
  112150. * @param engine Defines the Babylon Engine to check the support for
  112151. * @returns true if supported otherwise false
  112152. */
  112153. static IsSupported(engine: Engine): boolean;
  112154. private readonly _options;
  112155. private _canvas;
  112156. private _mediaRecorder;
  112157. private _recordedChunks;
  112158. private _fileName;
  112159. private _resolve;
  112160. private _reject;
  112161. /**
  112162. * True wether a recording is already in progress.
  112163. */
  112164. readonly isRecording: boolean;
  112165. /**
  112166. * Create a new VideoCapture object which can help converting what you see in Babylon to
  112167. * a video file.
  112168. * @param engine Defines the BabylonJS Engine you wish to record
  112169. * @param options Defines options that can be used to customized the capture
  112170. */
  112171. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  112172. /**
  112173. * Stops the current recording before the default capture timeout passed in the startRecording
  112174. * functions.
  112175. */
  112176. stopRecording(): void;
  112177. /**
  112178. * Starts recording the canvas for a max duration specified in parameters.
  112179. * @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.
  112180. * @param maxDuration Defines the maximum recording time in seconds.
  112181. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  112182. * @return a promise callback at the end of the recording with the video data in Blob.
  112183. */
  112184. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  112185. /**
  112186. * Releases internal resources used during the recording.
  112187. */
  112188. dispose(): void;
  112189. private _handleDataAvailable;
  112190. private _handleError;
  112191. private _handleStop;
  112192. }
  112193. }
  112194. declare module BABYLON {
  112195. /**
  112196. * Helper class to push actions to a pool of workers.
  112197. */
  112198. export class WorkerPool implements IDisposable {
  112199. private _workerInfos;
  112200. private _pendingActions;
  112201. /**
  112202. * Constructor
  112203. * @param workers Array of workers to use for actions
  112204. */
  112205. constructor(workers: Array<Worker>);
  112206. /**
  112207. * Terminates all workers and clears any pending actions.
  112208. */
  112209. dispose(): void;
  112210. /**
  112211. * Pushes an action to the worker pool. If all the workers are active, the action will be
  112212. * pended until a worker has completed its action.
  112213. * @param action The action to perform. Call onComplete when the action is complete.
  112214. */
  112215. push(action: (worker: Worker, onComplete: () => void) => void): void;
  112216. private _execute;
  112217. }
  112218. }
  112219. declare module BABYLON {
  112220. /**
  112221. * Class containing a set of static utilities functions for screenshots
  112222. */
  112223. export class ScreenshotTools {
  112224. /**
  112225. * Captures a screenshot of the current rendering
  112226. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112227. * @param engine defines the rendering engine
  112228. * @param camera defines the source camera
  112229. * @param size This parameter can be set to a single number or to an object with the
  112230. * following (optional) properties: precision, width, height. If a single number is passed,
  112231. * it will be used for both width and height. If an object is passed, the screenshot size
  112232. * will be derived from the parameters. The precision property is a multiplier allowing
  112233. * rendering at a higher or lower resolution
  112234. * @param successCallback defines the callback receives a single parameter which contains the
  112235. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112236. * src parameter of an <img> to display it
  112237. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  112238. * Check your browser for supported MIME types
  112239. */
  112240. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  112241. /**
  112242. * Generates an image screenshot from the specified camera.
  112243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112244. * @param engine The engine to use for rendering
  112245. * @param camera The camera to use for rendering
  112246. * @param size This parameter can be set to a single number or to an object with the
  112247. * following (optional) properties: precision, width, height. If a single number is passed,
  112248. * it will be used for both width and height. If an object is passed, the screenshot size
  112249. * will be derived from the parameters. The precision property is a multiplier allowing
  112250. * rendering at a higher or lower resolution
  112251. * @param successCallback The callback receives a single parameter which contains the
  112252. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112253. * src parameter of an <img> to display it
  112254. * @param mimeType The MIME type of the screenshot image (default: image/png).
  112255. * Check your browser for supported MIME types
  112256. * @param samples Texture samples (default: 1)
  112257. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  112258. * @param fileName A name for for the downloaded file.
  112259. */
  112260. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  112261. }
  112262. }
  112263. declare module BABYLON {
  112264. /**
  112265. * A cursor which tracks a point on a path
  112266. */
  112267. export class PathCursor {
  112268. private path;
  112269. /**
  112270. * Stores path cursor callbacks for when an onchange event is triggered
  112271. */
  112272. private _onchange;
  112273. /**
  112274. * The value of the path cursor
  112275. */
  112276. value: number;
  112277. /**
  112278. * The animation array of the path cursor
  112279. */
  112280. animations: Animation[];
  112281. /**
  112282. * Initializes the path cursor
  112283. * @param path The path to track
  112284. */
  112285. constructor(path: Path2);
  112286. /**
  112287. * Gets the cursor point on the path
  112288. * @returns A point on the path cursor at the cursor location
  112289. */
  112290. getPoint(): Vector3;
  112291. /**
  112292. * Moves the cursor ahead by the step amount
  112293. * @param step The amount to move the cursor forward
  112294. * @returns This path cursor
  112295. */
  112296. moveAhead(step?: number): PathCursor;
  112297. /**
  112298. * Moves the cursor behind by the step amount
  112299. * @param step The amount to move the cursor back
  112300. * @returns This path cursor
  112301. */
  112302. moveBack(step?: number): PathCursor;
  112303. /**
  112304. * Moves the cursor by the step amount
  112305. * If the step amount is greater than one, an exception is thrown
  112306. * @param step The amount to move the cursor
  112307. * @returns This path cursor
  112308. */
  112309. move(step: number): PathCursor;
  112310. /**
  112311. * Ensures that the value is limited between zero and one
  112312. * @returns This path cursor
  112313. */
  112314. private ensureLimits;
  112315. /**
  112316. * Runs onchange callbacks on change (used by the animation engine)
  112317. * @returns This path cursor
  112318. */
  112319. private raiseOnChange;
  112320. /**
  112321. * Executes a function on change
  112322. * @param f A path cursor onchange callback
  112323. * @returns This path cursor
  112324. */
  112325. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112326. }
  112327. }
  112328. declare module BABYLON {
  112329. /** @hidden */
  112330. export var blurPixelShader: {
  112331. name: string;
  112332. shader: string;
  112333. };
  112334. }
  112335. declare module BABYLON {
  112336. /** @hidden */
  112337. export var bones300Declaration: {
  112338. name: string;
  112339. shader: string;
  112340. };
  112341. }
  112342. declare module BABYLON {
  112343. /** @hidden */
  112344. export var instances300Declaration: {
  112345. name: string;
  112346. shader: string;
  112347. };
  112348. }
  112349. declare module BABYLON {
  112350. /** @hidden */
  112351. export var pointCloudVertexDeclaration: {
  112352. name: string;
  112353. shader: string;
  112354. };
  112355. }
  112356. // Mixins
  112357. interface Window {
  112358. mozIndexedDB: IDBFactory;
  112359. webkitIndexedDB: IDBFactory;
  112360. msIndexedDB: IDBFactory;
  112361. webkitURL: typeof URL;
  112362. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112363. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112364. WebGLRenderingContext: WebGLRenderingContext;
  112365. MSGesture: MSGesture;
  112366. CANNON: any;
  112367. AudioContext: AudioContext;
  112368. webkitAudioContext: AudioContext;
  112369. PointerEvent: any;
  112370. Math: Math;
  112371. Uint8Array: Uint8ArrayConstructor;
  112372. Float32Array: Float32ArrayConstructor;
  112373. mozURL: typeof URL;
  112374. msURL: typeof URL;
  112375. VRFrameData: any; // WebVR, from specs 1.1
  112376. DracoDecoderModule: any;
  112377. setImmediate(handler: (...args: any[]) => void): number;
  112378. }
  112379. interface HTMLCanvasElement {
  112380. requestPointerLock(): void;
  112381. msRequestPointerLock?(): void;
  112382. mozRequestPointerLock?(): void;
  112383. webkitRequestPointerLock?(): void;
  112384. /** Track wether a record is in progress */
  112385. isRecording: boolean;
  112386. /** Capture Stream method defined by some browsers */
  112387. captureStream(fps?: number): MediaStream;
  112388. }
  112389. interface CanvasRenderingContext2D {
  112390. msImageSmoothingEnabled: boolean;
  112391. }
  112392. interface MouseEvent {
  112393. mozMovementX: number;
  112394. mozMovementY: number;
  112395. webkitMovementX: number;
  112396. webkitMovementY: number;
  112397. msMovementX: number;
  112398. msMovementY: number;
  112399. }
  112400. interface Navigator {
  112401. mozGetVRDevices: (any: any) => any;
  112402. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112403. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112404. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112405. webkitGetGamepads(): Gamepad[];
  112406. msGetGamepads(): Gamepad[];
  112407. webkitGamepads(): Gamepad[];
  112408. }
  112409. interface HTMLVideoElement {
  112410. mozSrcObject: any;
  112411. }
  112412. interface Math {
  112413. fround(x: number): number;
  112414. imul(a: number, b: number): number;
  112415. }
  112416. interface WebGLProgram {
  112417. context?: WebGLRenderingContext;
  112418. vertexShader?: WebGLShader;
  112419. fragmentShader?: WebGLShader;
  112420. isParallelCompiled: boolean;
  112421. onCompiled?: () => void;
  112422. }
  112423. interface WebGLRenderingContext {
  112424. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112425. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112426. vertexAttribDivisor(index: number, divisor: number): void;
  112427. createVertexArray(): any;
  112428. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112429. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112430. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112431. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112432. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112433. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112434. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112435. // Queries
  112436. createQuery(): WebGLQuery;
  112437. deleteQuery(query: WebGLQuery): void;
  112438. beginQuery(target: number, query: WebGLQuery): void;
  112439. endQuery(target: number): void;
  112440. getQueryParameter(query: WebGLQuery, pname: number): any;
  112441. getQuery(target: number, pname: number): any;
  112442. MAX_SAMPLES: number;
  112443. RGBA8: number;
  112444. READ_FRAMEBUFFER: number;
  112445. DRAW_FRAMEBUFFER: number;
  112446. UNIFORM_BUFFER: number;
  112447. HALF_FLOAT_OES: number;
  112448. RGBA16F: number;
  112449. RGBA32F: number;
  112450. R32F: number;
  112451. RG32F: number;
  112452. RGB32F: number;
  112453. R16F: number;
  112454. RG16F: number;
  112455. RGB16F: number;
  112456. RED: number;
  112457. RG: number;
  112458. R8: number;
  112459. RG8: number;
  112460. UNSIGNED_INT_24_8: number;
  112461. DEPTH24_STENCIL8: number;
  112462. /* Multiple Render Targets */
  112463. drawBuffers(buffers: number[]): void;
  112464. readBuffer(src: number): void;
  112465. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112466. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112467. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112468. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112469. // Occlusion Query
  112470. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112471. ANY_SAMPLES_PASSED: number;
  112472. QUERY_RESULT_AVAILABLE: number;
  112473. QUERY_RESULT: number;
  112474. }
  112475. interface WebGLBuffer {
  112476. references: number;
  112477. capacity: number;
  112478. is32Bits: boolean;
  112479. }
  112480. interface WebGLProgram {
  112481. transformFeedback?: WebGLTransformFeedback | null;
  112482. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112483. }
  112484. interface EXT_disjoint_timer_query {
  112485. QUERY_COUNTER_BITS_EXT: number;
  112486. TIME_ELAPSED_EXT: number;
  112487. TIMESTAMP_EXT: number;
  112488. GPU_DISJOINT_EXT: number;
  112489. QUERY_RESULT_EXT: number;
  112490. QUERY_RESULT_AVAILABLE_EXT: number;
  112491. queryCounterEXT(query: WebGLQuery, target: number): void;
  112492. createQueryEXT(): WebGLQuery;
  112493. beginQueryEXT(target: number, query: WebGLQuery): void;
  112494. endQueryEXT(target: number): void;
  112495. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112496. deleteQueryEXT(query: WebGLQuery): void;
  112497. }
  112498. interface WebGLUniformLocation {
  112499. _currentState: any;
  112500. }
  112501. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112502. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112503. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112504. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112505. interface WebGLRenderingContext {
  112506. readonly RASTERIZER_DISCARD: number;
  112507. readonly DEPTH_COMPONENT24: number;
  112508. readonly TEXTURE_3D: number;
  112509. readonly TEXTURE_2D_ARRAY: number;
  112510. readonly TEXTURE_COMPARE_FUNC: number;
  112511. readonly TEXTURE_COMPARE_MODE: number;
  112512. readonly COMPARE_REF_TO_TEXTURE: number;
  112513. readonly TEXTURE_WRAP_R: number;
  112514. readonly HALF_FLOAT: number;
  112515. readonly RGB8: number;
  112516. readonly RED_INTEGER: number;
  112517. readonly RG_INTEGER: number;
  112518. readonly RGB_INTEGER: number;
  112519. readonly RGBA_INTEGER: number;
  112520. readonly R8_SNORM: number;
  112521. readonly RG8_SNORM: number;
  112522. readonly RGB8_SNORM: number;
  112523. readonly RGBA8_SNORM: number;
  112524. readonly R8I: number;
  112525. readonly RG8I: number;
  112526. readonly RGB8I: number;
  112527. readonly RGBA8I: number;
  112528. readonly R8UI: number;
  112529. readonly RG8UI: number;
  112530. readonly RGB8UI: number;
  112531. readonly RGBA8UI: number;
  112532. readonly R16I: number;
  112533. readonly RG16I: number;
  112534. readonly RGB16I: number;
  112535. readonly RGBA16I: number;
  112536. readonly R16UI: number;
  112537. readonly RG16UI: number;
  112538. readonly RGB16UI: number;
  112539. readonly RGBA16UI: number;
  112540. readonly R32I: number;
  112541. readonly RG32I: number;
  112542. readonly RGB32I: number;
  112543. readonly RGBA32I: number;
  112544. readonly R32UI: number;
  112545. readonly RG32UI: number;
  112546. readonly RGB32UI: number;
  112547. readonly RGBA32UI: number;
  112548. readonly RGB10_A2UI: number;
  112549. readonly R11F_G11F_B10F: number;
  112550. readonly RGB9_E5: number;
  112551. readonly RGB10_A2: number;
  112552. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112553. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112554. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112555. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112556. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112557. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112558. 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;
  112559. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112560. readonly TRANSFORM_FEEDBACK: number;
  112561. readonly INTERLEAVED_ATTRIBS: number;
  112562. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112563. createTransformFeedback(): WebGLTransformFeedback;
  112564. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112565. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112566. beginTransformFeedback(primitiveMode: number): void;
  112567. endTransformFeedback(): void;
  112568. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112569. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112570. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112571. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112572. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112573. }
  112574. interface ImageBitmap {
  112575. readonly width: number;
  112576. readonly height: number;
  112577. close(): void;
  112578. }
  112579. interface WebGLQuery extends WebGLObject {
  112580. }
  112581. declare var WebGLQuery: {
  112582. prototype: WebGLQuery;
  112583. new(): WebGLQuery;
  112584. };
  112585. interface WebGLSampler extends WebGLObject {
  112586. }
  112587. declare var WebGLSampler: {
  112588. prototype: WebGLSampler;
  112589. new(): WebGLSampler;
  112590. };
  112591. interface WebGLSync extends WebGLObject {
  112592. }
  112593. declare var WebGLSync: {
  112594. prototype: WebGLSync;
  112595. new(): WebGLSync;
  112596. };
  112597. interface WebGLTransformFeedback extends WebGLObject {
  112598. }
  112599. declare var WebGLTransformFeedback: {
  112600. prototype: WebGLTransformFeedback;
  112601. new(): WebGLTransformFeedback;
  112602. };
  112603. interface WebGLVertexArrayObject extends WebGLObject {
  112604. }
  112605. declare var WebGLVertexArrayObject: {
  112606. prototype: WebGLVertexArrayObject;
  112607. new(): WebGLVertexArrayObject;
  112608. };
  112609. // Type definitions for WebVR API
  112610. // Project: https://w3c.github.io/webvr/
  112611. // Definitions by: six a <https://github.com/lostfictions>
  112612. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112613. interface VRDisplay extends EventTarget {
  112614. /**
  112615. * Dictionary of capabilities describing the VRDisplay.
  112616. */
  112617. readonly capabilities: VRDisplayCapabilities;
  112618. /**
  112619. * z-depth defining the far plane of the eye view frustum
  112620. * enables mapping of values in the render target depth
  112621. * attachment to scene coordinates. Initially set to 10000.0.
  112622. */
  112623. depthFar: number;
  112624. /**
  112625. * z-depth defining the near plane of the eye view frustum
  112626. * enables mapping of values in the render target depth
  112627. * attachment to scene coordinates. Initially set to 0.01.
  112628. */
  112629. depthNear: number;
  112630. /**
  112631. * An identifier for this distinct VRDisplay. Used as an
  112632. * association point in the Gamepad API.
  112633. */
  112634. readonly displayId: number;
  112635. /**
  112636. * A display name, a user-readable name identifying it.
  112637. */
  112638. readonly displayName: string;
  112639. readonly isConnected: boolean;
  112640. readonly isPresenting: boolean;
  112641. /**
  112642. * If this VRDisplay supports room-scale experiences, the optional
  112643. * stage attribute contains details on the room-scale parameters.
  112644. */
  112645. readonly stageParameters: VRStageParameters | null;
  112646. /**
  112647. * Passing the value returned by `requestAnimationFrame` to
  112648. * `cancelAnimationFrame` will unregister the callback.
  112649. * @param handle Define the hanle of the request to cancel
  112650. */
  112651. cancelAnimationFrame(handle: number): void;
  112652. /**
  112653. * Stops presenting to the VRDisplay.
  112654. * @returns a promise to know when it stopped
  112655. */
  112656. exitPresent(): Promise<void>;
  112657. /**
  112658. * Return the current VREyeParameters for the given eye.
  112659. * @param whichEye Define the eye we want the parameter for
  112660. * @returns the eye parameters
  112661. */
  112662. getEyeParameters(whichEye: string): VREyeParameters;
  112663. /**
  112664. * Populates the passed VRFrameData with the information required to render
  112665. * the current frame.
  112666. * @param frameData Define the data structure to populate
  112667. * @returns true if ok otherwise false
  112668. */
  112669. getFrameData(frameData: VRFrameData): boolean;
  112670. /**
  112671. * Get the layers currently being presented.
  112672. * @returns the list of VR layers
  112673. */
  112674. getLayers(): VRLayer[];
  112675. /**
  112676. * Return a VRPose containing the future predicted pose of the VRDisplay
  112677. * when the current frame will be presented. The value returned will not
  112678. * change until JavaScript has returned control to the browser.
  112679. *
  112680. * The VRPose will contain the position, orientation, velocity,
  112681. * and acceleration of each of these properties.
  112682. * @returns the pose object
  112683. */
  112684. getPose(): VRPose;
  112685. /**
  112686. * Return the current instantaneous pose of the VRDisplay, with no
  112687. * prediction applied.
  112688. * @returns the current instantaneous pose
  112689. */
  112690. getImmediatePose(): VRPose;
  112691. /**
  112692. * The callback passed to `requestAnimationFrame` will be called
  112693. * any time a new frame should be rendered. When the VRDisplay is
  112694. * presenting the callback will be called at the native refresh
  112695. * rate of the HMD. When not presenting this function acts
  112696. * identically to how window.requestAnimationFrame acts. Content should
  112697. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112698. * asynchronously from other displays and at differing refresh rates.
  112699. * @param callback Define the eaction to run next frame
  112700. * @returns the request handle it
  112701. */
  112702. requestAnimationFrame(callback: FrameRequestCallback): number;
  112703. /**
  112704. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112705. * Repeat calls while already presenting will update the VRLayers being displayed.
  112706. * @param layers Define the list of layer to present
  112707. * @returns a promise to know when the request has been fulfilled
  112708. */
  112709. requestPresent(layers: VRLayer[]): Promise<void>;
  112710. /**
  112711. * Reset the pose for this display, treating its current position and
  112712. * orientation as the "origin/zero" values. VRPose.position,
  112713. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112714. * updated when calling resetPose(). This should be called in only
  112715. * sitting-space experiences.
  112716. */
  112717. resetPose(): void;
  112718. /**
  112719. * The VRLayer provided to the VRDisplay will be captured and presented
  112720. * in the HMD. Calling this function has the same effect on the source
  112721. * canvas as any other operation that uses its source image, and canvases
  112722. * created without preserveDrawingBuffer set to true will be cleared.
  112723. * @param pose Define the pose to submit
  112724. */
  112725. submitFrame(pose?: VRPose): void;
  112726. }
  112727. declare var VRDisplay: {
  112728. prototype: VRDisplay;
  112729. new(): VRDisplay;
  112730. };
  112731. interface VRLayer {
  112732. leftBounds?: number[] | Float32Array | null;
  112733. rightBounds?: number[] | Float32Array | null;
  112734. source?: HTMLCanvasElement | null;
  112735. }
  112736. interface VRDisplayCapabilities {
  112737. readonly canPresent: boolean;
  112738. readonly hasExternalDisplay: boolean;
  112739. readonly hasOrientation: boolean;
  112740. readonly hasPosition: boolean;
  112741. readonly maxLayers: number;
  112742. }
  112743. interface VREyeParameters {
  112744. /** @deprecated */
  112745. readonly fieldOfView: VRFieldOfView;
  112746. readonly offset: Float32Array;
  112747. readonly renderHeight: number;
  112748. readonly renderWidth: number;
  112749. }
  112750. interface VRFieldOfView {
  112751. readonly downDegrees: number;
  112752. readonly leftDegrees: number;
  112753. readonly rightDegrees: number;
  112754. readonly upDegrees: number;
  112755. }
  112756. interface VRFrameData {
  112757. readonly leftProjectionMatrix: Float32Array;
  112758. readonly leftViewMatrix: Float32Array;
  112759. readonly pose: VRPose;
  112760. readonly rightProjectionMatrix: Float32Array;
  112761. readonly rightViewMatrix: Float32Array;
  112762. readonly timestamp: number;
  112763. }
  112764. interface VRPose {
  112765. readonly angularAcceleration: Float32Array | null;
  112766. readonly angularVelocity: Float32Array | null;
  112767. readonly linearAcceleration: Float32Array | null;
  112768. readonly linearVelocity: Float32Array | null;
  112769. readonly orientation: Float32Array | null;
  112770. readonly position: Float32Array | null;
  112771. readonly timestamp: number;
  112772. }
  112773. interface VRStageParameters {
  112774. sittingToStandingTransform?: Float32Array;
  112775. sizeX?: number;
  112776. sizeY?: number;
  112777. }
  112778. interface Navigator {
  112779. getVRDisplays(): Promise<VRDisplay[]>;
  112780. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112781. }
  112782. interface Window {
  112783. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112784. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112785. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112786. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112787. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112788. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112789. }
  112790. interface Gamepad {
  112791. readonly displayId: number;
  112792. }
  112793. interface XRDevice {
  112794. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112795. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112796. }
  112797. interface XRSession {
  112798. getInputSources(): Array<any>;
  112799. baseLayer: XRWebGLLayer;
  112800. requestFrameOfReference(type: string): Promise<void>;
  112801. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112802. end(): Promise<void>;
  112803. requestAnimationFrame: Function;
  112804. addEventListener: Function;
  112805. }
  112806. interface XRSessionCreationOptions {
  112807. outputContext?: WebGLRenderingContext | null;
  112808. immersive?: boolean;
  112809. environmentIntegration?: boolean;
  112810. }
  112811. interface XRLayer {
  112812. getViewport: Function;
  112813. framebufferWidth: number;
  112814. framebufferHeight: number;
  112815. }
  112816. interface XRView {
  112817. projectionMatrix: Float32Array;
  112818. }
  112819. interface XRFrame {
  112820. getDevicePose: Function;
  112821. getInputPose: Function;
  112822. views: Array<XRView>;
  112823. baseLayer: XRLayer;
  112824. }
  112825. interface XRFrameOfReference {
  112826. }
  112827. interface XRWebGLLayer extends XRLayer {
  112828. framebuffer: WebGLFramebuffer;
  112829. }
  112830. declare var XRWebGLLayer: {
  112831. prototype: XRWebGLLayer;
  112832. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112833. };